parent
f1e0f7abb6
commit
80491ed643
@ -1,9 +1,131 @@
|
||||
## Version 1.8.3
|
||||
## Version 1.9.0
|
||||
|
||||
### Feature
|
||||
|
||||
#### account
|
||||
- Delete field RecursiveDelete in DeleteUserRequest in cloudapi/account and cloudbroker/account
|
||||
- Add field UniqPools in UpdateRequest in cloudapi/account
|
||||
- Add field ClearUniqPools in UpdateRequest in cloudbroker/account
|
||||
- Add field SortBy in listFlipGroups in cloudapi/account
|
||||
- Change Ratio field from required to optional in SetCPUAllocationRatioRequest in cloudbroker/compute
|
||||
|
||||
#### audit
|
||||
- Add endpoint Get in cloudapi/audit
|
||||
- Add endpoint ExportAuditsToFile in cloudbroker/audit
|
||||
- Delete field Apitask in model RecordAudit in cloudbroker/audit
|
||||
|
||||
#### compute
|
||||
- Add support DPDK network net type in NetAttach endpoints in cloudapi/compute and cloudbroker/compute
|
||||
- Add field Force in CloneRequest in cloudapi/compute and cloudbroker/compute
|
||||
- Change TargetStackID field from required to optional (add default 0 value) in PinToStackRequest in cloudbroker/compute
|
||||
- Change return value type from bool to string in SnapshotDelete in cloudbroker/compute and cloudapi/compute
|
||||
- Add field StatusCheck in MigrateStorageAbortRequest in cloudbroker/compute
|
||||
- Add function SnapshotDeleteAsync in cloudapi/compute and cloudbroker/compute
|
||||
- Add field StackID in ListRequest in cloudbroker/compute
|
||||
- Add field NodeID in model RecordCompute in cloudbroker/compute
|
||||
- Add function SetNetConfig in cloudbroker/compute
|
||||
- Add field MTU in model RecordNetAttach in cloudapi/compute and cloudbroker/compute
|
||||
- Change Mode field from required to optional in DiskMigrateRequest in cloudapi/compute
|
||||
- Add field Chipset in model RecordCompute in cloudapi/compute and cloudbroker/compute
|
||||
- Add field BusNumber in model RecordCompute, ItemComputeDisk, ItemDisk, InfoDisk in cloudapi/compute and cloudbroker/compute
|
||||
- Add field ImageID in ListRequest in cloudbroker/compute
|
||||
- Change Mode field from required to optional in DiskMigrateRequest in cloudbroker/compute
|
||||
- Add field Chipset in ListRequest in cloudbroker/compute
|
||||
- Add endpoints ChangeIP in cloudapi/compute and cloudbroker/compute
|
||||
|
||||
#### disks
|
||||
- Change drivers field from optional to required in FromPlatformDiskRequest in cloudapi/disks, cloudbroker/disks
|
||||
|
||||
#### dpdknet
|
||||
- Add endpoints List, Get in cloudapi/dpdk
|
||||
- Add endpoints Create, Delete, Disable Enable, Get, List, Update in cloudbroker/dpdk
|
||||
|
||||
#### extnet
|
||||
- Change StackId field from required to optional in DeviceMigrateRequest in cloudbroker/extnet
|
||||
|
||||
#### flipgroup
|
||||
- Change ClientIDs field from []uint64 to []string in ListRequest, cloudapi/flipgroup
|
||||
|
||||
#### grid
|
||||
- Change PasswordLength field from required to optional (add default 9 value) in SetPasswordPolicyRequest in cloudbroker/grid
|
||||
- Set Default value (true) in fields Digits and Uppercase in SetPasswordPolicyRequest in cloudbroker/grid
|
||||
- Add fields ckey, meta in model RecordGrid in cloudbroker/grid
|
||||
- Change GID field from uint64 to string in ExecuteMaintenanceScriptRequest in cloudbroker/grid
|
||||
- Add endpoints GetSettings and GetSettingsRaw in cloudbroker/grid
|
||||
|
||||
#### group
|
||||
- Change StackId field from uint64 to string in ListRequest in cloudbroker/group
|
||||
|
||||
#### image:
|
||||
- Change Drivers field from required to optional in CreateCDROMImageRequest in cloudbroker/image
|
||||
- Add field Enabled in ListRequest in cloudapi/image and cloudbroker/image
|
||||
- Delete field GID in SyncCreateRequest in cloudbroker/image
|
||||
- Delete field Permanently in DeleteRequest in cloudapi/image and cloudbroker/image
|
||||
- Delete field Permanently in DeleteImagesRequest in cloudbroker/image
|
||||
|
||||
#### k8s
|
||||
- Add fields HighlyAvailableLB, AddressVip, ExtnetOnly, WithLB in model RecordK8S in cloudbroker/k8s and cloudapi/k8s
|
||||
- Change MasterIds field from a slice of string to a slice of integers in DeleteMasterFromGroupRequest in cloudbroker/k8s and cloudapi/k8s
|
||||
- Add field Chipset in WorkerAddRequest, WorkersGroupAddRequest in cloudapi/k8s, cloudbroker/k8s
|
||||
- Add field Chipset in CreateRequest in cloudapi/k8s, cloudbroker/k8s
|
||||
|
||||
#### kvmx86
|
||||
- Add support DPDK network interface in Create endpoints in cloudapi/kvmx86 and cloudbroker/kvmx8
|
||||
- Add field Chipset in CreateRequest, CreateBlankRequest, MassCreateRequest, CreateBlankRequest in cloudapi/kvmx86 and cloudbroker/kvmx86
|
||||
- Add function MassCreateAsync in cloudbroker/kvmx86
|
||||
|
||||
#### lb
|
||||
- Change ExtNetID field from uint64 to int64 in CreateRequest, ItemLBList, RecordLB in cloudapi/lb, cloudbroker/lb
|
||||
- Change ExtNetID, VINSID fields from required to optional in CreateRequest in cloudapi/lb
|
||||
|
||||
#### node
|
||||
- Add field Force in EnableRequest in cloudbroker/node
|
||||
- Add function EnableAsync in cloudbroker/node
|
||||
|
||||
#### rg
|
||||
- Add endpoints removeDefNet in cloudapi/rg and cloudbroker/rg
|
||||
- Add field ClearUniqPools in UpdateRequest in cloudbroker/rg and cloudapi/rg
|
||||
- Add field UniqPools in UpdateRequest in cloudapi/rg
|
||||
- Delete field IPCIDR in CreateRequest in cloudbroker/rg
|
||||
|
||||
#### sep
|
||||
- Add endpoints SharedLockStart and SharedLockStop in cloudbroker/sep
|
||||
|
||||
#### user
|
||||
- Add field GUID in models ItemAudit in cloudapi/user and cloudbroker/user
|
||||
- Add fields MaxStatusCode and MinStatusCode in GetAuditRequest in cloudapi/user
|
||||
|
||||
#### vins
|
||||
- Add field Computes in model ListVINS in cloudbroker/vins
|
||||
- Add fields VNFDevId in ListRequest in cloudapi/vins and in ListDeletedRequest in cloudbroker/vins
|
||||
- Add field MTU, LibvirtSettings in model ItemInterface in cloudapi/vins and cloudbroker/vins
|
||||
- Add field BusNumber in model ItemInterface in cloudapi/vins and cloudbroker/vins
|
||||
|
||||
### Removed
|
||||
|
||||
#### common
|
||||
- The reason field has been deleted everywhere
|
||||
|
||||
#### accounts
|
||||
- The GetConsumption function was removed in cloudapi/account
|
||||
|
||||
#### grid
|
||||
- The CheckVMs function was removed in cloudbroker/grid
|
||||
- The CreateSystemSpace function was removed in cloudbroker/grid
|
||||
|
||||
#### image
|
||||
- The Permanently field has been removed from DeleteCDROMImageRequest in cloudbroker/image
|
||||
|
||||
#### kvmppc
|
||||
- The group has been completely deleted
|
||||
|
||||
#### sizes
|
||||
- The group has been completely deleted
|
||||
|
||||
#### user
|
||||
- The StatusCode field has been deleted from GetAuditRequest in cloudapi/user
|
||||
|
||||
### Bugfix
|
||||
|
||||
- Change validation conditions in field type in models IPReserveRequest (cloudapi/vins/ip_reserve and cloudbroker/vins/ip_reserve).
|
||||
- Fixed the return value in cloudbroker/sep/AddPool
|
||||
- Fixed the InfoDisk model in cloudbroker/disks/models
|
||||
- Change variable types in fields freeIPs in models ItemVINS (cloudapi/account/listVins, cloudbroker/account/listVins, cloudapi/rg/listVins, cloudbroker/rg/listVins, cloudapi/vins/list, cloudapi/vins/listDeleted, cloudbroker/vins/list, cloudbroker/vins/listdeleted)
|
||||
- Change variable types in fields freeIPs in models RecordExtNet (cloudapi/extnet/get, cloudbroker/extnet/get) and ItemExtNet(cloudbroker/extnet/list)
|
||||
#### backup
|
||||
- Fixed RestoreDisksFromBackupRequest in cloudbroker/backup
|
||||
|
@ -1,58 +0,0 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetConsumptionRequest struct to download the resources tracking files for an account
|
||||
type GetConsumptionRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Epoch represents the start time
|
||||
// Required: true
|
||||
Start float64 `url:"start" json:"start" validate:"required"`
|
||||
|
||||
// Epoch represents the end time
|
||||
// Required: true
|
||||
End float64 `url:"end" json:"end" validate:"required"`
|
||||
}
|
||||
|
||||
// GetConsumption downloads the resources tracking files for an account within a given period
|
||||
func (a Account) GetConsumption(ctx context.Context, req GetConsumptionRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/getConsumption"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
|
||||
}
|
||||
|
||||
// GetConsumptionGet downloads the resources tracking files for an account within a given period
|
||||
func (a Account) GetConsumptionGet(ctx context.Context, req GetConsumptionRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/getConsumption"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package cloudapi
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/audit"
|
||||
)
|
||||
|
||||
// Accessing the Stack method group
|
||||
func (ca *CloudAPI) Audit() *audit.Audit {
|
||||
return audit.New(ca.client)
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package audit
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to audit
|
||||
type Audit struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for audit endpoint
|
||||
func New(client interfaces.Caller) *Audit{
|
||||
return &Audit{
|
||||
client: client,
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about account
|
||||
type GetRequest struct {
|
||||
// Audit GUID
|
||||
// Required: true
|
||||
AuditGuid string `url:"auditGuid" json:"auditGuid" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets information about audit as a RecordAudit struct
|
||||
func (a Audit) Get(ctx context.Context, req GetRequest) (*RecordAudit, error) {
|
||||
res, err := a.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordAudit{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets information about audit as an array of bytes
|
||||
func (a Audit) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/audit/get"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package audit
|
||||
|
||||
// Main info about audit
|
||||
type RecordAudit struct {
|
||||
|
||||
// Arguments
|
||||
Arguments string `json:"args"`
|
||||
|
||||
// Call
|
||||
Call string `json:"call"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// Kwargs
|
||||
Kwargs string `json:"kwargs"`
|
||||
|
||||
// RemoteAddr
|
||||
RemoteAddr string `json:"remote_addr"`
|
||||
|
||||
// Response time
|
||||
ResponseTime float64 `json:"responsetime"`
|
||||
|
||||
// Result
|
||||
Result string `json:"result"`
|
||||
|
||||
// Status code
|
||||
StatusCode uint64 `json:"statuscode"`
|
||||
|
||||
// Tags
|
||||
Tags string `json:"tags"`
|
||||
|
||||
// Timestamp
|
||||
Timestamp float64 `json:"timestamp"`
|
||||
|
||||
// TimestampEnd
|
||||
TimestampEnd float64 `json:"timestampEnd"`
|
||||
|
||||
// User
|
||||
User string `json:"user"`
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ChangeIPRequest struct to change IP for network
|
||||
type ChangeIPRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Network type
|
||||
// 'EXTNET' for connect to external network directly
|
||||
// 'VINS' for connect to ViNS
|
||||
// Required: true
|
||||
NetType string `url:"netType" json:"netType" validate:"computeNetType"`
|
||||
|
||||
// Network ID for connect to
|
||||
// For EXTNET - external network ID
|
||||
// For VINS - VINS ID
|
||||
// Required: true
|
||||
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||
|
||||
// IP address to which we will change the existing one, it must be from the same subnet
|
||||
// Required: true
|
||||
IPAddr string `url:"ipAddr" json:"ipAddr" validate:"required"`
|
||||
}
|
||||
|
||||
// ChangeIP change reserved IP for compute instance
|
||||
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/changeIp"
|
||||
|
||||
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
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package cloudapi
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/dpdknet"
|
||||
|
||||
// Accessing the DPDKNet method group
|
||||
func (ca *CloudAPI) DPDKNet() *dpdknet.DPDKNet {
|
||||
return dpdknet.New(ca.client)
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package dpdknet
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to DPDK network
|
||||
type DPDKNet struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for dpdk endpoints
|
||||
func New(client interfaces.Caller) *DPDKNet {
|
||||
return &DPDKNet{
|
||||
client,
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package dpdknet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about DPDK network
|
||||
type GetRequest struct {
|
||||
// ID of the DPDK network
|
||||
// Required: true
|
||||
DPDKID uint64 `url:"dpdkId" json:"dpdkId" validate:"required"`
|
||||
}
|
||||
|
||||
// Get DPDK network details as a RecordDPDKNet struct
|
||||
func (d DPDKNet) Get(ctx context.Context, req GetRequest) (*RecordDPDKNet, error) {
|
||||
res, err := d.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordDPDKNet{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets DPDK network details as an array of bytes
|
||||
func (d DPDKNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/dpdknet/get"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package dpdknet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of DPDK networks
|
||||
type ListRequest struct {
|
||||
// Find by id
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
// Find by gid
|
||||
// Required: false
|
||||
GID uint64 `url:"gid,omitempty" json:"gid,omitempty"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by description
|
||||
// Required: false
|
||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by computeIDs
|
||||
// Required: false
|
||||
ComputeIDs []uint64 `url:"computeIds,omitempty" json:"computeIds,omitempty"`
|
||||
|
||||
// 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"`
|
||||
}
|
||||
|
||||
// List gets list of the created DPDK networks belonging to an account as a ListDPDKNet struct
|
||||
func (d DPDKNet) List(ctx context.Context, req ListRequest) (*ListDPDKNet, error) {
|
||||
|
||||
res, err := d.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListDPDKNet{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of the created DPDK networks belonging to an account as an array of bytes
|
||||
func (d DPDKNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/dpdknet/list"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package dpdknet
|
||||
|
||||
// Detailed information about DPDK network
|
||||
type RecordDPDKNet struct {
|
||||
// List of accounts with access
|
||||
AccountAccess []uint64 `json:"accountAccess"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// Guid ID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// List of resource groups with access
|
||||
RGAccess []uint64 `json:"rgAccess"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// OVS bridge
|
||||
OVSBridge string `json:"ovsBridge"`
|
||||
|
||||
// Vlan ID
|
||||
VlanID uint64 `json:"vlanId"`
|
||||
|
||||
// Compute IDs
|
||||
ComputeIDs []uint64 `json:"computeIds"`
|
||||
}
|
||||
|
||||
type ListDPDKNet struct {
|
||||
// Data
|
||||
Data []ItemDPDKNet `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
type ItemDPDKNet struct {
|
||||
// List of accounts with access
|
||||
AccountAccess []uint64 `json:"accountAccess"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// Description
|
||||
Description string `json:"description"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// Guid ID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// List of resource groups with access
|
||||
RGAccess []uint64 `json:"rgAccess"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// OVS bridge
|
||||
OVSBridge string `json:"ovsBridge"`
|
||||
|
||||
// Vlan ID
|
||||
VlanID uint64 `json:"vlanId"`
|
||||
|
||||
// Compute IDs
|
||||
ComputeIDs []uint64 `json:"computeIds"`
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package cloudapi
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/kvmppc"
|
||||
|
||||
// Accessing the KVMPPC method group
|
||||
func (ca *CloudAPI) KVMPPC() *kvmppc.KVMPPC {
|
||||
return kvmppc.New(ca.client)
|
||||
}
|
@ -1,202 +0,0 @@
|
||||
package kvmppc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type Interface struct {
|
||||
// Network type
|
||||
// Should be one of:
|
||||
// - VINS
|
||||
// - EXTNET
|
||||
NetType string `url:"netType" json:"netType" validate:"required,kvmNetType"`
|
||||
|
||||
// Network ID for connect to,
|
||||
// for EXTNET - external network ID,
|
||||
// for VINS - VINS ID,
|
||||
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||
|
||||
// IP address to assign to this VM when connecting to the specified network
|
||||
// Required: false
|
||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||
}
|
||||
|
||||
// DataDisk detailed struct for DataDisks field in CreateRequest and CreateBlankRequest
|
||||
type DataDisk struct {
|
||||
// Name for disk
|
||||
// Required: true
|
||||
DiskName string `url:"diskName" json:"diskName" validate:"required"`
|
||||
|
||||
// Disk size in GB
|
||||
// Required: true
|
||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// By default the same with boot disk
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool name
|
||||
// By default will be chosen automatically
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Optional description
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
// Specify image id for create disk from template
|
||||
// Required: false
|
||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||
}
|
||||
|
||||
// CreateRequest struct to create KVM PowerPC VM
|
||||
type CreateRequest struct {
|
||||
// ID of the resource group, which will own this VM
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Name of this VM.
|
||||
// Must be unique among all VMs (including those in DELETED state) in target resource group
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Number CPUs to allocate to this VM
|
||||
// Required: true
|
||||
CPU uint64 `url:"cpu" json:"cpu" validate:"required"`
|
||||
|
||||
// Volume of RAM in MB to allocate to this VM
|
||||
// Required: true
|
||||
RAM uint64 `url:"ram" json:"ram" validate:"required"`
|
||||
|
||||
// ID of the OS image to base this VM on;
|
||||
// Could be boot disk image or CD-ROM image
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// Size of the boot disk in GB
|
||||
// Required: false
|
||||
BootDisk uint64 `url:"bootDisk,omitempty" json:"bootDisk,omitempty"`
|
||||
|
||||
// ID of SEP to create boot disk on.
|
||||
// Uses images SEP ID if not set
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool to use if sepId is set, can be also empty if needed to be chosen by system
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
// To create compute without disks, pass initialized empty slice .
|
||||
// Required: false
|
||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Slice of structs with net interface description.
|
||||
// If not specified, compute will be created with default interface from RG.
|
||||
// To create compute without interfaces, pass initialized empty slice .
|
||||
// Required: false
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Input data for cloud-init facility
|
||||
// Required: false
|
||||
Userdata string `url:"userdata,omitempty" json:"userdata,omitempty"`
|
||||
|
||||
// Text description of this VM
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
// Start VM upon success
|
||||
// Required: false
|
||||
Start bool `url:"start" json:"start"`
|
||||
|
||||
// System name
|
||||
// Required: false
|
||||
IS string `url:"IS,omitempty" json:"IS,omitempty"`
|
||||
|
||||
// Compute purpose
|
||||
// Required: false
|
||||
IPAType string `url:"ipaType,omitempty" json:"ipaType,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates KVM PowerPC VM based on specified OS image
|
||||
func (k KVMPPC) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
CreateRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudapi/kvmppc/create"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
package kvmppc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// CreateBlankRequest struct to create KVM PowerPC VM from scratch
|
||||
type CreateBlankRequest struct {
|
||||
// ID of the resource group, which will own this VM
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Name of this VM.
|
||||
// Must be unique among all VMs (including those in DELETED state) in target resource group
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Number CPUs to allocate to this VM
|
||||
// Required: true
|
||||
CPU uint64 `url:"cpu" json:"cpu" validate:"required"`
|
||||
|
||||
// Volume of RAM in MB to allocate to this VM
|
||||
// Required: true
|
||||
RAM uint64 `url:"ram" json:"ram" validate:"required"`
|
||||
|
||||
// Size of the boot disk in GB
|
||||
// Required: true
|
||||
BootDisk uint64 `url:"bootDisk" json:"bootDisk" validate:"required"`
|
||||
|
||||
// ID of SEP to create boot disk on
|
||||
// Uses images SEP ID if not set
|
||||
// Required: true
|
||||
SEPID uint64 `url:"sepId" json:"sepId" validate:"required"`
|
||||
|
||||
// Pool to use if SEP ID is set, can be also empty if needed to be chosen by system
|
||||
// Required: true
|
||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
// To create compute without disks, pass initialized empty slice .
|
||||
// Required: false
|
||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Slice of structs with net interface description.
|
||||
// If not specified, compute will be created with default interface from RG.
|
||||
// To create compute without interfaces, pass initialized empty slice .
|
||||
// Required: false
|
||||
Interfaces []Interface `url:"-" json:"interfaces,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Text description of this VM
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r CreateBlankRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateBlankRequest struct {
|
||||
CreateBlankRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// CreateBlank creates KVM PowerPC VM from scratch
|
||||
func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var interfaces []string
|
||||
|
||||
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
||||
interfaces = make([]string, 0, len(req.Interfaces))
|
||||
|
||||
for i := range req.Interfaces {
|
||||
b, err := json.Marshal(req.Interfaces[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
interfaces = append(interfaces, string(b))
|
||||
}
|
||||
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateBlankRequest{
|
||||
CreateBlankRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudapi/kvmppc/createBlank"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
// API to manage KVM PowerPC compute instances (PPC VMs)
|
||||
package kvmppc
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to KVMPPC
|
||||
type KVMPPC struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for KVMPPC endpoints
|
||||
func New(client interfaces.Caller) *KVMPPC {
|
||||
return &KVMPPC{
|
||||
client,
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package rg
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RemoveDefNetRequest struct to remove default network
|
||||
type RemoveDefNetRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
}
|
||||
|
||||
// RemoveDefNet removes default network from resource group
|
||||
func (r RG) RemoveDefNet(ctx context.Context, req RemoveDefNetRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/rg/removeDefNet"
|
||||
|
||||
res, err := r.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
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package cloudapi
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/sizes"
|
||||
)
|
||||
|
||||
// Accessing the Sizes method group
|
||||
func (ca *CloudAPI) Sizes() *sizes.Sizes {
|
||||
return sizes.New(ca.client)
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package sizes
|
||||
|
||||
// FilterByID returns ListSizes with specified ID.
|
||||
func (ls ListSizes) FilterByID(id uint64) ListSizes {
|
||||
predicate := func(is ItemSize) bool {
|
||||
return is.ID == id
|
||||
}
|
||||
|
||||
return ls.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns ListSizes with specified Name.
|
||||
func (ls ListSizes) FilterByName(name string) ListSizes {
|
||||
predicate := func(is ItemSize) bool {
|
||||
return is.Name == name
|
||||
}
|
||||
|
||||
return ls.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListSizes based on a user-specified predicate.
|
||||
func (ls ListSizes) FilterFunc(predicate func(ItemSize) bool) ListSizes {
|
||||
var result ListSizes
|
||||
|
||||
for _, item := range ls.Data {
|
||||
if predicate(item) {
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(result.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemSize
|
||||
// If none was found, returns an empty struct.
|
||||
func (ls ListSizes) FindOne() ItemSize {
|
||||
if len(ls.Data) == 0 {
|
||||
return ItemSize{}
|
||||
}
|
||||
|
||||
return ls.Data[0]
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package sizes
|
||||
|
||||
import "testing"
|
||||
|
||||
var sizeItems = ListSizes{
|
||||
Data: []ItemSize{
|
||||
{
|
||||
Description: "",
|
||||
Disks: []uint64{},
|
||||
ID: 1,
|
||||
Memory: 512,
|
||||
Name: "size_1",
|
||||
VCPUs: 2,
|
||||
},
|
||||
{
|
||||
Description: "",
|
||||
Disks: []uint64{},
|
||||
ID: 2,
|
||||
Memory: 1024,
|
||||
Name: "size_2",
|
||||
VCPUs: 4,
|
||||
},
|
||||
{
|
||||
Description: "",
|
||||
Disks: []uint64{},
|
||||
ID: 2,
|
||||
Memory: 2048,
|
||||
Name: "size_3",
|
||||
VCPUs: 6,
|
||||
},
|
||||
},
|
||||
EntryCount: 3,
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := sizeItems.FilterByID(1).FindOne()
|
||||
|
||||
if actual.ID != 1 {
|
||||
t.Fatal("expected ID 1, found: ", actual.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByName(t *testing.T) {
|
||||
actual := sizeItems.FilterByName("size_2").FindOne()
|
||||
|
||||
if actual.Name != "size_2" {
|
||||
t.Fatal("expected Name 'size_2', found: ", actual.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := sizeItems.FilterFunc(func(is ItemSize) bool {
|
||||
return is.Memory > 512
|
||||
})
|
||||
|
||||
if len(actual.Data) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||
}
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if item.Memory <= 512 {
|
||||
t.Fatal("expected Memory greater than 512, found: ", item.Memory)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package sizes
|
||||
|
||||
// IDs gets array of configured available flavours IDs from ListSizes struct
|
||||
func (ls ListSizes) IDs() []uint64 {
|
||||
res := make([]uint64, 0, len(ls.Data))
|
||||
for _, s := range ls.Data {
|
||||
res = append(res, s.ID)
|
||||
}
|
||||
return res
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package sizes
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct for list of the available flavors
|
||||
type ListRequest struct {
|
||||
// ID of the cloudspace
|
||||
// Required: false
|
||||
CloudspaceID uint64 `url:"cloudspaceId,omitempty" json:"cloudspaceId,omitempty"`
|
||||
|
||||
// Location code for the sizes
|
||||
// Required: false
|
||||
Location string `url:"location,omitempty" json:"location,omitempty"`
|
||||
|
||||
// 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"`
|
||||
}
|
||||
|
||||
// List gets list of the available flavors as a ListSizes struct, filtering can be based on the user which is doing the request
|
||||
func (s Sizes) List(ctx context.Context, req ListRequest) (*ListSizes, error) {
|
||||
|
||||
res, err := s.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := &ListSizes{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of the available flavors as an array of bytes
|
||||
func (s Sizes) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/sizes/list"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package sizes
|
||||
|
||||
// Main onformation about configured available flavors
|
||||
type ItemSize struct {
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// List of disk IDs
|
||||
Disks []uint64 `json:"disks"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Memory
|
||||
Memory uint64 `json:"memory"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// VCPUs
|
||||
VCPUs uint64 `json:"vcpus"`
|
||||
}
|
||||
|
||||
// List of configured available flavors
|
||||
type ListSizes struct {
|
||||
// Data
|
||||
Data []ItemSize `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package sizes
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (ls ListSizes) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(ls.Data) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(ls, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(ls)
|
||||
}
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (is ItemSize) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(is, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(is)
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
// Lists all the configured flavors available.
|
||||
// A flavor is a combination of amount of compute capacity(CU) and disk capacity(GB).
|
||||
package sizes
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creatig request to sizes
|
||||
type Sizes struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for sizes endpoints
|
||||
func New(client interfaces.Caller) *Sizes {
|
||||
return &Sizes{
|
||||
client,
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// ExportAuditsToFile Get audits in csv file, return []byte which should be written to a file *tar.gz
|
||||
func (a Audit) ExportAuditsToFile(ctx context.Context) ([]byte, error) {
|
||||
url := "/cloudbroker/audit/exportAuditsToFile"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ChangeIPRequest struct to change IP for network
|
||||
type ChangeIPRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Network type
|
||||
// 'EXTNET' for connect to external network directly
|
||||
// 'VINS' for connect to ViNS
|
||||
// Required: true
|
||||
NetType string `url:"netType" json:"netType" validate:"computeNetType"`
|
||||
|
||||
// Network ID for connect to
|
||||
// For EXTNET - external network ID
|
||||
// For VINS - VINS ID
|
||||
// Required: true
|
||||
NetID uint64 `url:"netId" json:"netId" validate:"required"`
|
||||
|
||||
// IP address to which we will change the existing one, it must be from the same subnet
|
||||
// Required: true
|
||||
IPAddr string `url:"ipAddr" json:"ipAddr" validate:"required"`
|
||||
}
|
||||
|
||||
// ChangeIP change reserved IP for compute instance
|
||||
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/changeIp"
|
||||
|
||||
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
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue