This commit is contained in:
asteam
2025-08-29 12:51:25 +03:00
parent e10ee7f801
commit 825b1a0a00
177 changed files with 4821 additions and 349 deletions

View File

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

@@ -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,11 +41,6 @@ type CreateCDROMImageRequest struct {
// Password for remote media download
// Required: false
PasswordDl string `url:"passwordDL,omitempty" json:"passwordDL,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

@@ -34,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
@@ -73,11 +77,6 @@ type CreateRequest struct {
// Required: false
PoolName string `url:"poolName,omitempty" json:"poolName,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"`

View File

@@ -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

@@ -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"`