v1.16.0
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// AuditsRequest struct to get audit records
|
||||
type AuditsRequest struct {
|
||||
// ID of the compute
|
||||
// Required: true
|
||||
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) (*ListAudits, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/audits"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListAudits{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
84
pkg/cloudapi/compute/change_qos_policies.go
Normal file
84
pkg/cloudapi/compute/change_qos_policies.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type ChangeQoSPoliciesRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
|
||||
// Interface IP or MAC address
|
||||
// Required: true
|
||||
Interface string `url:"interface" json:"interface" validate:"required"`
|
||||
|
||||
// List of QoS Policy IDs to assign to this interface
|
||||
// Required: false
|
||||
QoSPolicyIDs []uint64 `url:"qos_policy_ids,omitempty" json:"qos_policy_ids,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperChangeQoSPoliciesRequest struct {
|
||||
ChangeQoSPoliciesRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// ChangeQoSPolicies change qos policies for compute
|
||||
func (c Compute) ChangeQoSPolicies(ctx context.Context, req ChangeQoSPoliciesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperChangeQoSPoliciesRequest{
|
||||
ChangeQoSPoliciesRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/change_qos_policies"
|
||||
|
||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ChangeQoSPolicies change qos policies for compute with AsyncMode
|
||||
func (c Compute) ChangeQoSPoliciesAsync(ctx context.Context, req ChangeQoSPoliciesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperChangeQoSPoliciesRequest{
|
||||
ChangeQoSPoliciesRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/change_qos_policies"
|
||||
|
||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetAuditsRequest struct to get compute audits
|
||||
type GetAuditsRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
// GetAudits gets compute audits
|
||||
func (c Compute) GetAudits(ctx context.Context, req GetAuditsRequest) (ListShortAudits, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/getAudits"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListShortAudits{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
@@ -14,10 +14,6 @@ type ListPCIDeviceRequest struct {
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Find by resource group ID
|
||||
// Required: false
|
||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||
|
||||
// Find by device id
|
||||
// Required: false
|
||||
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
||||
|
||||
@@ -558,11 +558,14 @@ type RecordCompute struct {
|
||||
Userdata interface{} `json:"userdata"`
|
||||
|
||||
// vGPUs list
|
||||
VGPUs []VGPUItem `json:"vgpus"`
|
||||
VGPUs []ItemVGPU `json:"vgpus"`
|
||||
|
||||
// VNC password
|
||||
VNCPassword string `json:"vncPasswd"`
|
||||
|
||||
// Watchdog action
|
||||
WatchdogAction string `json:"watchdog_action"`
|
||||
|
||||
// Weight
|
||||
Weight uint64 `json:"weight"`
|
||||
|
||||
@@ -813,7 +816,7 @@ type SnapRecordCompute struct {
|
||||
Userdata interface{} `json:"userdata"`
|
||||
|
||||
// vGPUs list
|
||||
VGPUs []VGPUItem `json:"vgpus"`
|
||||
VGPUs []ItemVGPU `json:"vgpus"`
|
||||
|
||||
// VNC password
|
||||
VNCPassword string `json:"vncPasswd"`
|
||||
@@ -848,65 +851,6 @@ type CPUAlignmentProfile struct {
|
||||
Vendor string `json:"vendor"`
|
||||
}
|
||||
|
||||
type VGPUItem struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// GID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// Mode
|
||||
Mode string `json:"mode"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// ProfileID
|
||||
ProfileID uint64 `json:"profileId"`
|
||||
|
||||
// RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
// LastUpdateTime
|
||||
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
||||
|
||||
// CreatedTime
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// DeletedTime
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// VMID
|
||||
VMID uint64 `json:"vmid"`
|
||||
|
||||
// PGPuid
|
||||
PGPuid uint64 `json:"pgpuid"`
|
||||
|
||||
// ReferenceID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// AccountID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// RgID
|
||||
RgID uint64 `json:"rgId"`
|
||||
|
||||
// LastClaimedBy
|
||||
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
||||
|
||||
// PCISlot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
|
||||
// BusNumber
|
||||
BusNumber uint64 `json:"bus_number"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
}
|
||||
|
||||
// Information about libvirt settings
|
||||
type LibvirtSettings struct {
|
||||
// TX mode
|
||||
@@ -1038,6 +982,9 @@ type ItemVNFInterface struct {
|
||||
// QOS
|
||||
QOS QOS `json:"qos"`
|
||||
|
||||
// List of QoS Policy IDs
|
||||
QoSPolicies []uint64 `json:"qos_policies"`
|
||||
|
||||
// List of security groups
|
||||
SecGroups []uint64 `json:"security_groups"`
|
||||
|
||||
@@ -1551,6 +1498,9 @@ type ItemCompute struct {
|
||||
// VINS connected
|
||||
VINSConnected uint64 `json:"vinsConnected"`
|
||||
|
||||
// Watchdog action
|
||||
WatchdogAction string `json:"watchdog_action"`
|
||||
|
||||
// Weight
|
||||
Weight uint64 `json:"weight"`
|
||||
|
||||
@@ -1569,6 +1519,9 @@ type InfoDisk struct {
|
||||
// SEP ID
|
||||
SepID int64 `json:"sepId"`
|
||||
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// Read-only
|
||||
ReadOnly bool `json:"read_only"`
|
||||
}
|
||||
@@ -1593,59 +1546,56 @@ type ListVGPUs struct {
|
||||
|
||||
// Main information about vgpu device
|
||||
type ItemVGPU struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
// Account IDs
|
||||
AccountIDs []uint64 `json:"account_ids"`
|
||||
|
||||
// Created Time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
// Bus number
|
||||
BusNumber int `json:"bus_number"`
|
||||
|
||||
// Deleted Time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
// ComputeID
|
||||
ComputeID uint64 `json:"compute_id"`
|
||||
|
||||
// GID
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"created_time"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deleted_time"`
|
||||
|
||||
// Device Reference
|
||||
DeviceReference string `json:"device_reference"`
|
||||
|
||||
//Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
// VGPU ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Last Claimed By
|
||||
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
||||
// Last Update time
|
||||
LastUpdateTime uint64 `json:"last_update_time"`
|
||||
|
||||
// Last Update Time
|
||||
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
||||
// Mdev UUID
|
||||
MdevUUID string `json:"mdev_uuid"`
|
||||
|
||||
// Mode
|
||||
Mode string `json:"mode"`
|
||||
// Parent PCI Address
|
||||
ParentPCIAddress string `json:"parent_pci_address"`
|
||||
|
||||
// PCI Slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
PCISlot uint64 `json:"pci_slot"`
|
||||
|
||||
// PGPUID
|
||||
PGPUID uint64 `json:"pgpuid"`
|
||||
// PGPU ID
|
||||
PGPUID uint64 `json:"pgpu_id"`
|
||||
|
||||
// Profile ID
|
||||
ProfileID uint64 `json:"profileId"`
|
||||
// Profile Reference
|
||||
ProfileReference string `json:"profile_reference"`
|
||||
|
||||
// RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
// Reference ID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// RG ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
// Split Mode
|
||||
SplitMode string `json:"split_mode"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// VM ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
}
|
||||
|
||||
// Main information about PCI device
|
||||
@@ -1668,8 +1618,8 @@ type ItemPCIDevice struct {
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
// Account IDs
|
||||
AccountIDs []uint64 `json:"account_ids"`
|
||||
|
||||
// Node ID
|
||||
NodeID uint64 `json:"nodeId"`
|
||||
|
||||
@@ -86,6 +86,10 @@ type NetAttachRequest struct {
|
||||
// Required: false
|
||||
// Default: true
|
||||
EnableDefaultGateway interface{} `url:"enable_default_gateway,omitempty" json:"enable_default_gateway,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// List of QoS Policy IDs to apply to this interface (default: []), Allow used only with netType VINS, EXTNET and DPDK
|
||||
// Required: false
|
||||
QoSPolicies []uint64 `url:"qos_policies,omitempty" json:"qos_policies,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperNetAttachRequest struct {
|
||||
|
||||
@@ -74,6 +74,11 @@ type UpdateRequest struct {
|
||||
// Required: false
|
||||
// Default: null
|
||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
||||
|
||||
// Watchdog action
|
||||
// Required: false
|
||||
// Default: reset
|
||||
WatchdogAction string `url:"watchdog_action,omitempty" json:"watchdog_action,omitempty" validate:"omitempty,watchdogAction"`
|
||||
}
|
||||
|
||||
// Update updates some properties of the compute
|
||||
|
||||
Reference in New Issue
Block a user