v12.0.0
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package cloudbroker
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/account"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/account"
|
||||
)
|
||||
|
||||
// Accessing the Account method group
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// API Actor API for managing account
|
||||
package account
|
||||
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces"
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces"
|
||||
|
||||
// Structure for creating request to account
|
||||
type Account struct {
|
||||
|
||||
46
pkg/cloudbroker/account/add_storage_policy.go
Normal file
46
pkg/cloudbroker/account/add_storage_policy.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// AddStoragePolicyRequest struct for adding storage policy to the account
|
||||
type AddStoragePolicyRequest struct {
|
||||
// ID of account to add to
|
||||
// Required: true
|
||||
AccountID uint64 `url:"account_id" json:"account_id" validate:"required"`
|
||||
|
||||
// ID of the storage policy to which to connect account
|
||||
// Required: true
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
|
||||
// Limit storage resources GB. Or -1 unlimit
|
||||
// Required: false
|
||||
Limit int `url:"limit,omitempty" json:"limit,omitempty"`
|
||||
}
|
||||
|
||||
// AddStoragePolicy add storage policy to the account.
|
||||
func (a Account) AddStoragePolicy(ctx context.Context, req AddStoragePolicyRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/add_storage_policy"
|
||||
|
||||
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
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// AddUserRequest struct for adding permission to access to account for a user
|
||||
|
||||
42
pkg/cloudbroker/account/add_zone.go
Normal file
42
pkg/cloudbroker/account/add_zone.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/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
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// AuditsRequest struct to give list of account audits
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// CreateRequest struct for creating account
|
||||
@@ -26,6 +27,10 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
EmailAddress string `url:"emailaddress,omitempty" json:"emailaddress,omitempty" validate:"omitempty,email"`
|
||||
|
||||
// Storage policies
|
||||
// Required: false
|
||||
StoragePolicies []StoragePolicy `url:"-" json:"storage_policies,omitempty"`
|
||||
|
||||
// Max size of memory in MB
|
||||
// Required: false
|
||||
MaxMemoryCapacity int64 `url:"maxMemoryCapacity,omitempty" json:"maxMemoryCapacity,omitempty"`
|
||||
@@ -60,9 +65,22 @@ type CreateRequest struct {
|
||||
UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"`
|
||||
|
||||
// Advanced compute features,
|
||||
// one of: hugepages, numa, cpupin, vfnic, dpdk, changemac
|
||||
// one of: hugepages, numa, cpupin, vfnic, dpdk, changemac, trunk
|
||||
// Required: false
|
||||
ComputeFeatures []string `url:"computeFeatures,omitempty" json:"computeFeatures,omitempty" validate:"omitempty,computeFeatures"`
|
||||
|
||||
// Default zone ID
|
||||
// Required: false
|
||||
DefaultZoneID uint64 `url:"defaultZoneId,omitempty" json:"defaultZoneId,omitempty"`
|
||||
|
||||
// Zones
|
||||
// Required: false
|
||||
ZoneIDs []uint64 `url:"zoneIds,omitempty" json:"zoneIds,omitempty"`
|
||||
}
|
||||
|
||||
type StoragePolicy struct {
|
||||
ID uint64 `url:"id" json:"id"`
|
||||
Limit int `url:"limit" json:"limit"`
|
||||
}
|
||||
|
||||
// Create creates account
|
||||
@@ -75,7 +93,7 @@ func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error)
|
||||
|
||||
url := "/cloudbroker/account/create"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
42
pkg/cloudbroker/account/del_storage_policy.go
Normal file
42
pkg/cloudbroker/account/del_storage_policy.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DelStoragePolicyRequest struct for deleting storage policy to the account
|
||||
type DelStoragePolicyRequest struct {
|
||||
// ID of account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"account_id" json:"account_id" validate:"required"`
|
||||
|
||||
// ID of the storage policy to which to disconnect account
|
||||
// Required: true
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
}
|
||||
|
||||
// DelStoragePolicy delete storage policy to the account.
|
||||
func (a Account) DelStoragePolicy(ctx context.Context, req DelStoragePolicyRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/del_storage_policy"
|
||||
|
||||
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
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest struct to delete account
|
||||
@@ -20,25 +20,21 @@ type DeleteRequest struct {
|
||||
// Name of account
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Reason of deleting
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Delete completes delete an account from the system Returns true if account is deleted or was already deleted or never existed
|
||||
func (a Account) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/delete"
|
||||
|
||||
_, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return string(result), nil
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteAccountsRequest struct to delete group of accounts
|
||||
@@ -19,18 +19,18 @@ type DeleteAccountsRequest struct {
|
||||
}
|
||||
|
||||
// DeleteAccounts destroys a group of accounts
|
||||
func (a Account) DeleteAccounts(ctx context.Context, req DeleteAccountsRequest) (bool, error) {
|
||||
func (a Account) DeleteAccounts(ctx context.Context, req DeleteAccountsRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/deleteAccounts"
|
||||
|
||||
_, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteUserRequest struct to revoke access to account
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DisableRequest struct to disable account
|
||||
@@ -13,10 +13,6 @@ type DisableRequest struct {
|
||||
// ID of account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Reason of disabling
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Disable disables an account
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DisableAccountsRequest struct to disable group of accounts
|
||||
@@ -12,25 +12,21 @@ type DisableAccountsRequest struct {
|
||||
// IDs of accounts
|
||||
// Required: true
|
||||
AccountIDs []uint64 `url:"accountIds" json:"accountIds" validate:"min=1"`
|
||||
|
||||
// Reason of disabling
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// DisableAccounts disables accounts
|
||||
func (a Account) DisableAccounts(ctx context.Context, req DisableAccountsRequest) (bool, error) {
|
||||
func (a Account) DisableAccounts(ctx context.Context, req DisableAccountsRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/disableAccounts"
|
||||
|
||||
_, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// EnableRequest struct to enable account
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// EnableAccountsRequest to enable group of accounts
|
||||
@@ -15,18 +15,18 @@ type EnableAccountsRequest struct {
|
||||
}
|
||||
|
||||
// EnableAccounts enables accounts
|
||||
func (a Account) EnableAccounts(ctx context.Context, req EnableAccountsRequest) (bool, error) {
|
||||
func (a Account) EnableAccounts(ctx context.Context, req EnableAccountsRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/enableAccounts"
|
||||
|
||||
_, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
@@ -7,18 +7,7 @@ import (
|
||||
var accounts = ListAccounts{
|
||||
Data: []ItemAccount{
|
||||
{
|
||||
Meta: []interface{}{},
|
||||
InfoAccount: InfoAccount{
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "not_really_timofey_tkachev_1@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedTime: 1676878820,
|
||||
DeletedTime: 0,
|
||||
ID: 132847,
|
||||
@@ -26,20 +15,19 @@ var accounts = ListAccounts{
|
||||
Status: "CONFIRMED",
|
||||
UpdatedTime: 1676645275,
|
||||
},
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "not_really_timofey_tkachev_1@decs3o",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Meta: []interface{}{},
|
||||
InfoAccount: InfoAccount{
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "timofey_tkachev_1@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedTime: 1676645275,
|
||||
DeletedTime: 1677723401,
|
||||
ID: 132846,
|
||||
@@ -47,28 +35,19 @@ var accounts = ListAccounts{
|
||||
Status: "DELETED",
|
||||
UpdatedTime: 1676645275,
|
||||
},
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "timofey_tkachev_1@decs3o",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Meta: []interface{}{},
|
||||
InfoAccount: InfoAccount{
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "timofey_tkachev_1@decs3o",
|
||||
},
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "second_account@decs3o",
|
||||
},
|
||||
},
|
||||
CreatedTime: 1676883850,
|
||||
DeletedTime: 1676883899,
|
||||
ID: 132848,
|
||||
@@ -76,6 +55,24 @@ var accounts = ListAccounts{
|
||||
Status: "DELETED",
|
||||
UpdatedTime: 1676878820,
|
||||
},
|
||||
ACL: []ACL{
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "timofey_tkachev_1@decs3o",
|
||||
},
|
||||
{
|
||||
Explicit: true,
|
||||
GUID: "",
|
||||
Right: "CXDRAU",
|
||||
Status: "CONFIRMED",
|
||||
Type: "U",
|
||||
UserGroupID: "second_account@decs3o",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
EntryCount: 3,
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about account
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetResourceConsumptionRequest struct for getting resource consumption
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GrantAccessTemplatesRequest struct to share images with account
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of accounts
|
||||
@@ -30,6 +30,11 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Sort by zone id
|
||||
// Default value: 0
|
||||
// Required: false
|
||||
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListAvailableTemplatesRequest struct to list templates who sharedWith include accountId
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListComputesRequest struct to a get list of compute instances
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct to get list of deleted accounts
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListDisksRequest struct to get list of deleted disks
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListFLIPGroupsRequest struct to get list of FLIPGroups
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListRGRequest struct to get list of resource groups
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListVINSRequest struct to get list of VINS
|
||||
|
||||
@@ -46,6 +46,18 @@ type ListResources struct {
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Policy
|
||||
type Policy struct {
|
||||
// Size of the disk
|
||||
DiskSize float64 `json:"disksize"`
|
||||
|
||||
// Max size of the disk
|
||||
DiskSizeMax float64 `json:"disksizemax"`
|
||||
|
||||
// SEPs used
|
||||
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||
}
|
||||
|
||||
type Resource struct {
|
||||
// Number of cores
|
||||
CPU int64 `json:"cpu"`
|
||||
@@ -70,6 +82,9 @@ type Resource struct {
|
||||
|
||||
// SEPs
|
||||
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||
|
||||
// Policies
|
||||
Policies map[string]Policy `json:"policies"`
|
||||
}
|
||||
|
||||
// Disk usage
|
||||
@@ -102,6 +117,15 @@ type ACL struct {
|
||||
UserGroupID string `json:"userGroupId"`
|
||||
}
|
||||
|
||||
// Access Control List with emails field
|
||||
type ACLWithEmails struct {
|
||||
// ACL
|
||||
ACL
|
||||
|
||||
// Emails
|
||||
Emails []string `json:"emails"`
|
||||
}
|
||||
|
||||
// Resource limits
|
||||
type ResourceLimits struct {
|
||||
// CuC
|
||||
@@ -124,6 +148,9 @@ type ResourceLimits struct {
|
||||
|
||||
// GPUUnits
|
||||
GPUUnits float64 `json:"gpu_units"`
|
||||
|
||||
// Storage policies
|
||||
StoragePolicies []StoragePolicy `json:"storage_policy"`
|
||||
}
|
||||
|
||||
// Main information about account
|
||||
@@ -131,12 +158,6 @@ type InfoAccount struct {
|
||||
// DCLocation
|
||||
DCLocation string `json:"DCLocation"`
|
||||
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Access Control List
|
||||
ACL []ACL `json:"acl"`
|
||||
|
||||
// Company
|
||||
Company string `json:"company"`
|
||||
|
||||
@@ -194,6 +215,9 @@ type InfoAccount struct {
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Storage policy ids
|
||||
StoragePolicyIDs []uint64 `json:"storage_policy_ids"`
|
||||
|
||||
// UniqPools
|
||||
UniqPools []string `json:"uniqPools"`
|
||||
|
||||
@@ -205,21 +229,43 @@ type InfoAccount struct {
|
||||
|
||||
// List of VINS IDs
|
||||
VINS []uint64 `json:"vins"`
|
||||
|
||||
// Default zone ID
|
||||
DefaultZoneID uint64 `json:"defaultZoneId"`
|
||||
}
|
||||
|
||||
// Deatailed information about the account zone
|
||||
type ZoneID struct {
|
||||
// ID of zone
|
||||
ID int64 `json:"id"`
|
||||
|
||||
// Name of zone
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// Deatailed information about account
|
||||
type RecordAccount struct {
|
||||
// Main information about account
|
||||
InfoAccount
|
||||
|
||||
// Access Control List
|
||||
ACL []ACLWithEmails `json:"acl"`
|
||||
|
||||
// Zones IDs
|
||||
ZoneIDs []ZoneID `json:"zoneIds"`
|
||||
}
|
||||
|
||||
// More information about account
|
||||
type ItemAccount struct {
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// Access Control List
|
||||
ACL []ACL `json:"acl"`
|
||||
|
||||
// Main information about account
|
||||
InfoAccount
|
||||
|
||||
// Zones
|
||||
ZoneIDs []uint64 `json:"zoneIds"`
|
||||
}
|
||||
|
||||
// List of accounts
|
||||
|
||||
42
pkg/cloudbroker/account/remove_zone.go
Normal file
42
pkg/cloudbroker/account/remove_zone.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/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
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// RestoreRequest struct to restore a deleted account
|
||||
@@ -12,25 +12,21 @@ type RestoreRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Reason of disabling
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Restore restores a deleted account
|
||||
func (a Account) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
||||
func (a Account) Restore(ctx context.Context, req RestoreRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/restore"
|
||||
|
||||
_, err = a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return "", err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return string(result), nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// RevokeAccessTemplatesRequest struct to unshare images with account
|
||||
|
||||
@@ -3,7 +3,7 @@ package account
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/serialization"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// SetCPUAllocationParameterRequest struct for setting CPU allocation parameter
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// SetCPUAllocationRatioRequest struct for setting CPU allocation ratio
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateRequest struct to update account
|
||||
@@ -46,6 +47,10 @@ type UpdateRequest struct {
|
||||
// Required: false
|
||||
SendAccessEmails bool `url:"sendAccessEmails" json:"sendAccessEmails"`
|
||||
|
||||
// Storage policies
|
||||
// Required: false
|
||||
StoragePolicies []StoragePolicy `url:"-" json:"storage_policies,omitempty"`
|
||||
|
||||
// Limit (positive) or disable (0) GPU resources
|
||||
// Required: false
|
||||
GPUUnits int64 `url:"gpu_units,omitempty" json:"gpu_units,omitempty"`
|
||||
@@ -59,6 +64,10 @@ type UpdateRequest struct {
|
||||
// Default: false
|
||||
// Required: false
|
||||
ClearUniqPools bool `url:"clearUniqPools" json:"clearUniqPools"`
|
||||
|
||||
// Default zone ID
|
||||
// Required: false
|
||||
DefaultZoneID uint64 `url:"defaultZoneId,omitempty" json:"defaultZoneId,omitempty"`
|
||||
}
|
||||
|
||||
// Update updates an account name and resource types and limits
|
||||
@@ -70,7 +79,7 @@ func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/account/update"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateComputeFeaturesRequest struct to update advanced compute features
|
||||
@@ -15,7 +15,7 @@ type UpdateComputeFeaturesRequest struct {
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Advanced compute features,
|
||||
// one of: hugepages, numa, cpupin, vfnic, dpdk, changemac
|
||||
// one of: hugepages, numa, cpupin, vfnic, dpdk, changemac, trunk
|
||||
// Required: false
|
||||
ComputeFeatures []string `url:"computeFeatures,omitempty" json:"computeFeatures,omitempty" validate:"omitempty,computeFeatures"`
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateResourceTypesRequest struct to update resource types in account
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateUserRequest struct to update user access rights
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cloudbroker
|
||||
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/apiaccess"
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/apiaccess"
|
||||
|
||||
// Accessing the APIAccess method group
|
||||
func (cb *CloudBroker) APIAccess() *apiaccess.APIAccess {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// APIFindRequest struct for finding apiaccess groups.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package apiaccess
|
||||
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces"
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces"
|
||||
|
||||
// Structure for creating request to APIAccess
|
||||
type APIAccess struct {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
type APIString string
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// APIsIncludeRequest struct for adding api to access group.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// CopyRequest Request for copying apiaccess group.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// CreateRequest struct for creating apiaccess group.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest struct for deleting apiaccess group.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DescUpdateRequest struct for updating apiaccess group description.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get apiaccess group.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of all non deleted apiaccess instances.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// SetDefaultRequest struct for setting default apiaccess group.
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"context"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// SubtractRequest struct for subtracting.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// UnionRequest struct for union.
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateRequest struct for updating apis of apiaccess group.
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// UserListRequest struct for getting a list of users currently included in the specified group.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cloudbroker
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/audit"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/audit"
|
||||
)
|
||||
|
||||
// Accessing the Stack method group
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package audit
|
||||
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces"
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces"
|
||||
|
||||
// Structure for creating request to audit
|
||||
type Audit struct {
|
||||
|
||||
81
pkg/cloudbroker/audit/filter.go
Normal file
81
pkg/cloudbroker/audit/filter.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package audit
|
||||
|
||||
// FilterByID returns ListAudits with specified ID.
|
||||
func (la ListAudits) FilterByID(guid string) ListAudits {
|
||||
predicate := func(ia ItemAudit) bool {
|
||||
return ia.GUID == guid
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByCall returns ListAudits with specified call.
|
||||
func (la ListAudits) FilterByCall(call string) ListAudits {
|
||||
predicate := func(ic ItemAudit) bool {
|
||||
return ic.Call == call
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByCorrelationID returns ListAudits with specified correlation id.
|
||||
func (la ListAudits) FilterByCorrelationID(correlationID string) ListAudits {
|
||||
predicate := func(ic ItemAudit) bool {
|
||||
return ic.CorrelationID == correlationID
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByRemoteAddr returns ListAudits with specified remote address.
|
||||
func (la ListAudits) FilterByRemoteAddr(remoteAddr string) ListAudits {
|
||||
predicate := func(ic ItemAudit) bool {
|
||||
return ic.RemoteAddr == remoteAddr
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByUser returns ListAudits with specified user name.
|
||||
func (la ListAudits) FilterByUser(user string) ListAudits {
|
||||
predicate := func(ic ItemAudit) bool {
|
||||
return ic.User == user
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByStatusCode return ListAudits with specified status code.
|
||||
func (la ListAudits) FilterByStatusCode(statusCode uint64) ListAudits {
|
||||
predicate := func(ic ItemAudit) bool {
|
||||
return ic.StatusCode == statusCode
|
||||
}
|
||||
|
||||
return la.FilterFunc(predicate)
|
||||
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListAudits based on a user-specified predicate.
|
||||
func (la ListAudits) FilterFunc(predicate func(ItemAudit) bool) ListAudits {
|
||||
var result ListAudits
|
||||
|
||||
for _, item := range la.Data {
|
||||
if predicate(item) {
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(result.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemAudit
|
||||
// If none was found, returns an empty struct.
|
||||
func (la ListAudits) FindOne() ItemAudit {
|
||||
if len(la.Data) == 0 {
|
||||
return ItemAudit{}
|
||||
}
|
||||
|
||||
return la.Data[0]
|
||||
}
|
||||
115
pkg/cloudbroker/audit/filter_test.go
Normal file
115
pkg/cloudbroker/audit/filter_test.go
Normal file
@@ -0,0 +1,115 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var audits = ListAudits{
|
||||
Data: []ItemAudit{
|
||||
{
|
||||
Args: "[]",
|
||||
Call: "/restmachine/cloudapi/audit/linkedJobs",
|
||||
GUID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
CorrelationID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
Kwargs: `{\"audit_guid\":\"dd8623a1-a887-48c1-a500-c10210d404cf\"}`,
|
||||
RemoteAddr: "192.168.1.100",
|
||||
ResponseTime: 1,
|
||||
Result: `[]`,
|
||||
StatusCode: 200,
|
||||
Timestamp: 1640995200,
|
||||
TimestampEnd: 1640995201,
|
||||
User: "test@example.com",
|
||||
TTL: "2025-07-31T14:22:57.028000",
|
||||
},
|
||||
{
|
||||
Args: "[]",
|
||||
Call: "/restmachine/cloudapi/audit/test",
|
||||
GUID: "550e8400-e29b-41d4-a716-446655440002",
|
||||
CorrelationID: "550e8400-e29b-41d4-a716-446655440002",
|
||||
Kwargs: `{\"audit_guid\":\"dd8623a1-a887-48c1-a500-c10210d404cf\"}`,
|
||||
RemoteAddr: "192.168.1.105",
|
||||
ResponseTime: 5,
|
||||
Result: `[]`,
|
||||
StatusCode: 400,
|
||||
Timestamp: 1640995200,
|
||||
TimestampEnd: 1640995201,
|
||||
User: "test2@example.com",
|
||||
TTL: "2025-07-31T14:22:57.028000",
|
||||
},
|
||||
},
|
||||
EntryCount: 2,
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := audits.FilterByID("550e8400-e29b-41d4-a716-446655440002").FindOne()
|
||||
|
||||
if actual.GUID != "550e8400-e29b-41d4-a716-446655440002" {
|
||||
t.Fatal("expected GUID 550e8400-e29b-41d4-a716-446655440002, found: ", actual.GUID)
|
||||
}
|
||||
|
||||
actualEmpty := audits.FilterByID("")
|
||||
|
||||
if len(actualEmpty.Data) != 0 {
|
||||
t.Fatal("expected empty, actual: ", len(actualEmpty.Data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByCorrelationID(t *testing.T) {
|
||||
actual := audits.FilterByCorrelationID("550e8400-e29b-41d4-a716-446655440002").FindOne()
|
||||
|
||||
if actual.CorrelationID != "550e8400-e29b-41d4-a716-446655440002" {
|
||||
t.Fatal("expected GUID 550e8400-e29b-41d4-a716-446655440002, found: ", actual.CorrelationID)
|
||||
}
|
||||
|
||||
actualEmpty := audits.FilterByCorrelationID("")
|
||||
|
||||
if len(actualEmpty.Data) != 0 {
|
||||
t.Fatal("expected empty, actual: ", len(actualEmpty.Data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByRemoteAddr(t *testing.T) {
|
||||
actual := audits.FilterByRemoteAddr("192.168.1.100").FindOne()
|
||||
|
||||
if actual.RemoteAddr != "192.168.1.100" {
|
||||
t.Fatal("expected remote address 192.168.1.100, found: ", actual.RemoteAddr)
|
||||
}
|
||||
|
||||
actualEmpty := audits.FilterByRemoteAddr("")
|
||||
|
||||
if len(actualEmpty.Data) != 0 {
|
||||
t.Fatal("expected empty, actual: ", len(actualEmpty.Data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByUser(t *testing.T) {
|
||||
actual := audits.FilterByUser("test@example.com").FindOne()
|
||||
|
||||
if actual.User != "test@example.com" {
|
||||
t.Fatal("expected user test@example.com, found: ", actual.RemoteAddr)
|
||||
}
|
||||
|
||||
actualEmpty := audits.FilterByUser("")
|
||||
|
||||
if len(actualEmpty.Data) != 0 {
|
||||
t.Fatal("expected empty, actual: ", len(actualEmpty.Data))
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByCall(t *testing.T) {
|
||||
actual := audits.FilterByCall("/restmachine/cloudapi/audit/test").FindOne()
|
||||
|
||||
if actual.Call != "/restmachine/cloudapi/audit/test" {
|
||||
t.Fatal("expected call /restmachine/cloudapi/audit/test, found: ", actual.Call)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByStatusCode(t *testing.T) {
|
||||
actual := audits.FilterByStatusCode(200)
|
||||
|
||||
for _, item := range actual.Data {
|
||||
if item.StatusCode != 200 {
|
||||
t.Fatal("expected 200 status code, found: ", item.StatusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get information about account
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// LinkedJobsRequest struct to get information about jobs linked with Audit
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to give list of account audits
|
||||
@@ -50,6 +50,50 @@ type ListRequest struct {
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
|
||||
// Find by resource group id
|
||||
// Required: false
|
||||
RGID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"`
|
||||
|
||||
// Find by compute id
|
||||
// Required: false
|
||||
ComputeID uint64 `url:"compute_id,omitempty" json:"compute_id,omitempty"`
|
||||
|
||||
// Find by account id
|
||||
// Required: false
|
||||
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
|
||||
|
||||
// Find by vins id
|
||||
// Required: false
|
||||
VINSID uint64 `url:"vins_id,omitempty" json:"vins_id,omitempty"`
|
||||
|
||||
// Find by service id
|
||||
// Required: false
|
||||
ServiceID uint64 `url:"service_id,omitempty" json:"service_id,omitempty"`
|
||||
|
||||
// Find by k8s id
|
||||
// Required: false
|
||||
K8SID uint64 `url:"k8s_id,omitempty" json:"k8s_id,omitempty"`
|
||||
|
||||
// Find by flipgroup id
|
||||
// Required: false
|
||||
FLIPGroupID uint64 `url:"flipgroup_id,omitempty" json:"flipgroup_id,omitempty"`
|
||||
|
||||
// Find by load balancer id
|
||||
// Required: false
|
||||
LBID uint64 `url:"lb_id,omitempty" json:"lb_id,omitempty"`
|
||||
|
||||
// Find by sep id
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
|
||||
|
||||
// Find by node id
|
||||
// Required: false
|
||||
NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"`
|
||||
|
||||
// Exclude audit lines from response
|
||||
// Required: false
|
||||
ExcludeAuditLines bool `url:"exclude_audit_lines,omitempty" json:"exclude_audit_lines,omitempty"`
|
||||
}
|
||||
|
||||
// List gets audit records for the specified account object
|
||||
|
||||
@@ -11,6 +11,9 @@ type ItemAudit struct {
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// Correlation ID
|
||||
CorrelationID string `json:"correlation_id"`
|
||||
|
||||
// Kwargs
|
||||
Kwargs string `json:"kwargs"`
|
||||
|
||||
@@ -37,9 +40,6 @@ type ItemAudit struct {
|
||||
|
||||
// TTL
|
||||
TTL string `json:"_ttl"`
|
||||
|
||||
// Tags
|
||||
Tags string `json:"tags"`
|
||||
}
|
||||
|
||||
// List of audits
|
||||
@@ -60,6 +60,9 @@ type RecordAudit struct {
|
||||
// Call
|
||||
Call string `json:"call"`
|
||||
|
||||
// Correlation ID
|
||||
CorrelationID string `json:"correlation_id"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cloudbroker
|
||||
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/backup"
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/backup"
|
||||
|
||||
// Accessing the Backup method group
|
||||
func (cb *CloudBroker) Backup() *backup.Backup {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package backup
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to backup
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// CreateDiskBackupRequest struct for creating disk backup
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
type Disk struct {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteDiskBackupRequest struct for deleting disk backup
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListBackupPathsRequest struct for getting list of backup paths
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// RestoreDiskFromBackupRequest struct for restoring disk from backup
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
type BackupFile struct {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cloudbroker
|
||||
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/pkg/cloudbroker/bservice"
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/pkg/cloudbroker/bservice"
|
||||
|
||||
// Accessing the BService method group
|
||||
func (ca *CloudBroker) BService() *bservice.BService {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package bservice
|
||||
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/interfaces"
|
||||
import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/interfaces"
|
||||
|
||||
// Structure for creating request to bservice
|
||||
type BService struct {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// CreateRequest struct for BasicService
|
||||
@@ -25,6 +25,10 @@ type CreateRequest struct {
|
||||
// SSH key to deploy for the specified user. Same key will be deployed to all computes of the service
|
||||
// Required: false
|
||||
SSHKey string `url:"sshKey,omitempty" json:"sshKey,omitempty"`
|
||||
|
||||
// Zone ID
|
||||
// Required: false
|
||||
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates blank BasicService instance
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest struct to delete basic service
|
||||
@@ -15,8 +15,9 @@ type DeleteRequest struct {
|
||||
ServiceID uint64 `url:"serviceId" json:"serviceId" validate:"required"`
|
||||
|
||||
// If set to False, Basic service will be deleted to recycle bin. Otherwise destroyed immediately
|
||||
// Required: true
|
||||
Permanently bool `url:"permanently" json:"permanently"`
|
||||
// Required: false
|
||||
// Default: false
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
// Delete deletes BasicService instance
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// DisableRequest struct for disable service
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// EnableRequest struct to disable service
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GetRequest struct to get detailed information about service
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupAddRequest struct to create new compute group within BasicService
|
||||
@@ -38,11 +38,9 @@ type GroupAddRequest struct {
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// Compute driver
|
||||
// should be one of:
|
||||
// - KVM_X86
|
||||
// Compute driver like a KVM_X86, etc.
|
||||
// Required: true
|
||||
Driver string `url:"driver" json:"driver" validate:"driver"`
|
||||
Driver string `url:"driver" json:"driver" validate:"required"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// Required: false
|
||||
@@ -75,6 +73,10 @@ type GroupAddRequest struct {
|
||||
//Chipset "i440fx" or "Q35
|
||||
//Required: false
|
||||
Chipset string `url:"chipset,omitempty" json:"chipset,omitempty" validate:"chipset"`
|
||||
|
||||
// ID of the chosen storage policy
|
||||
// Required: false
|
||||
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupComputeRemoveRequest struct to remove group compute
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupGetRequest struct to get detailed information about Compute Group
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupParentRemoveRequest struct to remove parent Compute Group
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupParentAddRequest struct to add parent Compute Group relation to the specified Compute Group
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupRemoveRequest struct for destroy the specified Compute Group
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupResizeRequest struct to resize the group
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupStartRequest struct to start the specified Compute Group
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupStopRequest struct to stop the specified Compute Group
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupUpdateRequest struct to update existing Compute group
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupUpdateExtNetRequest struct to update External Network settings
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// GroupUpdateVINSRequest struct to update VINS settings
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of BasicService instances
|
||||
@@ -42,6 +42,11 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
AccountName string `url:"accountName,omitempty" json:"accountName,omitempty"`
|
||||
|
||||
// Sort by zone id
|
||||
// Default value: 0
|
||||
// Required: false
|
||||
ZoneID uint64 `url:"zone_id,omitempty" json:"zone_id,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct to get list of deleted BasicService instances
|
||||
|
||||
42
pkg/cloudbroker/bservice/migrate_to_zone.go
Normal file
42
pkg/cloudbroker/bservice/migrate_to_zone.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package bservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/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
|
||||
}
|
||||
@@ -88,6 +88,9 @@ type RecordBasicService struct {
|
||||
|
||||
// Whether user controlled
|
||||
UserManaged bool `json:"userManaged"`
|
||||
|
||||
// Zone ID
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
}
|
||||
|
||||
// List of Groups
|
||||
@@ -254,6 +257,9 @@ type ItemBasicService struct {
|
||||
|
||||
// User Managed or not
|
||||
UserManaged bool `json:"userManaged"`
|
||||
|
||||
// Zone ID
|
||||
ZoneID uint64 `json:"zoneId"`
|
||||
}
|
||||
|
||||
// List of Snapshots
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// RestoreRequest struct to restore BasicService instance
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// SnapshotCreateRequest struct to create snapshot
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// SnapshotDeleteRequest struct to delete snapshot
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// SnapshotListRequest struct to get list of existing snapshots
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// SnapshotRollbackRequest struct to rollback snapshot
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// StartRequest struct to start service
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v11/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
||||
)
|
||||
|
||||
// StopRequest struct to stop service
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user