This commit is contained in:
2026-09-25 16:32:09 +03:00
parent bf932e5ef9
commit d26e8b2621
33 changed files with 2080 additions and 595 deletions

View File

@@ -88,6 +88,42 @@ type ItemAudit struct {
// TTL
TTL string `json:"_ttl"`
// Resource group ID
ResgroupID uint64 `json:"resgroup_id"`
// Account ID
AccountID uint64 `json:"account_id"`
// Compute ID
ComputeID uint64 `json:"compute_id"`
// VINS ID
VINSID uint64 `json:"vins_id"`
// Service ID
ServiceID uint64 `json:"service_id"`
// K8S ID
K8SID uint64 `json:"k8s_id"`
// FLIPGroup ID
FLIPGroupID uint64 `json:"flipgroup_id"`
// Load balancer ID
LBID uint64 `json:"lb_id"`
// SEP ID
SEPID uint64 `json:"sep_id"`
// Node IDs
NodeIDs []uint64 `json:"node_ids"`
// Persistent disk IDs associated with the operation
DiskIDs []uint64 `json:"disk_ids"`
// API task ID for asynchronous calls
APITask string `json:"apitask"`
}
// List of audits

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -51,14 +52,14 @@ type AffinityRuleAddRequest struct {
type wrapperAffinityRuleAddRequest struct {
AffinityRuleAddRequest
AsyncMode bool `url:"async_mode"`
AsyncMode bool `url:"async_mode" json:"async_mode"`
}
// AffinityRuleAdd add affinity rule
func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (bool, error) {
func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (AffinityRuleAddResult, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
return AffinityRuleAddResult{}, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/compute/affinityRuleAdd"
@@ -68,17 +69,24 @@ func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest
AsyncMode: false,
}
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq)
if err != nil {
return false, err
return AffinityRuleAddResult{}, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
if !req.Migrate {
result, err := strconv.ParseBool(string(res))
return AffinityRuleAddResult{Ok: result}, err
}
return result, nil
var report MigrationReport
err = json.Unmarshal(res, &report)
if err != nil {
return AffinityRuleAddResult{}, err
}
return AffinityRuleAddResult{Ok: report.Applied, MigrationReport: &report}, nil
}
// AsyncAffinityRuleAdd add affinity rule in async mode
@@ -95,7 +103,7 @@ func (c Compute) AsyncAffinityRuleAdd(ctx context.Context, req AffinityRuleAddRe
AsyncMode: true,
}
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq)
if err != nil {
return "", err
}

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
@@ -51,14 +52,14 @@ type AntiAffinityRuleAddRequest struct {
type wrapperAntiAffinityRuleAddRequest struct {
AntiAffinityRuleAddRequest
AsyncMode bool `url:"async_mode"`
AsyncMode bool `url:"async_mode" json:"async_mode"`
}
// AntiAffinityRuleAdd add anti affinity rule
func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest) (bool, error) {
func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest) (AntiAffinityRuleAddResult, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
return AntiAffinityRuleAddResult{}, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/compute/antiAffinityRuleAdd"
@@ -68,17 +69,24 @@ func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAd
AsyncMode: false,
}
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq)
if err != nil {
return false, err
return AntiAffinityRuleAddResult{}, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
if !req.Migrate {
result, err := strconv.ParseBool(string(res))
return AntiAffinityRuleAddResult{Ok: result}, err
}
return result, nil
var report MigrationReport
err = json.Unmarshal(res, &report)
if err != nil {
return AntiAffinityRuleAddResult{}, err
}
return AntiAffinityRuleAddResult{Ok: report.Applied, MigrationReport: &report}, nil
}
// AsyncAntiAffinityRuleAdd add anti affinity rule in async mode
@@ -95,7 +103,7 @@ func (c Compute) AsyncAntiAffinityRuleAdd(ctx context.Context, req AntiAffinityR
AsyncMode: true,
}
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, aReq)
if err != nil {
return "", err
}

View File

