This commit is contained in:
dayterr
2026-02-27 17:02:27 +03:00
parent b834e5d074
commit c2c810504d
34 changed files with 118 additions and 268 deletions

View File

@@ -2,8 +2,8 @@ package compute
import (
"context"
"encoding/json"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
@@ -17,22 +17,24 @@ type CloneAbortRequest struct {
}
// CloneAbort aborts a compute clone
func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) (bool, error) {
func (c Compute) CloneAbort(ctx context.Context, req CloneAbortRequest) ([]RecordCloneAbort, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/clone_abort"
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
if err != nil {
return false, err
return nil, err
}
result, err := strconv.ParseBool(string(res))
result := make([]RecordCloneAbort, 0)
err = json.Unmarshal(res, &result)
if err != nil {
return false, err
return nil, err
}
return result, nil

View File

@@ -31,13 +31,6 @@ type DiskAddRequest struct {
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// Type of the disk
// Should be one of:
// - D
// - B
// Required: false
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty" validate:"omitempty,computeDiskType"`
// Pool name
// By default will be chosen automatically
// Required: false

View File

@@ -18,10 +18,6 @@ type DiskAttachRequest struct {
// Required: true
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
// Type of the disk B;D
// Required: false
DiskType string `url:"diskType,omitempty" json:"diskType,omitempty"`
// Desired PCI slot (hex string, e.g. "0x1A")
// Required: false
PCISlot string `url:"pci_slot,omitempty" json:"pci_slot,omitempty"`

View File

@@ -891,6 +891,9 @@ type InfoCompute struct {
// VINS connected
VINSConnected uint64 `json:"vinsConnected"`
// Weight
Weight uint64 `json:"weight"`
// Zone ID
ZoneID uint64 `json:"zoneId"`
}
@@ -1178,6 +1181,9 @@ type RecordCompute struct {
// VNC password
VNCPassword string `json:"vncPasswd"`
// Weight
Weight uint64 `json:"weight"`
// Zone ID
ZoneID uint64 `json:"zoneId"`
@@ -1469,6 +1475,14 @@ type MigrateStorageItem struct {
TargetNodeID uint64 `json:"targetNodeId"`
}
type RecordCloneAbort struct {
// Disk ID
DiskID uint64 `json:"disk_id"`
// Abort status
Status bool `json:"status"`
}
type RecordCloneStatus struct {
// Disk ID
DiskID int `json:"disk_id"`

View File

@@ -69,6 +69,10 @@ type UpdateRequest struct {
// The OS version that will be installed on the virtual machine
// Required: false
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
// Priority weight of the compute: higher value means higher priority and later migration
// Required: false
Weight uint64 `url:"weight,omitempty" json:"weight,omitempty"`
}
// Update updates some properties of the compute

View File

@@ -59,7 +59,6 @@ var disks = ListDisks{
Snapshots: []ItemSnapshot{},
Status: "ASSIGNED",
TechStatus: "ALLOCATED",
Type: "B",
VMID: 48500,
},
},
@@ -120,7 +119,6 @@ var disks = ListDisks{
Snapshots: []ItemSnapshot{},
Status: "ASSIGNED",
TechStatus: "ALLOCATED",
Type: "B",
VMID: 48502,
},
},

View File

@@ -38,10 +38,6 @@ type ListRequest struct {
// Required: false
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
// Type of the disks
// Required: false
Type string `url:"type,omitempty" json:"type,omitempty"`
// Find by sep ID
// Required: false
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
@@ -65,6 +61,14 @@ type ListRequest struct {
// Page size
// Required: false
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
// ID of the resource group
// Required: false
RGID uint64 `url:"rg_id,omitempty" json:"rg_id,omitempty"`
// ID of the compute
// Required: false
ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"`
}
// List gets list of the created disks belonging to an account as a ListDisks struct

View File

@@ -34,10 +34,6 @@ type ListDeletedRequest struct {
// Required: false
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
// Type of the disks
// Required: false
Type string `url:"type,omitempty" json:"type,omitempty"`
// Sort by one of supported fields, format +|-(field)
// Required: false
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`

View File

@@ -1,53 +0,0 @@
package disks
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ListTypesRequest struct to get list of types of disks
type ListTypesRequest struct {
// Show detailed disk types by seps
// Required: false
Detailed bool `url:"detailed" json:"detailed"`
// Sort by one of supported fields, format +|-(field)
// Required: false
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
// Page number
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
// Page size
// Required: false
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
}
// ListTypes gets list of defined disk types
func (d Disks) ListTypes(ctx context.Context, req ListTypesRequest) (*ListTypes, error) {
if err := validators.ValidateRequest(req); err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/disks/listTypes"
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
list := ListTypes{}
err = json.Unmarshal(res, &list)
if err != nil {
return nil, err
}
return &list, nil
}

View File

@@ -26,10 +26,6 @@ type ListUnattachedRequest struct {
// Required: false
Status string `url:"status,omitempty" json:"status,omitempty"`
// Type of the disks
// Required: false
Type string `url:"type,omitempty" json:"type,omitempty"`
// ID of the account
// Required: false
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`

View File

@@ -185,9 +185,6 @@ type InfoDisk struct {
// Need to clean before destroy
ToClean bool `json:"to_clean"`
// Type
Type string `json:"type"`
// Virtual machine ID
VMID uint64 `json:"vmid"`
@@ -322,14 +319,6 @@ type ItemSnapshot struct {
// List snapshots
type ListSnapshots []ItemSnapshot
type ListTypes struct {
// Data
Data []interface{} `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
type MigrateStatus struct {
// Type
Type int `json:"type"`

View File

@@ -235,6 +235,11 @@ type CreateRequest struct {
// Boot Disk BLK Discard
// Required: false
BootDiskBLKDiscard interface{} `url:"boot_disk_blkdiscard,omitempty" json:"boot_disk_blkdiscard,omitempty" validate:"omitempty,isBool"`
// Priority weight of the VM: higher value means higher priority and later migration
// Required: false
// Default: 1
Weight uint64 `url:"weight,omitempty" json:"weight,omitempty"`
}
// GetRAM returns RAM field values

View File

@@ -123,6 +123,11 @@ type CreateBlankRequest struct {
// Boot Disk BLK Discard
// Required: false
BootDiskBLKDiscard interface{} `url:"boot_disk_blkdiscard" json:"boot_disk_blkdiscard" validate:"omitempty,isBool"`
// Priority weight of the VM: higher value means higher priority and later migration
// Required: false
// Default: 1
Weight uint64 `url:"weight,omitempty" json:"weight,omitempty"`
}
// GetRAM returns RAM field values

View File

@@ -160,6 +160,11 @@ type MassCreateRequest struct {
// Boot Disk BLK Discard
// Required: false
BootDiskBLKDiscard interface{} `url:"boot_disk_blkdiscard" json:"boot_disk_blkdiscard" validate:"omitempty,isBool"`
// Priority weight of the VM: higher value means higher priority and later migration
// Required: false
// Default: 1
Weight uint64 `url:"weight,omitempty" json:"weight,omitempty"`
}
type asyncWrapperMassCreateRequest struct {

View File

@@ -79,6 +79,9 @@ type ListResourceConsumption struct {
// Access Control List
type ACL struct {
// Email
Email string `json:"email"`
// Explicit
Explicit bool `json:"explicit"`

View File

@@ -22,8 +22,8 @@ type InfoStoragePolicyWithID struct {
// Max IOPS for the sotrage policy
LimitIOPS uint64 `json:"limit_iops"`
// ID of the storage policy
StoragePolicyID uint64 `json:"storage_policy_id"`
// Which accounts and resource groups use the storage policy
Usage Usage `json:"usage"`
}
type ListStoragePolicies struct {