parent
1f8637400f
commit
7dacf35cd6
@ -0,0 +1,42 @@
|
|||||||
|
package bservice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MigrateToZone struct to move basic service to another zone
|
||||||
|
type MigrateToZoneRequest struct {
|
||||||
|
// ID of the BasicService to move
|
||||||
|
// Required: true
|
||||||
|
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the zone to move
|
||||||
|
// Required: true
|
||||||
|
ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MigrateToZone moves basic service instance to new zone
|
||||||
|
func (b BService) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/bservice/migrateToZone"
|
||||||
|
|
||||||
|
res, err := b.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,42 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AbortSharedSnapshotMergeRequest struct to abort shared snapshots merge
|
||||||
|
type AbortSharedSnapshotMergeRequest struct {
|
||||||
|
// ID of the compute
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
|
||||||
|
// Label of the snapshot
|
||||||
|
// Required: true
|
||||||
|
Label string `url:"label" json:"label" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AbortSharedSnapshotMerge shared snapshots merge abort
|
||||||
|
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/abort_shared_snapshot_merge"
|
||||||
|
|
||||||
|
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,46 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChangeMTURequest struct to change MTU for a compute
|
||||||
|
type ChangeMTURequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
|
||||||
|
// Interface name or MAC address
|
||||||
|
// Required: true
|
||||||
|
Interface string `url:"interface" json:"interface" validate:"required"`
|
||||||
|
|
||||||
|
// Maximum transmission unit
|
||||||
|
// Required: true
|
||||||
|
MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChangeMTU change MTU for compute instance
|
||||||
|
func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/change_mtu"
|
||||||
|
|
||||||
|
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,38 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GuestAgentDisableRequest struct to disable guest agent
|
||||||
|
type GuestAgentDisableRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable guest agent at a specific compute
|
||||||
|
func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/guest_agent_disable"
|
||||||
|
|
||||||
|
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,38 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GuestAgentEnableRequest struct to enable guest agent
|
||||||
|
type GuestAgentEnableRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable guest agent at a specific compute
|
||||||
|
func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/guest_agent_enable"
|
||||||
|
|
||||||
|
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,48 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GuestAgentExecuteRequest struct to execute command from user to agent
|
||||||
|
type GuestAgentExecuteRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
|
||||||
|
// Custom command from user to agent
|
||||||
|
// Required: true
|
||||||
|
Command string `url:"command" json:"command" validate:"required"`
|
||||||
|
|
||||||
|
// Arguments to command
|
||||||
|
// Required: true
|
||||||
|
Arguments string `url:"arguments" json:"arguments" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute guest agent command
|
||||||
|
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/guest_agent_execute"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var result map[string]interface{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GuestAgentFeatureGetRequest struct to feature get guest agent
|
||||||
|
type GuestAgentFeatureGetRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of features
|
||||||
|
func (c Compute) GuestAgentFeatureGet(ctx context.Context, req GuestAgentFeatureGetRequest) ([]string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/guest_agent_feature_get"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
features := make([]string, 0)
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &features)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return features, nil
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GuestAgentFeatureUpdateRequest struct to feature update guest agent
|
||||||
|
type GuestAgentFeatureUpdateRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Feature update guest agent
|
||||||
|
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/guest_agent_feature_update"
|
||||||
|
|
||||||
|
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,42 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MigrateToRGZone struct to move compute to another zone
|
||||||
|
type MigrateToZoneRequest struct {
|
||||||
|
// ID of the compute instance to move
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the zone to move
|
||||||
|
// Required: true
|
||||||
|
ZoneID uint64 `url:"zoneId" json:"zoneId " validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MoveToRG moves compute instance to new resource group
|
||||||
|
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/migrateToZone"
|
||||||
|
|
||||||
|
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,33 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SharedSnapshotMergeStatusRequest struct to get shared snapshot merge status
|
||||||
|
type SharedSnapshotMergeStatusRequest struct {
|
||||||
|
// ID of compute instance to get log for
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SharedSnapshotMergeStatus shared snapshots merge status
|
||||||
|
// returns a string representing either the current status or the progress percentage
|
||||||
|
func (c Compute) SharedSnapshotMergeStatus(ctx context.Context, req SharedSnapshotMergeStatusRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/compute/shared_snapshot_merge_status"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res), nil
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MigrateToZone struct to move k8s cluster to another zone
|
||||||
|
type MigrateToZoneRequest struct {
|
||||||
|
// Kubernetes cluster ID to move
|
||||||
|
// Required: true
|
||||||
|
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the zone to move
|
||||||
|
// Required: true
|
||||||
|
ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MigrateToZone moves k8s cluster instance to new zone
|
||||||
|
func (k8s K8S) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/k8s/migrateToZone"
|
||||||
|
|
||||||
|
res, err := k8s.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,42 @@
|
|||||||
|
package lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MigrateToZone struct to move lb to another zone
|
||||||
|
type MigrateToZoneRequest struct {
|
||||||
|
// ID of the load balancer instance to move
|
||||||
|
// Required: true
|
||||||
|
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the zone to move
|
||||||
|
// Required: true
|
||||||
|
ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MigrateToZone moves lb instance to new zone
|
||||||
|
func (l LB) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/lb/migrateToZone"
|
||||||
|
|
||||||
|
res, err := l.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,71 @@
|
|||||||
|
package locations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListGetRequest struct to get list of locations
|
||||||
|
type ListGetRequest 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"`
|
||||||
|
|
||||||
|
// Find by flag
|
||||||
|
// Required: false
|
||||||
|
Flag string `url:"flag,omitempty" json:"flag,omitempty"`
|
||||||
|
|
||||||
|
// Find by name
|
||||||
|
// Required: false
|
||||||
|
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||||
|
|
||||||
|
// Find by ID
|
||||||
|
// Required: false
|
||||||
|
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by code location
|
||||||
|
// Required: false
|
||||||
|
LocationCode string `url:"locationCode,omitempty" json:"locationCode,omitempty"`
|
||||||
|
|
||||||
|
// Sort by one of supported fields, format +|-(field)
|
||||||
|
// Required: false
|
||||||
|
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListGet gets list of all locations as a ListLocations struct
|
||||||
|
func (l Locations) ListGet(ctx context.Context, req ListGetRequest) (*ListLocations, error) {
|
||||||
|
|
||||||
|
res, err := l.ListGetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListLocations{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListGetRaw gets list of all locations as an array of bytes
|
||||||
|
func (l Locations) ListGetRaw(ctx context.Context, req ListGetRequest) ([]byte, error) {
|
||||||
|
|
||||||
|
if err := validators.ValidateRequest(req); err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/locations/list"
|
||||||
|
|
||||||
|
res, err := l.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/trunk"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Accessing the Trunk method group
|
||||||
|
func (ca *CloudAPI) Trunk() *trunk.Trunk {
|
||||||
|
return trunk.New(ca.client)
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package trunk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequest struct to get information about a trunk
|
||||||
|
type GetRequest struct {
|
||||||
|
// ID of trunk
|
||||||
|
// Required: true
|
||||||
|
TrunkID uint64 `url:"id" json:"id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets detailed information about a trunk as a ItemTrunk struct
|
||||||
|
func (t Trunk) Get(ctx context.Context, req GetRequest) (*ItemTrunk, error) {
|
||||||
|
res, err := t.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := ItemTrunk{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets detailed information about a trunk as an array of bytes
|
||||||
|
func (t Trunk) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/trunk/get"
|
||||||
|
|
||||||
|
res, err := t.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package trunk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRequest struct to get list of trunks
|
||||||
|
type ListRequest struct {
|
||||||
|
// Account access ID to filter by
|
||||||
|
AccountIDs []uint64 `url:"account_ids,omitempty" json:"account_ids,omitempty"`
|
||||||
|
|
||||||
|
// ID of the trunk to filter by
|
||||||
|
IDs []uint64 `url:"ids,omitempty" json:"ids,omitempty"`
|
||||||
|
|
||||||
|
// Sort by one of supported fields, format ±<field>
|
||||||
|
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty"`
|
||||||
|
|
||||||
|
// Trunk tags to filter by
|
||||||
|
TrunkTags string `url:"trunk_tags,omitempty" json:"trunk_tags,omitempty" validate:"omitempty,trunkTags"`
|
||||||
|
|
||||||
|
// Page number
|
||||||
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|
||||||
|
// Page size
|
||||||
|
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List gets list of all trunks as a ListTrunks struct
|
||||||
|
func (t Trunk) List(ctx context.Context, req ListRequest) (*ListTrunks, error) {
|
||||||
|
|
||||||
|
res, err := t.ListRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListTrunks{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all trunks as an array of bytes
|
||||||
|
func (t Trunk) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
|
||||||
|
if err := validators.ValidateRequest(req); err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/trunk/list"
|
||||||
|
|
||||||
|
res, err := t.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package trunk
|
||||||
|
|
||||||
|
type ItemTrunk struct {
|
||||||
|
|
||||||
|
// List of account IDs with access to this trunk
|
||||||
|
AccountIDs []uint64 `json:"accountIds"`
|
||||||
|
|
||||||
|
// Created at
|
||||||
|
CreatedAt uint64 `json:"created_at"`
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
CreatedBy string `json:"created_by"`
|
||||||
|
|
||||||
|
// Deleted at
|
||||||
|
DeletedAt uint64 `json:"deleted_at"`
|
||||||
|
|
||||||
|
// Deleted by
|
||||||
|
DeletedBy string `json:"deleted_by"`
|
||||||
|
|
||||||
|
// Description of a trunk
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// ID of a trunk
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// MAC
|
||||||
|
MAC string `json:"mac"`
|
||||||
|
|
||||||
|
// Name of a trunk
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Native VLAN ID
|
||||||
|
NativeVLANID uint64 `json:"nativeVlanId"`
|
||||||
|
|
||||||
|
// OVS bridge name
|
||||||
|
OVSBridge string `json:"ovsBridge"`
|
||||||
|
|
||||||
|
// If the trunk is enabled
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// List of trunk tags (values between 1-4095)
|
||||||
|
TrunkTags string `json:"trunkTags"`
|
||||||
|
|
||||||
|
// Updated at
|
||||||
|
UpdatedAt uint64 `json:"updated_at"`
|
||||||
|
|
||||||
|
// Updated by
|
||||||
|
UpdatedBy string `json:"updated_by"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of trunks
|
||||||
|
type ListTrunks struct {
|
||||||
|
Data []ItemTrunk `json:"data"`
|
||||||
|
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// API Actor API for trunk nerworks
|
||||||
|
package trunk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Structure for creating request to trunk
|
||||||
|
type Trunk struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for trunk endpoints
|
||||||
|
func New(client interfaces.Caller) *Trunk {
|
||||||
|
return &Trunk{
|
||||||
|
client,
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package vins
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MigrateToZone struct to move VINS to another zone
|
||||||
|
type MigrateToZoneRequest struct {
|
||||||
|
// VINSID to move
|
||||||
|
// Required: true
|
||||||
|
VINSID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the zone to move
|
||||||
|
// Required: true
|
||||||
|
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MigrateToZone moves VINS instance to new zone
|
||||||
|
func (v VINS) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/vins/migrateToZone"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package cloudapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/zone"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Accessing the Zone method group
|
||||||
|
func (ca *CloudAPI) Zone() *zone.Zone {
|
||||||
|
return zone.New(ca.client)
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package zone
|
||||||
|
|
||||||
|
// FilterByID returns ListZones with specified ID.
|
||||||
|
func (list ListZones) FilterByID(id uint64) ListZones {
|
||||||
|
predicate := func(izone RecordZone) bool {
|
||||||
|
return izone.ID == id
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.FilterFunc(predicate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterByName returns ListZones with specified Name.
|
||||||
|
func (list ListZones) FilterByName(name string) ListZones {
|
||||||
|
predicate := func(izone RecordZone) bool {
|
||||||
|
return izone.Name == name
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.FilterFunc(predicate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterByStatus returns ListZones with specified Status.
|
||||||
|
func (list ListZones) FilterByStatus(status string) ListZones {
|
||||||
|
predicate := func(izone RecordZone) bool {
|
||||||
|
return izone.Status == status
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.FilterFunc(predicate)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterFunc allows filtering ListZones based on a user-specified predicate.
|
||||||
|
func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones {
|
||||||
|
var result ListZones
|
||||||
|
|
||||||
|
for _, item := range list.Data {
|
||||||
|
if predicate(item) {
|
||||||
|
result.Data = append(result.Data, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.EntryCount = uint64(len(result.Data))
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindOne returns first found RecordZone
|
||||||
|
// If none was found, returns an empty struct.
|
||||||
|
func (list ListZones) FindOne() RecordZone {
|
||||||
|
if list.EntryCount == 0 {
|
||||||
|
return RecordZone{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.Data[0]
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package zone
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
var zones = ListZones{
|
||||||
|
Data: []RecordZone{
|
||||||
|
|
||||||
|
{
|
||||||
|
ID: 2,
|
||||||
|
GUID: 0,
|
||||||
|
GID: 0,
|
||||||
|
Name: "System Config",
|
||||||
|
Description: "",
|
||||||
|
Deletable: true,
|
||||||
|
Status: "LOCKED",
|
||||||
|
CreatedTime: 1640995200, // 2022-01-01
|
||||||
|
UpdatedTime: 1640995200,
|
||||||
|
NodeIDs: nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 5,
|
||||||
|
GUID: 5500,
|
||||||
|
GID: 6600,
|
||||||
|
Name: "ssss Nodes",
|
||||||
|
Description: " infrastructure",
|
||||||
|
Deletable: true,
|
||||||
|
Status: "DISABLED",
|
||||||
|
CreatedTime: 1577836800, // 2020-01-01
|
||||||
|
UpdatedTime: 1580515200, // 2020-02-01
|
||||||
|
NodeIDs: []uint64{777, 888, 999},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: 10,
|
||||||
|
GUID: 5500,
|
||||||
|
GID: 6600,
|
||||||
|
Name: "node",
|
||||||
|
Description: "infrastructure",
|
||||||
|
Deletable: true,
|
||||||
|
Status: "DISABLED",
|
||||||
|
CreatedTime: 1577836800,
|
||||||
|
UpdatedTime: 1580515200,
|
||||||
|
NodeIDs: []uint64{777, 888, 999},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilterByID(t *testing.T) {
|
||||||
|
actual := zones.FilterByID(10).FindOne()
|
||||||
|
|
||||||
|
if actual.ID != 10 {
|
||||||
|
t.Fatal("expected ID 10, found: ", actual.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilterByName(t *testing.T) {
|
||||||
|
name := "node"
|
||||||
|
actual := zones.FilterByName(name).FindOne()
|
||||||
|
|
||||||
|
if actual.Name != name {
|
||||||
|
t.Fatal("expected ", name, " found: ", actual.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilterByStatus(t *testing.T) {
|
||||||
|
actual := zones.FilterByStatus("DISABLED")
|
||||||
|
|
||||||
|
if len(actual.Data) != 2 {
|
||||||
|
t.Fatal("expected 2 found, actual: ", len(actual.Data))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, item := range actual.Data {
|
||||||
|
if item.Status != "DISABLED" {
|
||||||
|
t.Fatal("expected Status 'DISABLED', found: ", item.Status)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFilterFunc(t *testing.T) {
|
||||||
|
actual := zones.FilterFunc(func(ien RecordZone) bool {
|
||||||
|
return ien.Deletable == true
|
||||||
|
})
|
||||||
|
|
||||||
|
if len(actual.Data) != 3 {
|
||||||
|
t.Fatal("expected 3 elements, found: ", len(actual.Data))
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package zone
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRequest struct to get detailed information about zone
|
||||||
|
type GetRequest struct {
|
||||||
|
// ID of zone
|
||||||
|
// Required: true
|
||||||
|
ID uint64 `url:"id" json:"id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets detailed information about zone struct
|
||||||
|
func (e Zone) Get(ctx context.Context, req GetRequest) (*RecordZone, error) {
|
||||||
|
res, err := e.GetRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
info := RecordZone{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &info)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &info, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRaw gets detailed information about zone as an array of bytes
|
||||||
|
func (e Zone) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/zone/get"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package zone
|
||||||
|
|
||||||
|
// IDs gets array of IDs from ListZones struct
|
||||||
|
func (le ListZones) IDs() []uint64 {
|
||||||
|
res := make([]uint64, 0, len(le.Data))
|
||||||
|
for _, e := range le.Data {
|
||||||
|
res = append(res, e.ID)
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package zone
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ListRequest struct to get list of zones
|
||||||
|
type ListRequest struct {
|
||||||
|
|
||||||
|
// Find by ID
|
||||||
|
// Required: false
|
||||||
|
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||||
|
|
||||||
|
// Find by Grid ID
|
||||||
|
// 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 deletable
|
||||||
|
// Required: false
|
||||||
|
Deletable bool `url:"deletable,omitempty" json:"deletable,omitempty"`
|
||||||
|
|
||||||
|
// Find by node ID
|
||||||
|
// Required: false
|
||||||
|
NodeID uint64 `url:"nodeId,omitempty" json:"nodeId,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 all zones as a ListZones struct
|
||||||
|
func (e Zone) List(ctx context.Context, req ListRequest) (*ListZones, error) {
|
||||||
|
|
||||||
|
res, err := e.ListRaw(ctx, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := ListZones{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListRaw gets list of all available zones as an array of bytes
|
||||||
|
func (e Zone) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||||
|
|
||||||
|
if err := validators.ValidateRequest(req); err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/zone/list"
|
||||||
|
|
||||||
|
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
return res, err
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
package zone
|
@ -0,0 +1,42 @@
|
|||||||
|
package zone
|
||||||
|
|
||||||
|
type ListZones struct {
|
||||||
|
// Entry count
|
||||||
|
EntryCount uint64 `json:"entryCount"`
|
||||||
|
|
||||||
|
// Data
|
||||||
|
Data []RecordZone `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detailed information about the zone record
|
||||||
|
type RecordZone struct {
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// GID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"description"`
|
||||||
|
|
||||||
|
// Deletable flag
|
||||||
|
Deletable bool `json:"deletable"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Created timestamp
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Updated timestamp
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// List of associated Node IDs
|
||||||
|
NodeIDs []uint64 `json:"nodeIds"`
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package zone
|
||||||
|
|
||||||
|
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 (list ListZones) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
|
if list.EntryCount == 0 {
|
||||||
|
return []byte{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(params) > 1 {
|
||||||
|
prefix := params[0]
|
||||||
|
indent := params[1]
|
||||||
|
|
||||||
|
return json.MarshalIndent(list, prefix, indent)
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(list)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 (item RecordZone) Serialize(params ...string) (serialization.Serialized, error) {
|
||||||
|
if len(params) > 1 {
|
||||||
|
prefix := params[0]
|
||||||
|
indent := params[1]
|
||||||
|
|
||||||
|
return json.MarshalIndent(item, prefix, indent)
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(item)
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
// API Actor for use zones
|
||||||
|
package zone
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Structure for creating request to zone
|
||||||
|
type Zone struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for zone endpoints
|
||||||
|
func New(client interfaces.Caller) *Zone {
|
||||||
|
return &Zone{
|
||||||
|
client,
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddZoneRequest struct for adding zone to account for a user
|
||||||
|
type AddZoneRequest struct {
|
||||||
|
// ID of account to add to
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
|
||||||
|
// IDs of zones
|
||||||
|
// Required: true
|
||||||
|
ZoneIDs []uint64 `url:"zoneIds" json:"zoneIds" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddUser gives a user access rights.
|
||||||
|
func (a Account) AddZone(ctx context.Context, req AddZoneRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/account/addZone"
|
||||||
|
|
||||||
|
res, err := a.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,42 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RemoveZoneRequest struct for removing zone from account for a user
|
||||||
|
type RemoveZoneRequest struct {
|
||||||
|
// ID of account to add to
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||||
|
|
||||||
|
// IDs of zones
|
||||||
|
// Required: true
|
||||||
|
ZoneIDs []uint64 `url:"zoneIds" json:"zoneIds" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveZone removes zones with ids provided from a user.
|
||||||
|
func (a Account) RemoveZone(ctx context.Context, req RemoveZoneRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/account/removeZone"
|
||||||
|
|
||||||
|
res, err := a.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,42 @@
|
|||||||
|
package bservice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MigrateToZone struct to move basic service to another zone
|
||||||
|
type MigrateToZoneRequest struct {
|
||||||
|
// ID of the BasicService to move
|
||||||
|
// Required: true
|
||||||
|
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the zone to move
|
||||||
|
// Required: true
|
||||||
|
ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MigrateToZone moves Basic Service instance to new zone
|
||||||
|
func (b BService) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/bservice/migrateToZone"
|
||||||
|
|
||||||
|
res, err := b.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,42 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AbortSharedSnapshotMergeRequest struct to abort shared snapshots merge
|
||||||
|
type AbortSharedSnapshotMergeRequest struct {
|
||||||
|
// ID of the compute
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
|
||||||
|
// Label of the snapshot
|
||||||
|
// Required: true
|
||||||
|
Label string `url:"label" json:"label" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AbortSharedSnapshotMerge shared snapshots merge abort
|
||||||
|
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/abort_shared_snapshot_merge"
|
||||||
|
|
||||||
|
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,46 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChangeMTURequest struct to change MTU for a compute
|
||||||
|
type ChangeMTURequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
|
||||||
|
// Interface name or MAC address
|
||||||
|
// Required: true
|
||||||
|
Interface string `url:"interface" json:"interface" validate:"required"`
|
||||||
|
|
||||||
|
// Maximum transmission unit
|
||||||
|
// Required: true
|
||||||
|
MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChangeMTU change MTU for compute instance
|
||||||
|
func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/change_mtu"
|
||||||
|
|
||||||
|
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,38 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GuestAgentDisableRequest struct to disable guest agent
|
||||||
|
type GuestAgentDisableRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable guest agent at a specific compute
|
||||||
|
func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/guest_agent_disable"
|
||||||
|
|
||||||
|
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,38 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GuestAgentEnableRequest struct to enable guest agent
|
||||||
|
type GuestAgentEnableRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable guest agent at a specific compute
|
||||||
|
func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/guest_agent_enable"
|
||||||
|
|
||||||
|
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,48 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GuestAgentExecuteRequest struct to execute command from user to agent
|
||||||
|
type GuestAgentExecuteRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
|
||||||
|
// Custom command from user to agent
|
||||||
|
// Required: true
|
||||||
|
Command string `url:"command" json:"command" validate:"required"`
|
||||||
|
|
||||||
|
// Arguments to command
|
||||||
|
// Required: true
|
||||||
|
Arguments string `url:"arguments" json:"arguments" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute guest agent command
|
||||||
|
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/guest_agent_execute"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var result map[string]interface{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GuestAgentFeatureGetRequest struct to feature get guest agent
|
||||||
|
type GuestAgentFeatureGetRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// List of features
|
||||||
|
func (c Compute) GuestAgentFeatureGet(ctx context.Context, req GuestAgentFeatureGetRequest) ([]string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/guest_agent_feature_get"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
features := make([]string, 0)
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &features)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return features, nil
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GuestAgentFeatureUpdateRequest struct to feature update guest agent
|
||||||
|
type GuestAgentFeatureUpdateRequest struct {
|
||||||
|
// ID of compute instance
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Feature update guest agent
|
||||||
|
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/guest_agent_feature_update"
|
||||||
|
|
||||||
|
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,42 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MigrateToZone struct to move compute to another zone
|
||||||
|
type MigrateToZoneRequest struct {
|
||||||
|
// ID of the compute instance to move
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the zone to move
|
||||||
|
// Required: true
|
||||||
|
ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MoveToZone moves compute to new zone
|
||||||
|
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/migrateToZone"
|
||||||
|
|
||||||
|
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,33 @@
|
|||||||
|
package compute
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SharedSnapshotMergeStatusRequest struct to get shared snapshot merge status
|
||||||
|
type SharedSnapshotMergeStatusRequest struct {
|
||||||
|
// ID of compute instance to get log for
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SharedSnapshotMergeStatus shared snapshots merge status
|
||||||
|
// returns a string representing either the current status or the progress percentage
|
||||||
|
func (c Compute) SharedSnapshotMergeStatus(ctx context.Context, req SharedSnapshotMergeStatusRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/compute/shared_snapshot_merge_status"
|
||||||
|
|
||||||
|
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res), nil
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package extnet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MigrateToZone struct to move extnet to another zone
|
||||||
|
type MigrateToZoneRequest struct {
|
||||||
|
// ID of external network
|
||||||
|
// Required: true
|
||||||
|
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the zone to move
|
||||||
|
// Required: true
|
||||||
|
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MoveToZone moves extnet to new zone
|
||||||
|
func (e ExtNet) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/extnet/migrateToZone"
|
||||||
|
|
||||||
|
res, err := e.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