v1.12.0
This commit is contained in:
@@ -38,12 +38,6 @@ type CreateCDROMImageRequest struct {
|
||||
// Required: false
|
||||
PasswordDl string `url:"passwordDL,omitempty" json:"passwordDL,omitempty"`
|
||||
|
||||
// Binary architecture of this image
|
||||
// Should be one of:
|
||||
// - X86_64
|
||||
// Required: false
|
||||
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"`
|
||||
|
||||
// List of types of compute suitable for image.
|
||||
// Example: [ "KVM_X86" ]
|
||||
// Required: false
|
||||
|
||||
@@ -2,6 +2,7 @@ package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -72,12 +73,6 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||
|
||||
// Binary architecture of this image
|
||||
// Should be one of:
|
||||
// - X86_64
|
||||
// Required: false
|
||||
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"`
|
||||
|
||||
// List of types of compute suitable for image
|
||||
// Example: [ "KVM_X86" ]
|
||||
// Required: required
|
||||
@@ -88,6 +83,11 @@ type CreateRequest struct {
|
||||
Bootable bool `url:"bootable,omitempty" json:"bootable,omitempty"`
|
||||
}
|
||||
|
||||
type asyncWrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateImage creates image from a media identified by URL
|
||||
func (i Image) CreateImage(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -109,3 +109,29 @@ func (i Image) CreateImage(ctx context.Context, req CreateRequest) (uint64, erro
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AsyncCreate creates image from a media identified by URL in async mode
|
||||
func (i Image) AsyncCreateImage(ctx context.Context, req CreateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/create"
|
||||
|
||||
asyncReq := asyncWrapperCreateRequest{CreateRequest: req, AsyncMode: true}
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
|
||||
if err != nil {
|
||||
return " ", err
|
||||
}
|
||||
|
||||
var taskID string
|
||||
|
||||
err = json.Unmarshal(res, &taskID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return taskID, nil
|
||||
}
|
||||
|
||||
@@ -26,10 +26,6 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by architecture
|
||||
// Required: false
|
||||
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"`
|
||||
|
||||
// Find by type
|
||||
// Required: false
|
||||
TypeImage string `url:"typeImage,omitempty" json:"typeImage,omitempty"`
|
||||
|
||||
@@ -331,9 +331,6 @@ type ItemListStacks struct {
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// API URL
|
||||
APIURL string `json:"apiUrl"`
|
||||
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// SyncCreateRequest struct to sync create image
|
||||
type SyncCreateRequest struct {
|
||||
// Name of the rescue disk
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// URL where to download media from
|
||||
// Required: true
|
||||
URL string `url:"url" json:"url" validate:"required"`
|
||||
|
||||
// Boot type of image
|
||||
// Should be one of:
|
||||
// - bios
|
||||
// - UEFI
|
||||
// Required: true
|
||||
BootType string `url:"boottype" json:"boottype" validate:"required,imageBootType"`
|
||||
|
||||
// Image type
|
||||
// Should be one of:
|
||||
// - linux
|
||||
// - windows
|
||||
// - or other
|
||||
// Required: true
|
||||
ImageType string `url:"imagetype" json:"imagetype" validate:"required,imageType"`
|
||||
|
||||
// Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming
|
||||
// Should be:
|
||||
// - eth
|
||||
// - ens (default value)
|
||||
// Required: false
|
||||
NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"`
|
||||
|
||||
// Does this machine supports hot resize
|
||||
// Required: false
|
||||
HotResize bool `url:"hotresize,omitempty" json:"hotresize,omitempty"`
|
||||
|
||||
// Optional username for the image
|
||||
// Required: false
|
||||
Username string `url:"username,omitempty" json:"username,omitempty"`
|
||||
|
||||
// Optional password for the image
|
||||
// Required: false
|
||||
Password string `url:"password,omitempty" json:"password,omitempty"`
|
||||
|
||||
// Account ID to make the image exclusive
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Username for upload binary media
|
||||
// Required: false
|
||||
UsernameDL string `url:"usernameDL,omitempty" json:"usernameDL,omitempty"`
|
||||
|
||||
// Password for upload binary media
|
||||
// Required: false
|
||||
PasswordDL string `url:"passwordDL,omitempty" json:"passwordDL,omitempty"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool for image create
|
||||
// Required: false
|
||||
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||
|
||||
// Binary architecture of this image
|
||||
// Should be one of:
|
||||
// - X86_64
|
||||
// Required: false
|
||||
Architecture string `url:"architecture,omitempty" json:"architecture,omitempty"`
|
||||
|
||||
// List of types of compute suitable for image
|
||||
// Example: [ "KVM_X86" ]
|
||||
// Required: true
|
||||
Drivers []string `url:"drivers" json:"drivers" validate:"min=1,max=2,imageDrivers"`
|
||||
|
||||
// Bootable image or not
|
||||
// Required: false
|
||||
Bootable bool `url:"bootable,omitempty" json:"bootable,omitempty"`
|
||||
}
|
||||
|
||||
// SyncCreate creates image from a media identified by URL (in synchronous mode)
|
||||
func (i Image) SyncCreate(ctx context.Context, req SyncCreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/syncCreateImage"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user