v1.16.4
v1.16.4
This commit is contained in:
@@ -2,8 +2,8 @@ package apiaccess
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
@@ -20,23 +20,25 @@ type DescUpdateRequest struct {
|
||||
}
|
||||
|
||||
// DescUpdate sets a new text description of the apiaccess group.
|
||||
func (a APIAccess) DescUpdate(ctx context.Context, req DescUpdateRequest) (bool, error) {
|
||||
func (a APIAccess) DescUpdate(ctx context.Context, req DescUpdateRequest) (*ItemAPIAccess, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/descUpdate"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
info := ItemAPIAccess{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package apiaccess
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type ItemAPIAccess struct {
|
||||
// APIs
|
||||
APIs APIsEndpoints `json:"apis"`
|
||||
@@ -88,43 +90,74 @@ type APIsEndpoints struct {
|
||||
// CloudBroker endpoints
|
||||
CloudBroker CloudBrokerEndpoints `json:"cloudbroker,omitempty"`
|
||||
|
||||
// LibCloud endpoints
|
||||
LibCloud LibCloudEndpoints `json:"libcloud,omitempty"`
|
||||
// SDN endpoints
|
||||
SDN SDNEndpoints `json:"sdn,omitempty"`
|
||||
|
||||
// System endpoints
|
||||
System SystemEndpoints `json:"system,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON omits empty namespaces, so that "{}" is not sent in requests.
|
||||
func (a APIsEndpoints) MarshalJSON() ([]byte, error) {
|
||||
namespaces := []struct {
|
||||
key string
|
||||
value interface{}
|
||||
}{
|
||||
{"cloudapi", a.CloudAPI},
|
||||
{"cloudbroker", a.CloudBroker},
|
||||
{"sdn", a.SDN},
|
||||
{"system", a.System},
|
||||
}
|
||||
|
||||
result := make(map[string]json.RawMessage, len(namespaces))
|
||||
|
||||
for _, ns := range namespaces {
|
||||
data, err := json.Marshal(ns.value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if string(data) == "{}" {
|
||||
continue
|
||||
}
|
||||
|
||||
result[ns.key] = data
|
||||
}
|
||||
|
||||
return json.Marshal(result)
|
||||
}
|
||||
|
||||
type CloudAPIEndpoints struct {
|
||||
Account []string `json:"account,omitempty"`
|
||||
BService []string `json:"bservice,omitempty"`
|
||||
CloudSpace []string `json:"cloudspace,omitempty"`
|
||||
Compute []string `json:"compute,omitempty"`
|
||||
ComputeCI []string `json:"computeci,omitempty"`
|
||||
Disks []string `json:"disks,omitempty"`
|
||||
DPDK []string `json:"dpdk,omitempty"`
|
||||
ExtNet []string `json:"extnet,omitempty"`
|
||||
FLIPGroup []string `json:"flipgroup,omitempty"`
|
||||
GPU []string `json:"gpu,omitempty"`
|
||||
Image []string `json:"image,omitempty"`
|
||||
K8CI []string `json:"k8ci,omitempty"`
|
||||
K8S []string `json:"k8s,omitempty"`
|
||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||
LB []string `json:"lb,omitempty"`
|
||||
Loactions []string `json:"locations,omitempty"`
|
||||
Machine []string `json:"machine,omitempty"`
|
||||
Openshift []string `json:"openshift,omitempty"`
|
||||
OpenshiftCI []string `json:"openshiftci,omitempty"`
|
||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||
PortForwarding []string `json:"portforwarding,omitempty"`
|
||||
Prometheus []string `json:"prometheus,omitempty"`
|
||||
RG []string `json:"rg,omitempty"`
|
||||
Sizes []string `json:"sizes,omitempty"`
|
||||
Tasks []string `json:"tasks,omitempty"`
|
||||
User []string `json:"user,omitempty"`
|
||||
VGPU []string `json:"vgpu,omitempty"`
|
||||
VINS []string `json:"vins,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
Account []string `json:"account,omitempty"`
|
||||
Audit []string `json:"audit,omitempty"`
|
||||
BService []string `json:"bservice,omitempty"`
|
||||
Compute []string `json:"compute,omitempty"`
|
||||
Disks []string `json:"disks,omitempty"`
|
||||
DPDKNet []string `json:"dpdknet,omitempty"`
|
||||
ExtNet []string `json:"extnet,omitempty"`
|
||||
FLIPGroup []string `json:"flipgroup,omitempty"`
|
||||
GPU []string `json:"gpu,omitempty"`
|
||||
Image []string `json:"image,omitempty"`
|
||||
K8CI []string `json:"k8ci,omitempty"`
|
||||
K8S []string `json:"k8s,omitempty"`
|
||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||
LB []string `json:"lb,omitempty"`
|
||||
Loactions []string `json:"locations,omitempty"`
|
||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||
Prometheus []string `json:"prometheus,omitempty"`
|
||||
RG []string `json:"rg,omitempty"`
|
||||
SecurityGroup []string `json:"security_group,omitempty"`
|
||||
SEP []string `json:"sep,omitempty"`
|
||||
StoragePolicy []string `json:"storage_policy,omitempty"`
|
||||
Tasks []string `json:"tasks,omitempty"`
|
||||
Trunk []string `json:"trunk,omitempty"`
|
||||
User []string `json:"user,omitempty"`
|
||||
VFPool []string `json:"vfpool,omitempty"`
|
||||
VGPU []string `json:"vgpu,omitempty"`
|
||||
VINS []string `json:"vins,omitempty"`
|
||||
VMFolder []string `json:"vmfolder,omitempty"`
|
||||
Zone []string `json:"zone,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
type CloudBrokerEndpoints struct {
|
||||
@@ -133,74 +166,85 @@ type CloudBrokerEndpoints struct {
|
||||
Audit interface{} `json:"audit,omitempty"`
|
||||
AuditBeat []string `json:"auditbeat,omitempty"`
|
||||
AuditCollector []string `json:"auditcollector,omitempty"`
|
||||
Backup []string `json:"backup,omitempty"`
|
||||
BackupCreator []string `json:"backupcreator,omitempty"`
|
||||
BService []string `json:"bservice,omitempty"`
|
||||
CloudSpace []string `json:"cloudspace,omitempty"`
|
||||
Compute []string `json:"compute,omitempty"`
|
||||
ComputeCI []string `json:"computeci,omitempty"`
|
||||
Desnode []string `json:"desnode,omitempty"`
|
||||
Diagnostics []string `json:"diagnostics,omitempty"`
|
||||
Disks []string `json:"disks,omitempty"`
|
||||
DPDK []string `json:"dpdk,omitempty"`
|
||||
DPDKNet []string `json:"dpdknet,omitempty"`
|
||||
Eco []string `json:"eco,omitempty"`
|
||||
ExtNet []string `json:"extnet,omitempty"`
|
||||
FlIPgroup []string `json:"flipgroup,omitempty"`
|
||||
Grid []string `json:"grid,omitempty"`
|
||||
Group []string `json:"group,omitempty"`
|
||||
Health []string `json:"health,omitempty"`
|
||||
IaaS []string `json:"iaas,omitempty"`
|
||||
Image []string `json:"image,omitempty"`
|
||||
Job interface{} `json:"job,omitempty"`
|
||||
K8CI []string `json:"k8ci,omitempty"`
|
||||
K8S []string `json:"k8s,omitempty"`
|
||||
KVMX86 []string `json:"kvmx86,omitempty"`
|
||||
LB []string `json:"lb,omitempty"`
|
||||
Machine []string `json:"machine,omitempty"`
|
||||
Metering []string `json:"metering,omitempty"`
|
||||
Milestones []string `json:"milestones,omitempty"`
|
||||
Openshift []string `json:"openshift,omitempty"`
|
||||
OpenshiftCI []string `json:"openshiftci,omitempty"`
|
||||
Ovsnode []string `json:"ovsnode,omitempty"`
|
||||
Node []string `json:"node,omitempty"`
|
||||
PCIDevice []string `json:"pcidevice,omitempty"`
|
||||
PGPU []string `json:"pgpu,omitempty"`
|
||||
Prometheus []string `json:"prometheus,omitempty"`
|
||||
QOS []string `json:"qos,omitempty"`
|
||||
Resmon interface{} `json:"resmon,omitempty"`
|
||||
RG []string `json:"rg,omitempty"`
|
||||
SecurityGroup []string `json:"security_group,omitempty"`
|
||||
Sep []string `json:"sep,omitempty"`
|
||||
Node []string `json:"node,omitempty"`
|
||||
StoragePolicy []string `json:"storage_policy,omitempty"`
|
||||
Tasks []string `json:"tasks,omitempty"`
|
||||
TLock []string `json:"tlock,omitempty"`
|
||||
Trunk []string `json:"trunk,omitempty"`
|
||||
User []string `json:"user,omitempty"`
|
||||
VFPool []string `json:"vfpool,omitempty"`
|
||||
VGPU []string `json:"vgpu,omitempty"`
|
||||
VINS []string `json:"vins,omitempty"`
|
||||
VMFolder []string `json:"vmfolder,omitempty"`
|
||||
VNFDev []string `json:"vnfdev,omitempty"`
|
||||
ZeroAccess []string `json:"zeroaccess,omitempty"`
|
||||
Zone []string `json:"zone,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
type LibCloudEndpoints struct {
|
||||
Libvirt []string `json:"libvirt,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
type SDNEndpoints struct {
|
||||
AccessGroup []string `json:"access_group,omitempty"`
|
||||
AddressPool []string `json:"address_pool,omitempty"`
|
||||
DefaultSecurityPolicy []string `json:"default_security_policy,omitempty"`
|
||||
ExternalNetwork []string `json:"external_network,omitempty"`
|
||||
FloatingIP []string `json:"floating_ip,omitempty"`
|
||||
Hypervisor []string `json:"hypervisor,omitempty"`
|
||||
L2ExternalNetwork []string `json:"l2_external_network,omitempty"`
|
||||
LogicalPort []string `json:"logical_port,omitempty"`
|
||||
NetworkObjectGroup []string `json:"network_object_group,omitempty"`
|
||||
Router []string `json:"router,omitempty"`
|
||||
RouterGatewayPort []string `json:"router/gateway_port,omitempty"`
|
||||
RouterPolicies []string `json:"router/policies,omitempty"`
|
||||
RouterRouterPort []string `json:"router/router_port,omitempty"`
|
||||
RouterStaticRoute []string `json:"router/static_route,omitempty"`
|
||||
SecurityPolicy []string `json:"security_policy,omitempty"`
|
||||
SecurityPolicyRule []string `json:"security_policy/rule,omitempty"`
|
||||
SecurityRule []string `json:"security_rule,omitempty"`
|
||||
Segment []string `json:"segment,omitempty"`
|
||||
Version []string `json:"version,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
type SystemEndpoints struct {
|
||||
AgentController []string `json:"agentcontroller,omitempty"`
|
||||
Alerts []string `json:"alerts,omitempty"`
|
||||
Audits []string `json:"audits,omitempty"`
|
||||
ContentManager []string `json:"contentmanager,omitempty"`
|
||||
DocGenerator []string `json:"docgenerator,omitempty"`
|
||||
EmailSender []string `json:"emailsender,omitempty"`
|
||||
ErrorConditionHandler []string `json:"errorconditionhandler,omitempty"`
|
||||
GridManager []string `json:"gridmanager,omitempty"`
|
||||
Health []string `json:"health,omitempty"`
|
||||
Info []string `json:"info,omitempty"`
|
||||
InfoMGR []string `json:"infomgr,omitempty"`
|
||||
Job []string `json:"job,omitempty"`
|
||||
Log []string `json:"log,omitempty"`
|
||||
Logo []string `json:"logo,omitempty"`
|
||||
Oauth []string `json:"oauth,omitempty"`
|
||||
Task []string `json:"task,omitempty"`
|
||||
UserManager []string `json:"usermanager,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
Audits []string `json:"audits,omitempty"`
|
||||
Cache []string `json:"cache,omitempty"`
|
||||
ContentManager []string `json:"contentmanager,omitempty"`
|
||||
DocGenerator []string `json:"docgenerator,omitempty"`
|
||||
EmailSender []string `json:"emailsender,omitempty"`
|
||||
GridManager []string `json:"gridmanager,omitempty"`
|
||||
Health []string `json:"health,omitempty"`
|
||||
Info []string `json:"info,omitempty"`
|
||||
InfoWellknown []string `json:"info/wellknown,omitempty"`
|
||||
InfoMGR []string `json:"infomgr,omitempty"`
|
||||
Oauth []string `json:"oauth,omitempty"`
|
||||
Task []string `json:"task,omitempty"`
|
||||
UserManager []string `json:"usermanager,omitempty"`
|
||||
All bool `json:"ALL,omitempty"`
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
@@ -27,10 +26,10 @@ type wrapperUpdateRequest struct {
|
||||
}
|
||||
|
||||
// Update updates apis of apiaccess group.
|
||||
func (a APIAccess) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
func (a APIAccess) Update(ctx context.Context, req UpdateRequest) (*ItemAPIAccess, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/update"
|
||||
@@ -41,20 +40,22 @@ func (a APIAccess) Update(ctx context.Context, req UpdateRequest) (bool, error)
|
||||
|
||||
apiJSON, err := json.Marshal(&req.APIs)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
reqWrapped.APIString = string(apiJSON)
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
info := ItemAPIAccess{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ type CreateDiskBackupRequest struct {
|
||||
type wrapperCreateDiskBackupRequest struct {
|
||||
CreateDiskBackupRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// CreateDiskBackup creates disk backup
|
||||
|
||||
@@ -33,7 +33,7 @@ type CreateDisksBackupRequest struct {
|
||||
type wrapperCreateDisksBackupRequest struct {
|
||||
CreateDisksBackupRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// CreateDisksBackup creates disks backup
|
||||
|
||||
@@ -21,7 +21,7 @@ type DeleteDiskBackupRequest struct {
|
||||
type wrapperDeleteDiskBackupRequest struct {
|
||||
DeleteDiskBackupRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// DeleteDiskBackup deletes disk backup
|
||||
|
||||
@@ -30,7 +30,7 @@ type RestoreDiskFromBackupRequest struct {
|
||||
type wrapperRestoreDiskFromBackupRequest struct {
|
||||
RestoreDiskFromBackupRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// RestoreDiskFromBackup restores disk from backup
|
||||
|
||||
@@ -35,7 +35,7 @@ type RestoreDisksFromBackupRequest struct {
|
||||
type wrapperRestoreDisksFromBackupRequest struct {
|
||||
RestoreDisksFromBackupRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// RestoreDisksFromBackup restores disks from backup
|
||||
|
||||
@@ -20,7 +20,7 @@ type AbortSharedSnapshotMergeRequest struct {
|
||||
|
||||
type wrapperAbortSharedSnapshotMergeRequest struct {
|
||||
AbortSharedSnapshotMergeRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// AbortSharedSnapshotMerge shared snapshots merge abort
|
||||
|
||||
@@ -2,6 +2,7 @@ package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -42,6 +43,17 @@ type AffinityRuleAddRequest struct {
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
|
||||
// Migrate compute according to the rule
|
||||
// Default: false
|
||||
// Required: false
|
||||
Migrate bool `url:"migrate" json:"migrate"`
|
||||
}
|
||||
|
||||
type wrapperAffinityRuleAddRequest struct {
|
||||
AffinityRuleAddRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// AffinityRuleAdd adds affinity rule
|
||||
@@ -53,7 +65,12 @@ func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest
|
||||
|
||||
url := "/cloudbroker/compute/affinityRuleAdd"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
aReq := wrapperAffinityRuleAddRequest{
|
||||
AffinityRuleAddRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -65,3 +82,32 @@ func (c Compute) AffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AsyncAffinityRuleAdd add affinity rule in async mode
|
||||
func (c Compute) AsyncAffinityRuleAdd(ctx context.Context, req AffinityRuleAddRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/affinityRuleAdd"
|
||||
|
||||
aReq := wrapperAffinityRuleAddRequest{
|
||||
AffinityRuleAddRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(res, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -40,6 +41,17 @@ type AntiAffinityRuleAddRequest struct {
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: true
|
||||
Value string `url:"value" json:"value" validate:"required"`
|
||||
|
||||
// Migrate compute according to the rule
|
||||
// Default: false
|
||||
// Required: false
|
||||
Migrate bool `url:"migrate" json:"migrate"`
|
||||
}
|
||||
|
||||
type wrapperAntiAffinityRuleAddRequest struct {
|
||||
AntiAffinityRuleAddRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// AntiAffinityRuleAdd adds anti affinity rule
|
||||
@@ -51,7 +63,12 @@ func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAd
|
||||
|
||||
url := "/cloudbroker/compute/antiAffinityRuleAdd"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
aReq := wrapperAntiAffinityRuleAddRequest{
|
||||
AntiAffinityRuleAddRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -63,3 +80,32 @@ func (c Compute) AntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAd
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AsyncAntiAffinityRuleAdd add anti affinity rule in async mode
|
||||
func (c Compute) AsyncAntiAffinityRuleAdd(ctx context.Context, req AntiAffinityRuleAddRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/antiAffinityRuleAdd"
|
||||
|
||||
aReq := wrapperAntiAffinityRuleAddRequest{
|
||||
AntiAffinityRuleAddRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(res, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ type CDEjectRequest struct {
|
||||
type wrapperCDEjectRequest struct {
|
||||
CDEjectRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// CDEject ejects CD image to compute's CD-ROM
|
||||
|
||||
@@ -21,7 +21,7 @@ type CDInsertRequest struct {
|
||||
type wrapperCDInsertRequest struct {
|
||||
CDInsertRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// CDInsert inserts new CD image to compute's CD-ROM
|
||||
|
||||
@@ -34,7 +34,7 @@ type ChangeIPRequest struct {
|
||||
type wrapperChangeIPRequest struct {
|
||||
ChangeIPRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// ChangeIP change reserved IP for compute instance
|
||||
|
||||
@@ -27,7 +27,7 @@ type ChangeLinkStateRequest struct {
|
||||
type wrapperChangeLinkStateRequest struct {
|
||||
ChangeLinkStateRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// ChangeLinkState changes the status link virtual of compute
|
||||
|
||||
@@ -26,7 +26,7 @@ type ChangeMTURequest struct {
|
||||
type wrapperChangeMTURequest struct {
|
||||
ChangeMTURequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// ChangeMTU change MTU for compute instance
|
||||
|
||||
@@ -26,7 +26,7 @@ type ChangeQoSPoliciesRequest struct {
|
||||
type wrapperChangeQoSPoliciesRequest struct {
|
||||
ChangeQoSPoliciesRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// ChangeQoSPolicies change qos policies for compute
|
||||
|
||||
@@ -30,7 +30,7 @@ type ChangeSecGroupsRequest struct {
|
||||
type wrapperChangeSecGroupsRequest struct {
|
||||
ChangeSecGroupsRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// ChangeSecGroups changes security groups for compute
|
||||
|
||||
@@ -47,7 +47,7 @@ type CloneRequest struct {
|
||||
type wrapperCloneRequest struct {
|
||||
CloneRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Clone clones compute instance
|
||||
|
||||
@@ -22,7 +22,7 @@ type CreateTemplateRequest struct {
|
||||
type wrapperCreateTemplateRequest struct {
|
||||
CreateTemplateRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// CreateTemplate create template from compute instance
|
||||
|
||||
@@ -55,7 +55,7 @@ type CreateTemplateFromBlankRequest struct {
|
||||
|
||||
type wrapperCreateTemplateFromBlankRequest struct {
|
||||
CreateTemplateFromBlankRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// CreateTemplateFromBlank creates template from boot disk of current compute in sync mode.
|
||||
|
||||
@@ -26,7 +26,7 @@ type DeleteRequest struct {
|
||||
type wrapperDeleteRequest struct {
|
||||
DeleteRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Delete deletes compute
|
||||
|
||||
@@ -18,7 +18,7 @@ type DisableRequest struct {
|
||||
type wrapperDisableRequest struct {
|
||||
DisableRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Disable disables compute
|
||||
|
||||
@@ -68,7 +68,7 @@ type DiskAddRequest struct {
|
||||
type wrapperDiskAddRequest struct {
|
||||
DiskAddRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// DiskAdd creates new disk and attach to compute
|
||||
|
||||
@@ -34,7 +34,7 @@ type DiskAttachRequest struct {
|
||||
type wrapperDiskAttachRequest struct {
|
||||
DiskAttachRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// DiskAttach attach disk to compute
|
||||
|
||||
@@ -26,7 +26,7 @@ type DiskDelRequest struct {
|
||||
type wrapperDiskDelRequest struct {
|
||||
DiskDelRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// DiskDel deletes disk and detaches it from compute
|
||||
|
||||
@@ -22,7 +22,7 @@ type DiskDetachRequest struct {
|
||||
type wrapperDiskDetachRequest struct {
|
||||
DiskDetachRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// DiskDetach detaches disk from compute
|
||||
|
||||
@@ -26,7 +26,7 @@ type DiskQOSRequest struct {
|
||||
type wrapperDiskQOSRequest struct {
|
||||
DiskQOSRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// DiskQOS changes QOS of the disk
|
||||
|
||||
@@ -26,7 +26,7 @@ type DiskResizeRequest struct {
|
||||
type wrapperDiskResizeRequest struct {
|
||||
DiskResizeRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// DiskResize changes disk size
|
||||
|
||||
@@ -26,7 +26,7 @@ type DiskSwitchToReplicationRequest struct {
|
||||
type wrapperDiskSwitchToReplicationRequest struct {
|
||||
DiskSwitchToReplicationRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// DiskSwitchToReplication switches disk to it's replication
|
||||
|
||||
@@ -18,7 +18,7 @@ type GuestAgentDisableRequest struct {
|
||||
type wrapperGuestAgentDisableRequest struct {
|
||||
GuestAgentDisableRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Disable guest agent at a specific compute
|
||||
|
||||
@@ -18,7 +18,7 @@ type GuestAgentEnableRequest struct {
|
||||
type wrapperGuestAgentEnableRequest struct {
|
||||
GuestAgentEnableRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Enable guest agent at a specific compute
|
||||
|
||||
@@ -26,7 +26,7 @@ type GuestAgentExecuteRequest struct {
|
||||
type wrapperGuestAgentExecuteRequest struct {
|
||||
GuestAgentExecuteRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Execute guest agent command
|
||||
|
||||
@@ -18,7 +18,7 @@ type GuestAgentFeatureUpdateRequest struct {
|
||||
type wrapperGuestAgentFeatureUpdateRequest struct {
|
||||
GuestAgentFeatureUpdateRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Feature update guest agent
|
||||
|
||||
@@ -75,6 +75,14 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
|
||||
|
||||
// Find by VM folder ID
|
||||
// Required: false
|
||||
FolderID uint64 `url:"folder_id,omitempty" json:"folder_id,omitempty"`
|
||||
|
||||
// Include computes from descendant folders.
|
||||
// Required: false
|
||||
IncludeDescendants interface{} `url:"include_descendants,omitempty" json:"include_descendants,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
@@ -22,7 +22,7 @@ type MassDeleteRequest struct {
|
||||
type wrapperMassDeleteRequest struct {
|
||||
MassDeleteRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// MassDelete starts jobs to delete several computes
|
||||
|
||||
@@ -18,7 +18,7 @@ type MassRebootRequest struct {
|
||||
type wrapperMassRebootRequest struct {
|
||||
MassRebootRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// MassReboot starts jobs to reboot several computes
|
||||
|
||||
@@ -18,7 +18,7 @@ type MassStartRequest struct {
|
||||
type wrapperMassStartRequest struct {
|
||||
MassStartRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// MassStart starts jobs to start several computes
|
||||
|
||||
@@ -22,7 +22,7 @@ type MassStopRequest struct {
|
||||
type wrapperMassStopRequest struct {
|
||||
MassStopRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// MassStop starts jobs to stop several computes
|
||||
|
||||
@@ -22,7 +22,7 @@ type MigrateRequest struct {
|
||||
|
||||
type AsyncWrapperMigrateRequest struct {
|
||||
MigrateRequest
|
||||
SyncMode bool `url:"sync"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Migrate migrates compute to another node
|
||||
@@ -34,7 +34,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, AsyncMode: false}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, syncReq)
|
||||
if err != nil {
|
||||
@@ -58,7 +58,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, AsyncMode: true}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, asyncReq)
|
||||
if err != nil {
|
||||
|
||||
@@ -18,7 +18,7 @@ type MigrateAbortRequest struct {
|
||||
type wrapperMigrateAbortRequest struct {
|
||||
MigrateAbortRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// MigrateAbort aborts compute migration
|
||||
|
||||
@@ -28,7 +28,7 @@ type MigrateStorageRequest struct {
|
||||
|
||||
// Async API call
|
||||
// Required: true
|
||||
Sync bool `url:"sync" json:"sync" validate:"required"`
|
||||
Async interface{} `url:"async_mode" json:"async_mode" validate:"required,isBool"`
|
||||
}
|
||||
|
||||
// MigrateStorage gets complex compute migration
|
||||
|
||||
@@ -23,7 +23,7 @@ type MigrateStorageAbortRequest struct {
|
||||
type wrapperMigrateStorageAbortRequest struct {
|
||||
MigrateStorageAbortRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// MigrateStorageAbort aborts complex compute migration job
|
||||
|
||||
@@ -18,7 +18,7 @@ type MigrateStorageCleanUpRequest struct {
|
||||
type wrapperMigrateStorageCleanUpRequest struct {
|
||||
MigrateStorageCleanUpRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// MigrateStorageCleanUp cleanup resources after finished (success of failed) complex compute migration.
|
||||
|
||||
@@ -22,7 +22,7 @@ type MigrateToZoneRequest struct {
|
||||
type wrapperMigrateToZoneRequest struct {
|
||||
MigrateToZoneRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// MigrateToZone moves compute to new zone
|
||||
|
||||
@@ -37,7 +37,7 @@ type MoveToRGRequest struct {
|
||||
type wrapperMoveToRGRequest struct {
|
||||
MoveToRGRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// MoveToRG moves compute instance to new resource group
|
||||
|
||||
@@ -96,7 +96,7 @@ type NetAttachRequest struct {
|
||||
type wrapperNetAttachRequest struct {
|
||||
NetAttachRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// NetAttach attaches network to compute and gets info about network
|
||||
|
||||
@@ -26,7 +26,7 @@ type NetDetachRequest struct {
|
||||
type wrapperNetDetachRequest struct {
|
||||
NetDetachRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// NetDetach detaches network from compute
|
||||
|
||||
@@ -41,7 +41,7 @@ type NetQOSRequest struct {
|
||||
type wrapperNetQOSRequest struct {
|
||||
NetQOSRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// NetQOS updates compute interfaces QOS
|
||||
|
||||
@@ -18,7 +18,7 @@ type PauseRequest struct {
|
||||
type wrapperPauseRequest struct {
|
||||
PauseRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Pause pause compute
|
||||
|
||||
@@ -38,7 +38,7 @@ type PFWAddRequest struct {
|
||||
type wrapperPFWAddRequest struct {
|
||||
PFWAddRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// PFWAdd adds port forward rule
|
||||
|
||||
@@ -41,7 +41,7 @@ type PFWDelRequest struct {
|
||||
type wrapperPFWDelRequest struct {
|
||||
PFWDelRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// PFWDel deletes port forward rule
|
||||
|
||||
@@ -31,7 +31,7 @@ type PinToNodeRequest struct {
|
||||
type wrapperPinToNodeRequest struct {
|
||||
PinToNodeRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// PinToNode pins compute to current node
|
||||
|
||||
@@ -18,7 +18,7 @@ type PowerCycleRequest struct {
|
||||
type wrapperPowerCycleRequest struct {
|
||||
PowerCycleRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// PowerCycle makes force stop and start compute
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
type wrapperRaiseDownRequest struct {
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// RaiseDown starting all computes in "DOWN" tech status
|
||||
|
||||
@@ -18,7 +18,7 @@ type RebootRequest struct {
|
||||
type wrapperRebootRequest struct {
|
||||
RebootRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Reboot reboots compute
|
||||
|
||||
@@ -50,7 +50,7 @@ type RedeployRequest struct {
|
||||
type wrapperRedeployRequest struct {
|
||||
RedeployRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Redeploy redeploys compute
|
||||
|
||||
@@ -18,7 +18,7 @@ type ResetRequest struct {
|
||||
type wrapperResetRequest struct {
|
||||
ResetRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Reset resets compute
|
||||
|
||||
@@ -46,7 +46,7 @@ func (r ResizeRequest) GetRAM() map[string]uint64 {
|
||||
type wrapperResizeRequest struct {
|
||||
ResizeRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Resize resizes compute instance
|
||||
|
||||
@@ -18,7 +18,7 @@ type RestoreRequest struct {
|
||||
type wrapperRestoreRequest struct {
|
||||
RestoreRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Restore restores compute from recycle bin
|
||||
|
||||
@@ -18,7 +18,7 @@ type ResumeRequest struct {
|
||||
type wrapperResumeRequest struct {
|
||||
ResumeRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Resume resumes Compute from paused state
|
||||
|
||||
@@ -29,7 +29,7 @@ type SnapshotCreateRequest struct {
|
||||
|
||||
type wrapperSnapshotCreateRequest struct {
|
||||
SnapshotCreateRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// SnapshotCreate creates compute snapshot
|
||||
|
||||
@@ -21,7 +21,7 @@ type SnapshotDeleteRequest struct {
|
||||
type wrapperSnapshotDeleteRequest struct {
|
||||
SnapshotDeleteRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// SnapshotDelete deletes specified compute snapshot
|
||||
|
||||
@@ -2,6 +2,7 @@ package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -17,6 +18,15 @@ type SnapshotEvictDiskRequest struct {
|
||||
// ID of the disk instance
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// Is mode async
|
||||
// Required: false
|
||||
AsyncMode interface{} `url:"async_mode,omitempty" json:"async_mode,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type asyncWrapperSnapshotEvictDiskRequest struct {
|
||||
SnapshotEvictDiskRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
}
|
||||
|
||||
// SnapshotEvictDisk evicts specified disk from all snapshots of a compute instance
|
||||
@@ -26,9 +36,14 @@ func (c Compute) SnapshotEvictDisk(ctx context.Context, req SnapshotEvictDiskReq
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
aReq := asyncWrapperSnapshotEvictDiskRequest{
|
||||
SnapshotEvictDiskRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/snapshotEvictDisk"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +55,32 @@ func (c Compute) SnapshotEvictDisk(ctx context.Context, req SnapshotEvictDiskReq
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AsyncSnapshotEvictDisk evicts specified disk from all snapshots of a compute instance in async mode
|
||||
func (c Compute) AsyncSnapshotEvictDisk(ctx context.Context, req SnapshotEvictDiskRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
aReq := asyncWrapperSnapshotEvictDiskRequest{
|
||||
SnapshotEvictDiskRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/snapshotEvictDisk"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(res, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ type SnapshotRollbackRequest struct {
|
||||
|
||||
type wrapperSnapshotRollbackRequest struct {
|
||||
SnapshotRollbackRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// SnapshotRollback rollbacks specified compute snapshot
|
||||
|
||||
@@ -26,7 +26,7 @@ type StartRequest struct {
|
||||
type wrapperStartRequest struct {
|
||||
StartRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Start starts compute
|
||||
|
||||
@@ -22,7 +22,7 @@ type StopRequest struct {
|
||||
type wrapperStopRequest struct {
|
||||
StopRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Stop stops compute
|
||||
|
||||
@@ -54,7 +54,7 @@ type FromPlatformDiskRequest struct {
|
||||
|
||||
type wrapperFromPlatformDiskRequest struct {
|
||||
FromPlatformDiskRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// FromPlatformDisk creates template from platform disk in sync mode.
|
||||
|
||||
@@ -46,7 +46,7 @@ type CreateCDROMImageRequest struct {
|
||||
|
||||
type asyncWrapperCreateCDROMImageRequest struct {
|
||||
CreateCDROMImageRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// CreateCDROMImage creates CD-ROM image from an ISO identified by URL
|
||||
|
||||
@@ -84,7 +84,7 @@ type CreateRequest struct {
|
||||
|
||||
type asyncWrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// CreateImage creates image from a media identified by URL
|
||||
|
||||
@@ -210,7 +210,7 @@ func (r MassCreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
type wrapperMassCreateRequest struct {
|
||||
MassCreateRequest
|
||||
AsyncMode bool `json:"asyncMode"`
|
||||
AsyncMode bool `json:"async_mode"`
|
||||
}
|
||||
|
||||
type massCreateResponse struct {
|
||||
|
||||
@@ -30,7 +30,7 @@ type EnableRequest struct {
|
||||
type wrapperEnableRequest struct {
|
||||
EnableRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Enable enables node from maintenance status to enabled
|
||||
|
||||
@@ -33,6 +33,11 @@ type ListRequest struct {
|
||||
// Filter sessions active at this timestamp (login_time <= T < logout_time/expires_at)
|
||||
ActiveAt uint64 `url:"active_at,omitempty" json:"active_at,omitempty"`
|
||||
|
||||
// Include archived sessions
|
||||
// Default: true
|
||||
// Required: false
|
||||
IncludeArchive interface{} `url:"include_archive,omitempty" json:"include_archive,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
|
||||
43
pkg/cloudbroker/stpolicy/add_access_replication_profile.go
Normal file
43
pkg/cloudbroker/stpolicy/add_access_replication_profile.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package stpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// AddAccessReplicationProfileRequest struct to grant storage policy access to replication profile
|
||||
type AddAccessReplicationProfileRequest struct {
|
||||
// ID of replication profile
|
||||
// Required: true
|
||||
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
|
||||
|
||||
// ID of storage policy
|
||||
// Required: true
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
}
|
||||
|
||||
// AddAccessReplicationProfile grants storage policy access to replication profile
|
||||
func (sp StPolicy) AddAccessReplicationProfile(ctx context.Context, req AddAccessReplicationProfileRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/storage_policy/add_access_replication_profile"
|
||||
|
||||
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
77
pkg/cloudbroker/stpolicy/create_replication_profile.go
Normal file
77
pkg/cloudbroker/stpolicy/create_replication_profile.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package stpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// CalendarRequest struct for replication schedule calendar
|
||||
type CalendarRequest struct {
|
||||
// Weekly schedule
|
||||
// Required: true
|
||||
Weekly []string `url:"weekly" json:"weekly" validate:"required"`
|
||||
}
|
||||
|
||||
// SchedulesRequest struct for replication profile schedule
|
||||
type SchedulesRequest struct {
|
||||
// Type of the schedule
|
||||
// Required: true
|
||||
Type string `url:"type" json:"type" validate:"required"`
|
||||
|
||||
// Name of the schedule
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Min interval
|
||||
// Required: false
|
||||
MINInterval uint64 `url:"min_interval,omitempty" json:"min_interval,omitempty"`
|
||||
|
||||
// Calendar of the schedule
|
||||
// Required: false
|
||||
Calendar []CalendarRequest `url:"calendar,omitempty" json:"calendar,omitempty" validate:"omitempty,dive"`
|
||||
}
|
||||
|
||||
// CreateReplicationProfileRequest struct to create replication profile
|
||||
type CreateReplicationProfileRequest struct {
|
||||
// Name of the replication profile
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Replication type
|
||||
// Required: true
|
||||
ReplicationType string `url:"replication_type" json:"replication_type" validate:"required"`
|
||||
|
||||
// Max copy rate
|
||||
// Required: false
|
||||
MAXCopyRate uint64 `url:"max_copy_rate,omitempty" json:"max_copy_rate,omitempty"`
|
||||
|
||||
// List of schedules
|
||||
// Required: false
|
||||
Schedules []SchedulesRequest `url:"schedules,omitempty" json:"schedules,omitempty" validate:"omitempty,dive"`
|
||||
}
|
||||
|
||||
// CreateReplicationProfile creates a new replication profile
|
||||
func (sp StPolicy) CreateReplicationProfile(ctx context.Context, req CreateReplicationProfileRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/storage_policy/create_replication_profile"
|
||||
|
||||
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
39
pkg/cloudbroker/stpolicy/delete_replication_profile.go
Normal file
39
pkg/cloudbroker/stpolicy/delete_replication_profile.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package stpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteReplicationProfileRequest struct to delete replication profile
|
||||
type DeleteReplicationProfileRequest struct {
|
||||
// ID of replication profile
|
||||
// Required: true
|
||||
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
|
||||
}
|
||||
|
||||
// DeleteReplicationProfile deletes replication profile
|
||||
func (sp StPolicy) DeleteReplicationProfile(ctx context.Context, req DeleteReplicationProfileRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/storage_policy/delete_replication_profile"
|
||||
|
||||
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
46
pkg/cloudbroker/stpolicy/get_replication_profile.go
Normal file
46
pkg/cloudbroker/stpolicy/get_replication_profile.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package stpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetReplicationProfileRequest struct to get replication profile
|
||||
type GetReplicationProfileRequest struct {
|
||||
// ID of replication profile
|
||||
// Required: true
|
||||
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
|
||||
}
|
||||
|
||||
// GetReplicationProfile gets replication profile as an InfoReplicationProfile struct
|
||||
func (sp StPolicy) GetReplicationProfile(ctx context.Context, req GetReplicationProfileRequest) (*InfoReplicationProfile, error) {
|
||||
res, err := sp.GetReplicationProfileRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := InfoReplicationProfile{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetReplicationProfileRaw gets replication profile as an array of bytes
|
||||
func (sp StPolicy) GetReplicationProfileRaw(ctx context.Context, req GetReplicationProfileRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/storage_policy/get_replication_profile"
|
||||
|
||||
res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
65
pkg/cloudbroker/stpolicy/list_replication_profile.go
Normal file
65
pkg/cloudbroker/stpolicy/list_replication_profile.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package stpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListReplicationProfileRequest struct to get list of replication profiles
|
||||
type ListReplicationProfileRequest struct {
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
|
||||
// Search by replication profile ID
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
|
||||
// Search by replication profile name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Search by replication type
|
||||
// Required: false
|
||||
ReplicationType string `url:"replication_type,omitempty" json:"replication_type,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format ±<field>
|
||||
// Required: false
|
||||
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
|
||||
}
|
||||
|
||||
// ListReplicationProfile gets list of replication profiles as a ListReplicationProfiles struct
|
||||
func (sp StPolicy) ListReplicationProfile(ctx context.Context, req ListReplicationProfileRequest) (*ListReplicationProfiles, error) {
|
||||
res, err := sp.ListReplicationProfileRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListReplicationProfiles{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListReplicationProfileRaw gets list of replication profiles as an array of bytes
|
||||
func (sp StPolicy) ListReplicationProfileRaw(ctx context.Context, req ListReplicationProfileRequest) ([]byte, error) {
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/storage_policy/list_replication_profile"
|
||||
|
||||
res, err := sp.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -19,9 +19,12 @@ type InfoStoragePolicyWithID struct {
|
||||
// Status of the storage policy
|
||||
Status string `json:"status"`
|
||||
|
||||
// Max IOPS for the sotrage policy
|
||||
// Max IOPS for the storage policy
|
||||
LimitIOPS uint64 `json:"limit_iops"`
|
||||
|
||||
// ID of the replication profile
|
||||
ReplicationProfileID uint64 `json:"replication_profile_id"`
|
||||
|
||||
// Which accounts and resource groups use the storage policy
|
||||
Usage Usage `json:"usage"`
|
||||
}
|
||||
@@ -53,9 +56,12 @@ type ItemStoragePolicy struct {
|
||||
// Status of the storage policy
|
||||
Status string `json:"status"`
|
||||
|
||||
// Max IOPS for the sotrage policy
|
||||
// Max IOPS for the storage policy
|
||||
LimitIOPS uint64 `json:"limit_iops"`
|
||||
|
||||
// ID of the replication profile
|
||||
ReplicationProfileID uint64 `json:"replication_profile_id"`
|
||||
|
||||
// Storage policy ID
|
||||
StoragePolicyID uint64 `json:"storage_policy_id"`
|
||||
|
||||
@@ -85,6 +91,9 @@ type InfoStoragePolicy struct {
|
||||
// Max IOPS for the storage policy
|
||||
LimitIOPS uint64 `json:"limit_iops"`
|
||||
|
||||
// ID of the replication profile
|
||||
ReplicationProfileID uint64 `json:"replication_profile_id"`
|
||||
|
||||
// Storage policy ID
|
||||
StoragePolicyID uint64 `json:"storage_policy_id"`
|
||||
|
||||
@@ -115,3 +124,72 @@ type Usage struct {
|
||||
// List of resource groups
|
||||
Resgroups []uint64 `json:"resgroups"`
|
||||
}
|
||||
|
||||
type ListReplicationProfiles struct {
|
||||
// List
|
||||
Data []ItemReplicationProfile `json:"data"`
|
||||
|
||||
// Entry Count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
type ItemReplicationProfile struct {
|
||||
// ID of the replication profile
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// Name of the replication profile
|
||||
Name string `json:"name"`
|
||||
|
||||
// Replication types
|
||||
ReplicationType []string `json:"replication_type"`
|
||||
|
||||
// Max copy rate
|
||||
MAXCopyRate uint64 `json:"max_copy_rate"`
|
||||
|
||||
// List of schedules
|
||||
Schedules ListSchedules `json:"schedules"`
|
||||
}
|
||||
|
||||
type InfoReplicationProfile struct {
|
||||
// ID of the replication profile
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// Name of the replication profile
|
||||
Name string `json:"name"`
|
||||
|
||||
// Replication types
|
||||
ReplicationType []string `json:"replication_type"`
|
||||
|
||||
// Max copy rate
|
||||
MAXCopyRate uint64 `json:"max_copy_rate"`
|
||||
|
||||
// List of schedules
|
||||
Schedules ListSchedules `json:"schedules"`
|
||||
}
|
||||
|
||||
type ListSchedules []Schedule
|
||||
|
||||
type Schedule struct {
|
||||
// Type of the schedule
|
||||
Type string `json:"type"`
|
||||
|
||||
// Name of the schedule
|
||||
Name string `json:"name"`
|
||||
|
||||
// Min interval
|
||||
MINInterval uint64 `json:"min_interval"`
|
||||
|
||||
// Calendar of the schedule
|
||||
Calendar Calendar `json:"calendar"`
|
||||
}
|
||||
|
||||
type Calendar struct {
|
||||
// Weekly schedule
|
||||
Weekly map[string][]string `json:"weekly"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package stpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RevokeAccessReplicationProfileRequest struct to revoke storage policy access to replication profile
|
||||
type RevokeAccessReplicationProfileRequest struct {
|
||||
// ID of replication profile
|
||||
// Required: true
|
||||
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
|
||||
|
||||
// ID of storage policy
|
||||
// Required: true
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
}
|
||||
|
||||
// RevokeAccessReplicationProfile revokes storage policy access to replication profile
|
||||
func (sp StPolicy) RevokeAccessReplicationProfile(ctx context.Context, req RevokeAccessReplicationProfileRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/storage_policy/revoke_access_replication_profile"
|
||||
|
||||
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
70
pkg/cloudbroker/stpolicy/update_replication_profile.go
Normal file
70
pkg/cloudbroker/stpolicy/update_replication_profile.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package stpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ConfigRequest struct for replication profile config
|
||||
type ConfigRequest struct {
|
||||
// New name of the replication profile
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// New replication type
|
||||
// Required: false
|
||||
ReplicationType string `url:"replication_type,omitempty" json:"replication_type,omitempty"`
|
||||
|
||||
// New max copy rate
|
||||
// Required: false
|
||||
MAXCopyRate uint64 `url:"max_copy_rate,omitempty" json:"max_copy_rate,omitempty"`
|
||||
|
||||
// New list of schedules
|
||||
// Required: false
|
||||
Schedules []SchedulesRequest `url:"schedules,omitempty" json:"schedules,omitempty" validate:"omitempty,dive"`
|
||||
}
|
||||
|
||||
// UpdateReplicationProfileRequest struct to update replication profile
|
||||
type UpdateReplicationProfileRequest struct {
|
||||
// ID of replication profile
|
||||
// Required: true
|
||||
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
|
||||
|
||||
// Config of the replication profile
|
||||
// Required: true
|
||||
Config []ConfigRequest `url:"config" json:"config" validate:"required,dive"`
|
||||
}
|
||||
|
||||
// UpdateReplicationProfile updates replication profile
|
||||
func (sp StPolicy) UpdateReplicationProfile(ctx context.Context, req UpdateReplicationProfileRequest) (*InfoReplicationProfile, error) {
|
||||
res, err := sp.UpdateReplicationProfileRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := InfoReplicationProfile{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// UpdateReplicationProfileRaw updates replication profile and returns result as an array of bytes
|
||||
func (sp StPolicy) UpdateReplicationProfileRaw(ctx context.Context, req UpdateReplicationProfileRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/storage_policy/update_replication_profile"
|
||||
|
||||
res, err := sp.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
return res, err
|
||||
}
|
||||
10
pkg/cloudbroker/vmfolder.go
Normal file
10
pkg/cloudbroker/vmfolder.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package cloudbroker
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vmfolder"
|
||||
)
|
||||
|
||||
// Accessing the VMFolder method group
|
||||
func (cb *CloudBroker) VMFolder() *vmfolder.VMFolder {
|
||||
return vmfolder.New(cb.client)
|
||||
}
|
||||
47
pkg/cloudbroker/vmfolder/add_acl_access.go
Normal file
47
pkg/cloudbroker/vmfolder/add_acl_access.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// AddACLAccessRequest adds ACL access to a vm folder
|
||||
type AddACLAccessRequest struct {
|
||||
// ID of a folder
|
||||
// Required: true
|
||||
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||
|
||||
// User or group name to grant access
|
||||
// Required: true
|
||||
User string `url:"user" json:"user" validate:"required"`
|
||||
|
||||
// ID of a folder
|
||||
// Required: true
|
||||
Right string `url:"right" json:"right" validate:"required"`
|
||||
}
|
||||
|
||||
// AddACLAccess adds ACL access to a vm folder
|
||||
func (v VMFolder) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vmfolder/add_acl_access"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
42
pkg/cloudbroker/vmfolder/computes_move.go
Normal file
42
pkg/cloudbroker/vmfolder/computes_move.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ComputesMoveRequest struct to move computes to a vm folder
|
||||
type ComputesMoveRequest struct {
|
||||
// IDs of computes to move
|
||||
// Required: true
|
||||
ComputeIDs []uint64 `url:"compute_ids" json:"compute_ids" validate:"required"`
|
||||
|
||||
// Target vm folder ID
|
||||
// Required: true
|
||||
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||
}
|
||||
|
||||
// ComputesMove moves computes to a vm folder
|
||||
func (v VMFolder) ComputesMove(ctx context.Context, req ComputesMoveRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vmfolder/computes_move"
|
||||
|
||||
res, err := v.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
|
||||
}
|
||||
47
pkg/cloudbroker/vmfolder/create.go
Normal file
47
pkg/cloudbroker/vmfolder/create.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// CreateRequest struct to create a vm folder
|
||||
type CreateRequest struct {
|
||||
// Resource Group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rg_id" json:"rg_id" validate:"required"`
|
||||
|
||||
// Name
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Parent ID
|
||||
// Required: false
|
||||
ParentID uint64 `url:"parent_id,omitempty" json:"parent_id,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates a vm folder
|
||||
func (v VMFolder) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vmfolder/create"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
43
pkg/cloudbroker/vmfolder/del_acl_access.go
Normal file
43
pkg/cloudbroker/vmfolder/del_acl_access.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteACLAccessRequest deletes ACL access from a vm folder
|
||||
type DelACLAccessRequest struct {
|
||||
// ID of a folder
|
||||
// Required: true
|
||||
FolderID uint64 `url:"folder_id" json:"folder_id"`
|
||||
|
||||
// User or group name to revoke access from
|
||||
// Required: true
|
||||
User string `url:"user" json:"user"`
|
||||
}
|
||||
|
||||
// DeleteACLAccess deletes ACL access from a vm foler
|
||||
func (v VMFolder) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vmfolder/del_acl_access"
|
||||
|
||||
res, err := v.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
38
pkg/cloudbroker/vmfolder/delete.go
Normal file
38
pkg/cloudbroker/vmfolder/delete.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest struct to delete a VM folder
|
||||
type DeleteRequest struct {
|
||||
// ID of a folder to delete
|
||||
// Required: true
|
||||
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Delete deletes a vm folder
|
||||
func (v VMFolder) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vmfolder/delete"
|
||||
|
||||
res, err := v.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
|
||||
}
|
||||
46
pkg/cloudbroker/vmfolder/get.go
Normal file
46
pkg/cloudbroker/vmfolder/get.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get detailed information about a vm folder
|
||||
type GetRequest struct {
|
||||
// ID of a folder
|
||||
// Required: true
|
||||
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Get gets current configuration of the vm folder as a RecordVMFolder struct
|
||||
func (v VMFolder) Get(ctx context.Context, req GetRequest) (*RecordVMFolder, error) {
|
||||
res, err := v.GetRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordVMFolder{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// GetRaw gets current configuration of the vm folder as an array of bytes
|
||||
func (v VMFolder) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vmfolder/get"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
55
pkg/cloudbroker/vmfolder/list.go
Normal file
55
pkg/cloudbroker/vmfolder/list.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of vm folders
|
||||
type ListRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rg_id" json:"rg_id" validate:"required"`
|
||||
|
||||
// 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 all vm folders in a resource group as a ListVMFolder struct
|
||||
func (v VMFolder) List(ctx context.Context, req ListRequest) (*ListVMFolder, error) {
|
||||
|
||||
res, err := v.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := ListVMFolder{}
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &list, nil
|
||||
}
|
||||
|
||||
// ListRaw gets list of all vm folders in a resource group as an array of bytes
|
||||
func (v VMFolder) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vmfolder/list"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
82
pkg/cloudbroker/vmfolder/models.go
Normal file
82
pkg/cloudbroker/vmfolder/models.go
Normal file
@@ -0,0 +1,82 @@
|
||||
package vmfolder
|
||||
|
||||
// Detailed information about a folder
|
||||
type RecordVMFolder struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// RG ID
|
||||
RGID uint64 `json:"rg_id"`
|
||||
|
||||
// GID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// Name of a folder
|
||||
Name string `json:"name"`
|
||||
|
||||
// ACL
|
||||
ACL []ACL `json:"acl"`
|
||||
|
||||
// Time of creation
|
||||
CreatedTime uint64 `json:"created_time"`
|
||||
|
||||
// Parent ID
|
||||
ParentID uint64 `json:"parent_id"`
|
||||
|
||||
// Status of a folder
|
||||
Status string `json:"status"`
|
||||
|
||||
// Compute IDs
|
||||
ComputeIDs []uint64 `json:"compute_ids"`
|
||||
|
||||
// Time of update
|
||||
UpdatedTime uint64 `json:"updated_time"`
|
||||
}
|
||||
|
||||
// ACL
|
||||
type ACL struct {
|
||||
// Explicit
|
||||
Explicit bool `json:"explicit"`
|
||||
|
||||
// Right
|
||||
Right string `json:"right"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// User group ID
|
||||
UserGroupID string `json:"userGroupId"`
|
||||
}
|
||||
|
||||
// List of vm folders
|
||||
type ListVMFolder struct {
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
|
||||
// Data
|
||||
Data []ItemVMFolder `json:"data"`
|
||||
}
|
||||
|
||||
// Detailed information about a folder item
|
||||
type ItemVMFolder struct {
|
||||
// Folder ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Parent ID
|
||||
ParentID uint64 `json:"parent_id"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// ACL
|
||||
ACL []ACL `json:"acl"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// VM count
|
||||
VMCount uint64 `json:"vm_count"`
|
||||
}
|
||||
42
pkg/cloudbroker/vmfolder/move.go
Normal file
42
pkg/cloudbroker/vmfolder/move.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// MoveRequest to move a vm folder to a compute
|
||||
type MoveRequest struct {
|
||||
// VM Folder ID
|
||||
// Required: true
|
||||
FolderID uint64 `url:"folder_id" json:"folder_id"`
|
||||
|
||||
// New parent folder ID
|
||||
// Required: true
|
||||
NewParentID uint64 `url:"new_parent_id" json:"new_parent_id"`
|
||||
}
|
||||
|
||||
// Move moves a vm folder to a compute
|
||||
func (v VMFolder) Move(ctx context.Context, req MoveRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vmfolder/move"
|
||||
|
||||
res, err := v.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
|
||||
}
|
||||
42
pkg/cloudbroker/vmfolder/rename.go
Normal file
42
pkg/cloudbroker/vmfolder/rename.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RenameRequest struct to rename a VM folder
|
||||
type RenameRequest struct {
|
||||
// ID of a folder to rename
|
||||
// Required: true
|
||||
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||
|
||||
// A new name
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
// Rename renames a vm folder
|
||||
func (v VMFolder) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/vmfolder/rename"
|
||||
|
||||
res, err := v.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
|
||||
}
|
||||
17
pkg/cloudbroker/vmfolder/vmfolder.go
Normal file
17
pkg/cloudbroker/vmfolder/vmfolder.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to VMFolder
|
||||
type VMFolder struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// Builder for VMFolder endpoints
|
||||
func New(client interfaces.Caller) *VMFolder {
|
||||
return &VMFolder{
|
||||
client,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user