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

@@ -12,11 +12,47 @@ import (
type AuditsRequest struct {
// ID of the compute
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
// Find all audits after point in time
// Required: false
TimestampAT uint64 `url:"timestamp_at,omitempty" json:"timestamp_at,omitempty"`
// Find all audits before point in time
// Required: false
TimestampTO uint64 `url:"timestamp_to,omitempty" json:"timestamp_to,omitempty"`
// Find by user
// Required: false
User string `url:"user,omitempty" json:"user,omitempty"`
// Find by api endpoints
// Required: false
Call string `url:"call,omitempty" json:"call,omitempty"`
// Sort by one of supported fields, format ±<field>
// Required: false
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
// Page number
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
// Page size
// Required: false
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
// Find by HTTP min status code
// Required: false
MinStatusCode uint64 `url:"min_status_code,omitempty" json:"min_status_code,omitempty"`
// Find by HTTP max status code
// Required: false
MaxStatusCode uint64 `url:"max_status_code,omitempty" json:"max_status_code,omitempty"`
}
// Audits gets audit records for the specified compute object
func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListDetailedAudits, error) {
func (c Compute) Audits(ctx context.Context, req AuditsRequest) (*ListDetailedAudits, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
@@ -24,7 +60,7 @@ func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListDetailedAud
url := "/cloudbroker/compute/audits"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
if err != nil {
return nil, err
}
@@ -36,5 +72,5 @@ func (c Compute) Audits(ctx context.Context, req AuditsRequest) (ListDetailedAud
return nil, err
}
return list, nil
return &list, nil
}

View File

@@ -0,0 +1,50 @@
package compute
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ChangeSecGroupsRequest struct to change security groups for compute
type ChangeSecGroupsRequest struct {
// Identifier compute
// Required: true
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
// Interface name or MAC address
// Required: true
Interface string `url:"interface" json:"interface" validate:"required"`
// List of security group IDs to assign to this interface
// Required: false
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
// Flag indicating whether security groups are enabled for this interface
// Required: false
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
}
// ChangeSecGroups changes security groups for compute
func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/change_security_groups"
res, err := c.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

@@ -27,6 +27,10 @@ type CreateTemplateFromBlankRequest struct {
// Required: true
ImageType string `url:"imagetype" json:"imagetype" validate:"imageType"`
// Storage policy id of compute. The rules of the specified storage policy will be used.
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// Username for the image
// Required: false
Username string `url:"username,omitempty" json:"username,omitempty"`

View File

@@ -27,6 +27,10 @@ type DiskAddRequest struct {
// Required: false
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
// Storage policy id of compute. The rules of the specified storage policy will be used.
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// Type of the disk
// Should be one of:
// - D

View File

@@ -74,6 +74,11 @@ type ListRequest struct {
// Required: false
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
// Sort by zone id
// Default value: 0
// Required: false
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
// Page number
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`

View File

@@ -25,7 +25,7 @@ type MigrateRequest struct {
Force bool `url:"force,omitempty" json:"force,omitempty"`
}
type asyncWrapperMigrateRequest struct {
type AsyncWrapperMigrateRequest struct {
MigrateRequest
SyncMode bool `url:"sync"`
}
@@ -39,7 +39,7 @@ func (c Compute) Migrate(ctx context.Context, req MigrateRequest) (bool, error)
url := "/cloudbroker/compute/migrate"
syncReq := asyncWrapperMigrateRequest{MigrateRequest: req, SyncMode: true}
syncReq := AsyncWrapperMigrateRequest{MigrateRequest: req, SyncMode: true}
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
if err != nil {
@@ -63,7 +63,7 @@ func (c Compute) AsyncMigrate(ctx context.Context, req MigrateRequest) (string,
url := "/cloudbroker/compute/migrate"
asyncReq := asyncWrapperMigrateRequest{MigrateRequest: req, SyncMode: false}
asyncReq := AsyncWrapperMigrateRequest{MigrateRequest: req, SyncMode: false}
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
if err != nil {

View File

@@ -221,8 +221,14 @@ type ItemDetailedAudit struct {
User string `json:"user"`
}
// List of detailed audit
type ListDetailedAudits []ItemDetailedAudit
// List Detailed audits
type ListDetailedAudits struct {
// Data
Data []ItemDetailedAudit `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
// Main information about port forward
type ItemPFW struct {
@@ -475,9 +481,15 @@ type ItemDisk struct {
// Status
Status string `json:"status"`
// Storage policy id of disk.
StoragePolicyID uint64 `json:"storage_policy_id"`
// Tech status
TechStatus string `json:"techStatus"`
// Need to clean before destroy
ToClean bool `json:"to_clean"`
// Type
Type string `json:"type"`
@@ -525,6 +537,9 @@ type ItemInterface struct {
// Enabled
Enabled bool `json:"enabled"`
// Enable security groups
EnableSecGroups bool `json:"enable_secgroups"`
// FLIPGroup ID
FLIPGroupID uint64 `json:"flipgroupId"`
@@ -567,6 +582,9 @@ type ItemInterface struct {
// QOS
QOS QOS `json:"qos"`
// List of security groups
SecGroups []uint64 `json:"security_groups"`
// SDN interface ID
SDNInterfaceID string `json:"sdn_interface_id"`

View File

@@ -42,12 +42,24 @@ type NetAttachRequest struct {
// Used only for EXTNET and DPDK
// For DPDK must be 1-9216
// For EXTNET must be 1500-9216
// Required: false
// Required: false
MTU uint64 `url:"mtu,omitempty" json:"mtu,omitempty" validate:"omitempty,mtu"`
// Unique identifier of logical port on SDN side
// Required: false
SDNInterfaceID string `url:"sdn_interface_id,omitempty" json:"sdn_interface_id,omitempty" validate:"omitempty"`
// List of security group IDs to assign to this interface
// Required: false
SecGroups []uint64 `url:"security_groups,omitempty" json:"security_groups,omitempty"`
// Flag indicating whether security groups are enabled for this interface
// Required: false
EnableSecGroups bool `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty"`
// Flag indicating whether this interface is enabled (only for VINS, EXTNET, DPDK, SDN, TRUNK)
// Required: false
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
}
// NetAttach attaches network to compute and gets info about network

View File

@@ -18,6 +18,10 @@ type RedeployRequest struct {
// Required: false
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
// Storage policy id of compute. The rules of the specified storage policy will be used.
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// New size for the boot disk in GB, if boot disk size change is required
// Required: false
DiskSize uint64 `url:"diskSize,omitempty" json:"diskSize,omitempty"`