@@ -39,10 +39,6 @@ type CreateTemplateFromBlankRequest struct {
// 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"`
// Pool for image create
// Required: false
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`

View File

@@ -575,6 +575,9 @@ type RecordCompute struct {
// Zone ID
// Required: false
ZoneID uint64 `json:"zoneId"`
// Folder ID
FolderID uint64 `json:"folder_id"`
}
// Detailed information about ACL Access in a compute
@@ -1564,6 +1567,9 @@ type ItemCompute struct {
// Zone ID
ZoneID uint64 `json:"zoneId"`
// Folder ID
FolderID uint64 `json:"folder_id"`
}
// ListInfoDisks
@@ -1743,3 +1749,47 @@ type CloneStatus struct {
// Progress percent
ProgressPercent int `json:"progress_percent"`
}
type MigrationReportItem struct {
// ID of the compute instance
ComputeID uint64 `json:"compute_id"`
// Per-VM action result, not workflow status
// Should be one of:
// - migrated: migration completed; the rule may still be unsatisfied
// - skipped: migration was not needed or applicable
// - not_started: submission was not attempted
// - not_completed: completion is unconfirmed; the VM may have moved
Status string `json:"status"`
// Action details, errors and final rule-placement warnings
Message string `json:"message"`
// Workflow ID for tracking, or nil if submission was not attempted.
// A non-nil ID does not confirm job acceptance
WorkflowJobID *string `json:"workflow_job_id"`
}
type MigrationReport struct {
// Rules were saved; does not confirm migration success or rule satisfaction
Applied bool `json:"applied"`
// Per-compute migration results
Migrations []MigrationReportItem `json:"migrations"`
}
type AffinityRuleAddResult struct {
// Result of the rule addition
Ok bool
// Migration report. Populated only when the request was made with Migrate=true, nil otherwise
MigrationReport *MigrationReport
}
type AntiAffinityRuleAddResult struct {
// Result of the rule addition
Ok bool
// Migration report. Populated only when the request was made with Migrate=true, nil otherwise
MigrationReport *MigrationReport
}

View File

@@ -35,10 +35,6 @@ type FromPlatformDiskRequest struct {
// 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"`
// Pool for image create
// Required: false
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`

View File

@@ -93,6 +93,9 @@ type ItemReservation struct {
// Account ID
AccountID uint64 `json:"account_id"`
// Auto assignable
AutoAssignable bool `json:"auto_assignable"`
// ClientType
ClientType string `json:"clientType"`
@@ -127,6 +130,12 @@ type VNFs struct {
}
type Excluded struct {
// Account ID
AccountID uint64 `json:"account_id"`
// Auto assignable
AutoAssignable bool `json:"auto_assignable"`
// ClientType
ClientType string `json:"clientType"`

View File

@@ -230,6 +230,10 @@ type CreateRequest struct {
// Required: false
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
// List of PCI device IDs to attach to this VM
// Required: false
PCIdevices []uint64 `url:"pcidevices,omitempty" json:"pcidevices,omitempty"`
// Zone ID
// Required: false
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
@@ -252,6 +256,10 @@ type CreateRequest struct {
// Required: false
// Default: "auto"
MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"`
// List of vGPU IDs to attach to the VM
// Required: false
VGPUs []uint64 `url:"vgpus,omitempty" json:"vgpus,omitempty"`
}
// GetRAM returns RAM field values

View File

@@ -92,6 +92,10 @@ type CreateBlankRequest struct {
// Required: false
PreferredCPU []int64 `url:"preferredCpu,omitempty" json:"preferredCpu,omitempty" validate:"omitempty,preferredCPU"`
// List of PCI device IDs to attach to this VM
// Required: false
PCIdevices []uint64 `url:"pcidevices,omitempty" json:"pcidevices,omitempty"`
// VM type linux, windows or unknown
// Required: false
LoaderType string `url:"loaderType,omitempty" json:"loaderType,omitempty" validate:"omitempty,loaderType"`
@@ -134,6 +138,10 @@ type CreateBlankRequest struct {
// Required: false
// Default: "auto"
MemoryBalloonMode string `url:"memory_balloon_mode,omitempty" json:"memory_balloon_mode,omitempty" validate:"omitempty,memoryBalloonMode"`
// List of vGPU IDs to attach to the VM
// Required: false
VGPUs []uint64 `url:"vgpus,omitempty" json:"vgpus,omitempty"`
}
// GetRAM returns RAM field values