This commit is contained in:
asteam
2025-09-27 01:06:15 +03:00
parent 1ccc37a104
commit cf584c8123
1175 changed files with 11022 additions and 1832 deletions

View File

@@ -0,0 +1,41 @@
package image
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
type ChangeStoragePolicyRequest struct {
// ID of the image to change the storage policy
// Required: true
ImageID uint64 `url:"image_id" json:"image_id" validate:"required"`
// ID of the storage policy to move the image to
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
}
// ChangeStoragePolicy changes the storage policy of the image chosen
func (i Image) ChangeStoragePolicy(ctx context.Context, req ChangeStoragePolicyRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/image/change_storage_policy"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// ComputeCISetRequest struct to set compute CI

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// ComputeCIUnsetRequest struct to unset compute CI

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// CreateCDROMImageRequest struct to create CD-ROM image
@@ -18,6 +18,10 @@ type CreateCDROMImageRequest struct {
// Required: true
URL string `url:"url" json:"url" validate:"required,url"`
// ID of the chosen storage policy
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// Account ID to make the image exclusive
// Required: false
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
@@ -37,17 +41,6 @@ type CreateCDROMImageRequest struct {
// Password for remote media download
// 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
Drivers []string `url:"drivers,omitempty" json:"drivers,omitempty" validate:"max=2,imageDrivers"`
}
// CreateCDROMImage creates CD-ROM image from an ISO identified by URL

View File

@@ -2,15 +2,16 @@ package image
import (
"context"
"encoding/json"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// CreateRequest struct to create image
type CreateRequest struct {
// Name of the rescue disk
// Name of the image
// Required: true
Name string `url:"name" json:"name" validate:"required"`
@@ -33,6 +34,10 @@ type CreateRequest struct {
// Required: true
ImageType string `url:"imagetype" json:"imagetype" validate:"required,imageType"`
// ID of the chosen storage policy
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming
// Should be:
// - eth
@@ -72,22 +77,16 @@ 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
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"`
}
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)
@@ -97,7 +96,9 @@ func (i Image) CreateImage(ctx context.Context, req CreateRequest) (uint64, erro
url := "/cloudbroker/image/createImage"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
syncReq := asyncWrapperCreateRequest{CreateRequest: req, AsyncMode: false}
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
if err != nil {
return 0, err
}
@@ -109,3 +110,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/createImage"
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
}

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// CreateVirtualRequest struct to create virtual image
@@ -17,6 +17,11 @@ type CreateVirtualRequest struct {
// ID of real image to link this virtual image to upon creation
// Required: true
TargetID uint64 `url:"targetId" json:"targetId" validate:"required"`
// AccountID to make the virtual image exclusive
// Required: false
// Default: 0
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
}
// CreateVirtual creates virtual image

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// DeleteRequest struct to delete image

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// DeleteCDROMImageRequest struct to delete CD-ROM image

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// DeleteImagesRequest struct to delete images

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// DisableRequest struct to disable image

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// EditRequest struct to edit image

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// EnableRequest struct to enable image

View File

@@ -5,7 +5,7 @@ import (
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// GetRequest struct to get image details

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// GrantAccessRequest struct to share image with accounts

View File

@@ -1,7 +1,7 @@
// Lists all the images. A image is a template which can be used to deploy machines
package image
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces"
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces"
// Structure for creating request to image
type Image struct {

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// LinkRequest struct to link virtual image to another image

View File

@@ -5,7 +5,7 @@ import (
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// ListRequest struct to get list of available images
@@ -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"`
@@ -73,6 +69,10 @@ type ListRequest struct {
// Find by enabled True or False
// Required: false
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
// Find by storage policy id
// Required: false
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
}
// List gets list of information about images as a ListImages struct

View File

@@ -5,7 +5,7 @@ import (
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// ListStacksRequest struct to get list of stack

View File

@@ -110,6 +110,9 @@ type RecordImage struct {
// Status
Status string `json:"status"`
// Storage policy ID
StoragePolicyID uint64 `json:"storage_policy_id"`
// Tech status
TechStatus string `json:"techStatus"`
@@ -236,6 +239,9 @@ type ItemImage struct {
// Status
Status string `json:"status"`
// Storage policy ID
StoragePolicyID uint64 `json:"storage_policy_id"`
// Tech status
TechStatus string `json:"techStatus"`
@@ -331,9 +337,6 @@ type ItemListStacks struct {
// CKey
CKey string `json:"_ckey"`
// Meta
Meta []interface{} `json:"_meta"`
// API URL
APIURL string `json:"apiUrl"`

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// RenameRequest struct to rename image

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// RevokeAccessRequest struct to unshare image with accounts

View File

@@ -3,7 +3,7 @@ package image
import (
"encoding/json"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization"
)
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// ShareRequest struct to share image

View File

@@ -1,111 +0,0 @@
package image
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/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
}

View File

@@ -1,42 +0,0 @@
package image
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
)
// UpdateNodesRequest struct to update nodes
type UpdateNodesRequest struct {
// Image ID
// Required: true
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
// List of stacks
// Required: false
EnabledStacks []uint64 `url:"enabledStacks,omitempty" json:"enabledStacks,omitempty"`
}
// UpdateNodes updates image availability on nodes
func (i Image) UpdateNodes(ctx context.Context, req UpdateNodesRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/image/updateNodes"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}