v1.8.0
This commit is contained in:
@@ -54,6 +54,11 @@ type CreateRequest struct {
|
||||
// i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
|
||||
// Required: false
|
||||
UniqPools []string `url:"uniqPools,omitempty" json:"uniqPools,omitempty"`
|
||||
|
||||
// Advanced compute features,
|
||||
// one of: hugepages, numa, cpupin, vfnic
|
||||
// Required: false
|
||||
ComputeFeatures []string `url:"computeFeatures,omitempty" json:"computeFeatures,omitempty" validate:"omitempty,computeFeatures"`
|
||||
}
|
||||
|
||||
// Create creates account
|
||||
|
||||
42
pkg/cloudbroker/account/grant_access_templates.go
Normal file
42
pkg/cloudbroker/account/grant_access_templates.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GrantAccessTemplatesRequest struct to share images with account
|
||||
type GrantAccessTemplatesRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// list of image IDs
|
||||
// Required: true
|
||||
ImageIDs []uint64 `url:"imageIds" json:"imageIds" validate:"required"`
|
||||
}
|
||||
|
||||
// GrantAccessTemplates shares specified images with specified account
|
||||
func (a Account) GrantAccessTemplates(ctx context.Context, req GrantAccessTemplatesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/grantAccessTemplates"
|
||||
|
||||
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,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of accounts
|
||||
@@ -24,6 +26,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,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"`
|
||||
@@ -35,6 +41,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of all accounts the user has access to as a ListAccounts struct
|
||||
func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, error) {
|
||||
|
||||
res, err := a.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -52,6 +59,11 @@ func (a Account) List(ctx context.Context, req ListRequest) (*ListAccounts, erro
|
||||
|
||||
// ListRaw gets list of all accounts the user has access to as an array of bytes
|
||||
func (a Account) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/list"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
41
pkg/cloudbroker/account/list_available_templates.go
Normal file
41
pkg/cloudbroker/account/list_available_templates.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListAvailableTemplatesRequest struct to list templates who sharedWith include accountId
|
||||
type ListAvailableTemplatesRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
}
|
||||
|
||||
// ListAvailableTemplates lists templates who sharedWith include accountId
|
||||
func (a Account) ListAvailableTemplates(ctx context.Context, req ListAvailableTemplatesRequest) ([]uint64, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/listAvailableTemplates"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
list := make([]uint64, 0)
|
||||
|
||||
err = json.Unmarshal(res, &list)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return list, nil
|
||||
}
|
||||
@@ -46,6 +46,10 @@ type ListComputesRequest struct {
|
||||
// Required: false
|
||||
ExtNetID uint64 `url:"extNetId,omitempty" json:"extNetId,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"`
|
||||
@@ -57,6 +61,7 @@ type ListComputesRequest struct {
|
||||
|
||||
// ListComputes gets list of all compute instances under specified account, accessible by the user
|
||||
func (a Account) ListComputes(ctx context.Context, req ListComputesRequest) (*ListComputes, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct to get list of deleted accounts
|
||||
@@ -20,6 +22,10 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
ACL string `url:"acl,omitempty" json:"acl,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"`
|
||||
@@ -31,6 +37,11 @@ type ListDeletedRequest struct {
|
||||
|
||||
// ListDeleted gets list all deleted accounts the user has access to
|
||||
func (a Account) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListAccounts, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/listDeleted"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -30,6 +30,10 @@ type ListDisksRequest struct {
|
||||
// Required: false
|
||||
Type string `url:"type,omitempty" json:"type,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"`
|
||||
@@ -41,6 +45,7 @@ type ListDisksRequest struct {
|
||||
|
||||
// ListDisks gets list of all currently unattached disks under specified account
|
||||
func (a Account) ListDisks(ctx context.Context, req ListDisksRequest) (*ListDisks, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -38,6 +38,10 @@ type ListFLIPGroupsRequest struct {
|
||||
// Required: false
|
||||
FLIPGroupID uint64 `url:"flipGroupId,omitempty" json:"flipGroupId,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"`
|
||||
@@ -49,6 +53,7 @@ type ListFLIPGroupsRequest struct {
|
||||
|
||||
// ListFLIPGroups gets list of all FLIPGroups under specified account, accessible by the user
|
||||
func (a Account) ListFLIPGroups(ctx context.Context, req ListFLIPGroupsRequest) (*ListFLIPGroups, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -41,10 +41,15 @@ type ListRGRequest struct {
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
}
|
||||
|
||||
// ListRG gets list of all resource groups under specified account, accessible by the user
|
||||
func (a Account) ListRG(ctx context.Context, req ListRGRequest) (*ListRG, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -30,6 +30,10 @@ type ListVINSRequest struct {
|
||||
// Required: false
|
||||
ExtIP string `url:"extIp,omitempty" json:"extIp,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"`
|
||||
@@ -41,6 +45,7 @@ type ListVINSRequest struct {
|
||||
|
||||
// ListVINS gets list of all ViNSes under specified account, accessible by the user
|
||||
func (a Account) ListVINS(ctx context.Context, req ListVINSRequest) (*ListVINS, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -143,6 +143,9 @@ type InfoAccount struct {
|
||||
// Company URL
|
||||
CompanyURL string `json:"companyurl"`
|
||||
|
||||
// Compute Features
|
||||
ComputeFeatures []string `json:"computeFeatures"`
|
||||
|
||||
// CPU allocation parameter
|
||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||
|
||||
@@ -530,6 +533,12 @@ type ItemVINS struct {
|
||||
// External IP
|
||||
ExternalIP string `json:"externalIP"`
|
||||
|
||||
// Extnet ID
|
||||
ExtnetId uint64 `json:"extnetId"`
|
||||
|
||||
// Free IPs
|
||||
FreeIPs uint64 `json:"freeIPs"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
|
||||
42
pkg/cloudbroker/account/revoke_access_templates.go
Normal file
42
pkg/cloudbroker/account/revoke_access_templates.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RevokeAccessTemplatesRequest struct to unshare images with account
|
||||
type RevokeAccessTemplatesRequest struct {
|
||||
// ID an account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// list of image IDs
|
||||
// Required: true
|
||||
ImageIDs []uint64 `url:"imageIds" json:"imageIds" validate:"required"`
|
||||
}
|
||||
|
||||
// RevokeAccessTemplates unshares specified images with specified account
|
||||
func (a Account) RevokeAccessTemplates(ctx context.Context, req RevokeAccessTemplatesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/revokeAccessTemplates"
|
||||
|
||||
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
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
type SetCPUAllocationParameterRequest struct {
|
||||
// Account ID
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accoutnId" validate:"required"`
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// CPU allocation parameter.
|
||||
// If "strict" VM can't be run if not enough CPU resources.
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
type SetCPUAllocationRatioRequest struct {
|
||||
// Account ID
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accoutnId" validate:"required"`
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// CPU allocation ratio, i.e. one pCPU = ratio*vCPU
|
||||
// if don't set, default value = 0
|
||||
|
||||
43
pkg/cloudbroker/account/update_compute_features.go
Normal file
43
pkg/cloudbroker/account/update_compute_features.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateComputeFeaturesRequest struct to update advanced compute features
|
||||
type UpdateComputeFeaturesRequest struct {
|
||||
// ID of account
|
||||
// Required: true
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
|
||||
// Advanced compute features,
|
||||
// one of: hugepages, numa, cpupin, vfnic
|
||||
// Required: false
|
||||
ComputeFeatures []string `url:"computeFeatures,omitempty" json:"computeFeatures,omitempty" validate:"omitempty,computeFeatures"`
|
||||
}
|
||||
|
||||
// UpdateComputeFeatures updates advanced compute features
|
||||
func (a Account) UpdateComputeFeatures(ctx context.Context, req UpdateComputeFeaturesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/updateComputeFeatures"
|
||||
|
||||
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,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of all non deleted apiaccess instances.
|
||||
@@ -32,6 +34,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
CreatedBefore uint64 `url:"createdBefore,omitempty" json:"createdBefore,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"`
|
||||
@@ -43,6 +49,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of all non deleted apiaccess instances as a ListAPIAccess struct
|
||||
func (a APIAccess) List(ctx context.Context, req ListRequest) (*ListAPIAccess, error) {
|
||||
|
||||
res, err := a.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -60,6 +67,11 @@ func (a APIAccess) List(ctx context.Context, req ListRequest) (*ListAPIAccess, e
|
||||
|
||||
// ListRaw gets list of all non deleted apiaccess instances as an array of bytes
|
||||
func (a APIAccess) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/list"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,10 +4,16 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct for getting list of all deleted apiaccess instances.
|
||||
type ListDeletedRequest struct {
|
||||
// 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"`
|
||||
@@ -19,6 +25,11 @@ type ListDeletedRequest struct {
|
||||
|
||||
// ListDeleted gets list of all deleted apiaccess instances.
|
||||
func (a APIAccess) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListAPIAccess, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/apiaccess/listDeleted"
|
||||
|
||||
info := ListAPIAccess{}
|
||||
|
||||
@@ -124,7 +124,7 @@ type CloudBrokerEndpoints struct {
|
||||
Health []string `json:"health,omitempty"`
|
||||
IaaS []string `json:"iaas,omitempty"`
|
||||
Image []string `json:"image,omitempty"`
|
||||
Job []string `json:"job,omitempty"`
|
||||
Job interface{} `json:"job,omitempty"`
|
||||
K8CI []string `json:"k8ci,omitempty"`
|
||||
K8S []string `json:"k8s,omitempty"`
|
||||
KVMPPC []string `json:"kvmppc,omitempty"`
|
||||
@@ -141,7 +141,7 @@ type CloudBrokerEndpoints struct {
|
||||
PGPU []string `json:"pgpu,omitempty"`
|
||||
Prometheus []string `json:"prometheus,omitempty"`
|
||||
QOS []string `json:"qos,omitempty"`
|
||||
Resmon []string `json:"resmon,omitempty"`
|
||||
Resmon interface{} `json:"resmon,omitempty"`
|
||||
RG []string `json:"rg,omitempty"`
|
||||
Sep []string `json:"sep,omitempty"`
|
||||
Stack []string `json:"stack,omitempty"`
|
||||
|
||||
@@ -13,6 +13,14 @@ type UserListRequest struct {
|
||||
// APIAccess group ID
|
||||
// Required: true
|
||||
APIAccessID uint64 `url:"apiaccessId" json:"apiaccessId" validate:"required"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// UserList gets a list of users currently included in the specified group.
|
||||
|
||||
@@ -8,8 +8,8 @@ type Audit struct {
|
||||
}
|
||||
|
||||
// Builder for audit endpoint
|
||||
func New(client interfaces.Caller) *Audit {
|
||||
func New(client interfaces.Caller) *Audit{
|
||||
return &Audit{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,4 +43,4 @@ func (a Audit) GetRawLinkedJobs(ctx context.Context, req LinkedJobsRequest) ([]b
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to give list of account audits
|
||||
@@ -25,9 +27,17 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
Call string `url:"call,omitempty" json:"call,omitempty"`
|
||||
|
||||
// Find by HTTP status code
|
||||
// Find by HTTP min status code
|
||||
// Required: false
|
||||
StatusCode uint64 `url:"statusCode,omitempty" json:"statusCode,omitempty"`
|
||||
MinStatusCode uint64 `url:"minStatusCode,omitempty" json:"minStatusCode,omitempty"`
|
||||
|
||||
// Find by HTTP max status code
|
||||
// Required: false
|
||||
MaxStatusCode uint64 `url:"maxStatusCode,omitempty" json:"maxStatusCode,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
|
||||
@@ -40,6 +50,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets audit records for the specified account object
|
||||
func (a Audit) List(ctx context.Context, req ListRequest) (*ListAudits, error) {
|
||||
|
||||
res, err := a.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -57,6 +68,11 @@ func (a Audit) List(ctx context.Context, req ListRequest) (*ListAudits, error) {
|
||||
|
||||
// ListRaw gets list of audit records an array of bytes
|
||||
func (a Audit) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/audit/list"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -82,6 +82,9 @@ type ItemLinkedJobs struct {
|
||||
// CMD
|
||||
CMD string `json:"cmd"`
|
||||
|
||||
// GUID
|
||||
GUID string `json:"guid"`
|
||||
|
||||
// NID
|
||||
NID uint64 `json:"nid"`
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
@@ -15,6 +16,7 @@ type ListBackupPathsRequest struct {
|
||||
|
||||
// ListBackupPaths gets list of backup paths
|
||||
func (b Backup) ListBackupPaths(ctx context.Context, req ListBackupPathsRequest) ([]string, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -13,10 +13,6 @@ type AffinityRelationsRequest struct {
|
||||
// ID of the compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Affinity group label
|
||||
// Required: false
|
||||
AffinityLabel string `url:"affinityLabel,omitempty" json:"affinityLabel,omitempty"`
|
||||
}
|
||||
|
||||
// AffinityRelations gets dict of computes divided by affinity and anti affinity rules
|
||||
|
||||
@@ -41,6 +41,7 @@ type AffinityRuleAddRequest struct {
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ type AffinityRuleRemoveRequest struct {
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ type AntiAffinityRuleAddRequest struct {
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ type AntiAffinityRuleRemoveRequest struct {
|
||||
|
||||
// Value that must match the key to be taken into account when analyzing this rule
|
||||
// Required: false
|
||||
// Not required on purpose: despite required tag on platform, empty string is allowed
|
||||
Value string `url:"value" json:"value"`
|
||||
}
|
||||
|
||||
|
||||
42
pkg/cloudbroker/compute/boot_disk_set.go
Normal file
42
pkg/cloudbroker/compute/boot_disk_set.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// BootDiskSetRequest struct to set boot disk for compute
|
||||
type BootDiskSetRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// ID of the disk to set as boot
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
// BootDiskSet sets boot disk for compute
|
||||
func (c Compute) BootDiskSet(ctx context.Context, req BootDiskSetRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/bootDiskSet"
|
||||
|
||||
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
|
||||
}
|
||||
112
pkg/cloudbroker/compute/create_template_from_blank.go
Normal file
112
pkg/cloudbroker/compute/create_template_from_blank.go
Normal file
@@ -0,0 +1,112 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// CreateTemplateFromBlankRequest struct to create template from boot disk of current compute
|
||||
type CreateTemplateFromBlankRequest struct {
|
||||
// ID of the compute to create template from
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// Name of the rescue disk
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Boot type of image BIOS or UEFI
|
||||
// Required: true
|
||||
BootType string `url:"boottype" json:"boottype" validate:"imageBootType"`
|
||||
|
||||
// Image type linux, windows or other
|
||||
// Required: true
|
||||
ImageType string `url:"imagetype" json:"imagetype" validate:"imageType"`
|
||||
|
||||
// Username for the image
|
||||
// Required: false
|
||||
Username string `url:"username,omitempty" json:"username,omitempty"`
|
||||
|
||||
// Password for the image
|
||||
// Required: false
|
||||
Password string `url:"password,omitempty" json:"password,omitempty"`
|
||||
|
||||
// Account ID to make the image exclusive
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// SEP ID
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool for image create
|
||||
// Required: false
|
||||
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||
|
||||
// Does this machine supports hot resize
|
||||
// Default: false
|
||||
// Required: false
|
||||
HotResize bool `url:"hotresize" json:"hotresize"`
|
||||
}
|
||||
|
||||
type wrapperCreateTemplateFromBlankRequest struct {
|
||||
CreateTemplateFromBlankRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// CreateTemplateFromBlank creates template from boot disk of current compute in sync mode.
|
||||
// It returns id of created compute and error.
|
||||
func (c Compute) CreateTemplateFromBlank(ctx context.Context, req CreateTemplateFromBlankRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateTemplateFromBlankRequest{
|
||||
CreateTemplateFromBlankRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/createTemplateFromBlank"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateTemplateFromBlankAsync creates template from boot disk of current compute in async mode.
|
||||
// It returns guid of task and error.
|
||||
func (c Compute) CreateTemplateFromBlankAsync(ctx context.Context, req CreateTemplateFromBlankRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateTemplateFromBlankRequest{
|
||||
CreateTemplateFromBlankRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/createTemplateFromBlank"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
result := strings.ReplaceAll(string(res), "\"", "")
|
||||
|
||||
return result, nil
|
||||
}
|
||||
53
pkg/cloudbroker/compute/disk_migrate.go
Normal file
53
pkg/cloudbroker/compute/disk_migrate.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DiskMigrateRequest struct to migrate compute's disk to target disk
|
||||
type DiskMigrateRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// ID source disk
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// ID target disk
|
||||
// Required: true
|
||||
TargetDiskID uint64 `url:"targetDiskId" json:"targetDiskId" validate:"required"`
|
||||
|
||||
// Migration mode. 1 - Data migration and domain update were already completed by third-party software.
|
||||
// Use this if target disk already connected to compute and you only need to save changes for next reboot.
|
||||
// Required: true
|
||||
Mode int64 `url:"mode" json:"mode" validate:"required"`
|
||||
}
|
||||
|
||||
// DiskMigrate - migrate compute's disk to target disk. Source disk will be detached, target disk will be attached to the same PCI slot.
|
||||
// (WARNING) Current realisation is limited. No actual data migration will be performed.
|
||||
// Use this API if target disk already connected to compute and you only need to save changes for next reboot (mode: 1).
|
||||
func (c Compute) DiskMigrate(ctx context.Context, req DiskMigrateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/diskMigrate"
|
||||
|
||||
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
|
||||
}
|
||||
46
pkg/cloudbroker/compute/disk_switch_to_replication.go
Normal file
46
pkg/cloudbroker/compute/disk_switch_to_replication.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DiskSwitchToReplicationRequest struct to switch disk to it's replication
|
||||
type DiskSwitchToReplicationRequest struct {
|
||||
// ID of compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// ID of the disk to switch
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// Delete replication relationship
|
||||
// Required: false
|
||||
StopReplication bool `url:"stopReplication" json:"stopReplication"`
|
||||
}
|
||||
|
||||
// DiskSwitchToReplication switches disk to it's replication
|
||||
func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToReplicationRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/diskSwitchToReplication"
|
||||
|
||||
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
|
||||
}
|
||||
40
pkg/cloudbroker/compute/get_custom_fields.go
Normal file
40
pkg/cloudbroker/compute/get_custom_fields.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GetCustomFieldsRequest struct to get Compute's customFields
|
||||
type GetCustomFieldsRequest struct {
|
||||
// Compute ID
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
}
|
||||
|
||||
// GetCustomFields gets Compute's customFields
|
||||
func (c Compute) GetCustomFields(ctx context.Context, req GetCustomFieldsRequest) (interface{}, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/getCustomFields"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var info interface{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of available computes
|
||||
@@ -52,6 +54,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,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"`
|
||||
@@ -64,6 +70,7 @@ type ListRequest struct {
|
||||
// List gets list of the available computes as a ListComputes struct.
|
||||
// Filtering based on status is possible
|
||||
func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, error) {
|
||||
|
||||
res, err := c.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -81,6 +88,11 @@ func (c Compute) List(ctx context.Context, req ListRequest) (*ListComputes, erro
|
||||
|
||||
// ListRaw gets list of the available computes as an array of bytes
|
||||
func (c Compute) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/list"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct to get deleted computes list
|
||||
@@ -44,6 +46,10 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
ExtNetID uint64 `url:"extNetId,omitempty" json:"extNetId,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"`
|
||||
@@ -55,6 +61,11 @@ type ListDeletedRequest struct {
|
||||
|
||||
// ListDeleted gets list all deleted computes
|
||||
func (c Compute) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListComputes, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/listDeleted"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -22,14 +22,18 @@ type ListPCIDeviceRequest struct {
|
||||
// Required: false
|
||||
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
||||
|
||||
// Find by type
|
||||
// Find by name
|
||||
// Required: false
|
||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,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"`
|
||||
@@ -41,6 +45,7 @@ type ListPCIDeviceRequest struct {
|
||||
|
||||
// ListPCIDevice gets list of PCI device
|
||||
func (c Compute) ListPCIDevice(ctx context.Context, req ListPCIDeviceRequest) (*ListPCIDevices, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -26,6 +26,10 @@ type ListVGPURequest struct {
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,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"`
|
||||
@@ -41,6 +45,7 @@ type ListVGPURequest struct {
|
||||
|
||||
// ListVGPU gets list of GPU for compute
|
||||
func (c Compute) ListVGPU(ctx context.Context, req ListVGPURequest) (*ListVGPUs, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -439,6 +439,9 @@ type ItemDisk struct {
|
||||
// Reality device number
|
||||
RealityDeviceNumber uint64 `json:"realityDeviceNumber"`
|
||||
|
||||
// Replication
|
||||
Replication interface{} `json:"replication"`
|
||||
|
||||
// Reference ID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
@@ -496,6 +499,9 @@ type ItemInterface struct {
|
||||
// Default GW
|
||||
DefGW string `json:"defGw"`
|
||||
|
||||
// Enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// FLIPGroup ID
|
||||
FLIPGroupID uint64 `json:"flipgroupId"`
|
||||
|
||||
@@ -523,6 +529,9 @@ type ItemInterface struct {
|
||||
// Network type
|
||||
NetType string `json:"netType"`
|
||||
|
||||
// NodeID
|
||||
NodeID int64 `json:"nodeId"`
|
||||
|
||||
// PCI slot
|
||||
PCISlot int64 `json:"pciSlot"`
|
||||
|
||||
@@ -604,6 +613,9 @@ type InfoCompute struct {
|
||||
// Compute CI ID
|
||||
ComputeCIID uint64 `json:"computeciId"`
|
||||
|
||||
// CPU Pin
|
||||
CPUPin bool `json:"cpupin"`
|
||||
|
||||
// Number of CPU
|
||||
CPUs uint64 `json:"cpus"`
|
||||
|
||||
@@ -637,6 +649,9 @@ type InfoCompute struct {
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// HPBacked
|
||||
HPBacked bool `json:"hpBacked"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
@@ -667,6 +682,12 @@ type InfoCompute struct {
|
||||
// Need reboot
|
||||
NeedReboot bool `json:"needReboot"`
|
||||
|
||||
// Numa Affinity
|
||||
NumaAffinity string `json:"numaAffinity"`
|
||||
|
||||
//NumaNodeId
|
||||
NumaNodeId int64 `json:"numaNodeId"`
|
||||
|
||||
// List OS users
|
||||
OSUsers ListOSUsers `json:"osUsers"`
|
||||
|
||||
@@ -742,11 +763,215 @@ type InfoCompute struct {
|
||||
|
||||
// Detailed information about compute
|
||||
type RecordCompute struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Account name
|
||||
AccountName string `json:"accountName"`
|
||||
|
||||
// Access Control List
|
||||
ACL []interface{} `json:"acl"`
|
||||
|
||||
// Affinity label
|
||||
AffinityLabel string `json:"affinityLabel"`
|
||||
|
||||
// Affinity rules
|
||||
AffinityRules ListRules `json:"affinityRules"`
|
||||
|
||||
// Affinity weight
|
||||
AffinityWeight uint64 `json:"affinityWeight"`
|
||||
|
||||
// Anti affinity rules
|
||||
AntiAffinityRules ListRules `json:"antiAffinityRules"`
|
||||
|
||||
// Architecture
|
||||
Arch string `json:"arch"`
|
||||
|
||||
// Boot order
|
||||
BootOrder []string `json:"bootOrder"`
|
||||
|
||||
// Boot disk size
|
||||
BootDiskSize uint64 `json:"bootdiskSize"`
|
||||
|
||||
// cd Image Id
|
||||
CdImageId uint64 `json:"cdImageId"`
|
||||
|
||||
// Clone reference
|
||||
CloneReference uint64 `json:"cloneReference"`
|
||||
|
||||
// List clone IDs
|
||||
Clones []uint64 `json:"clones"`
|
||||
|
||||
// Compute CI ID
|
||||
ComputeCIID uint64 `json:"computeciId"`
|
||||
|
||||
// CPU Pin
|
||||
CPUPin bool `json:"cpupin"`
|
||||
|
||||
// Number of CPU
|
||||
CPUs uint64 `json:"cpus"`
|
||||
|
||||
// Created by
|
||||
CreatedBy string `json:"createdBy"`
|
||||
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Custom fields
|
||||
CustomFields map[string]interface{} `json:"customFields"`
|
||||
|
||||
// Deleted by
|
||||
DeletedBy string `json:"deletedBy"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// Devices
|
||||
Devices interface{} `json:"devices"`
|
||||
|
||||
// List disks
|
||||
Disks ListDisks `json:"disks"`
|
||||
|
||||
// Main information about compute
|
||||
InfoCompute
|
||||
// Driver
|
||||
Driver string `json:"driver"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// HPBacked
|
||||
HPBacked bool `json:"hpBacked"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// ImageName
|
||||
ImageName string `json:"imageName"`
|
||||
|
||||
// List interfaces
|
||||
Interfaces ListInterfaces `json:"interfaces"`
|
||||
|
||||
// Lock status
|
||||
LockStatus string `json:"lockStatus"`
|
||||
|
||||
// Manager ID
|
||||
ManagerID uint64 `json:"managerId"`
|
||||
|
||||
// Manager type
|
||||
ManagerType string `json:"managerType"`
|
||||
|
||||
// Migration job
|
||||
MigrationJob uint64 `json:"migrationjob"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Natable VINS ID
|
||||
NatableVINSID uint64 `json:"natableVinsId"`
|
||||
|
||||
// Natable VINS IP
|
||||
NatableVINSIP string `json:"natableVinsIp"`
|
||||
|
||||
// Natable VINS Name
|
||||
NatableVINSName string `json:"natableVinsName"`
|
||||
|
||||
// Natable VINS network
|
||||
NatableVINSNetwork string `json:"natableVinsNetwork"`
|
||||
|
||||
// Natable VINS network name
|
||||
NatableVINSNetworkName string `json:"natableVinsNetworkName"`
|
||||
|
||||
// Need reboot
|
||||
NeedReboot bool `json:"needReboot"`
|
||||
|
||||
// NumaAffinity
|
||||
NumaAffinity string `json:"numaAffinity"`
|
||||
|
||||
//NumaNodeId
|
||||
NumaNodeId int64 `json:"numaNodeId"`
|
||||
|
||||
// List OS users
|
||||
OSUsers ListOSUsers `json:"osUsers"`
|
||||
|
||||
// Pinned
|
||||
Pinned bool `json:"pinned"`
|
||||
|
||||
// Number of RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
// Reference ID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// Registered
|
||||
Registered bool `json:"registered"`
|
||||
|
||||
// Resource name
|
||||
ResName string `json:"resName"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Resource group name
|
||||
RGName string `json:"rgName"`
|
||||
|
||||
// SnapSets
|
||||
SnapSets ListSnapshots `json:"snapSets"`
|
||||
|
||||
// Stack ID
|
||||
StackID uint64 `json:"stackId"`
|
||||
|
||||
// Stack name
|
||||
StackName string `json:"stackName"`
|
||||
|
||||
// Stateless SEP ID
|
||||
StatelessSEPID int64 `json:"statelessSepId"`
|
||||
|
||||
// Stateless SEP Type
|
||||
StatelessSEPType string `json:"statelessSepType"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Tags
|
||||
Tags map[string]interface{} `json:"tags"`
|
||||
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// Total disk size
|
||||
TotalDiskSize uint64 `json:"totalDisksSize"`
|
||||
|
||||
// Updated by
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// User managed
|
||||
UserManaged bool `json:"userManaged"`
|
||||
|
||||
// Userdata
|
||||
Userdata interface{} `json:"userdata"`
|
||||
|
||||
// List VGPU IDs
|
||||
VGPUs []uint64 `json:"vgpus"`
|
||||
|
||||
// Virtual image ID
|
||||
VirtualImageID uint64 `json:"virtualImageId"`
|
||||
|
||||
// VirtualImageName
|
||||
VirtualImageName string `json:"virtualImageName"`
|
||||
}
|
||||
|
||||
// Information about of disk IDs
|
||||
@@ -781,11 +1006,11 @@ type ListComputes struct {
|
||||
// Data
|
||||
Data []ItemCompute `json:"data"`
|
||||
|
||||
// Entru Count
|
||||
EntryCount uint64 `json:"entrycount"`
|
||||
// EntryCount
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Short information about audir
|
||||
// Short information about audit
|
||||
type ItemAudit struct {
|
||||
// Epoch
|
||||
Epoch float64 `json:"epoch"`
|
||||
@@ -848,8 +1073,65 @@ type ListPCIDevices struct {
|
||||
// List VGPUs
|
||||
type ListVGPUs struct {
|
||||
// Data
|
||||
Data []interface{} `json:"data"`
|
||||
Data []ItemVGPU `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Main information about vgpu device
|
||||
type ItemVGPU struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Created Time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Deleted Time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// GID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Last Claimed By
|
||||
LastClaimedBy uint64 `json:"lastClaimedBy"`
|
||||
|
||||
// Last Update Time
|
||||
LastUpdateTime uint64 `json:"lastUpdateTime"`
|
||||
|
||||
// Mode
|
||||
Mode string `json:"mode"`
|
||||
|
||||
// PCI Slot
|
||||
PCISlot uint64 `json:"pciSlot"`
|
||||
|
||||
// PGPUID
|
||||
PGPUID uint64 `json:"pgpuid"`
|
||||
|
||||
// Profile ID
|
||||
ProfileID uint64 `json:"profileId"`
|
||||
|
||||
// RAM
|
||||
RAM uint64 `json:"ram"`
|
||||
|
||||
// Reference ID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// RG ID
|
||||
RGID uint64 `json:"rgId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// VM ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ type PFWAddRequest struct {
|
||||
PublicPortEnd int64 `url:"publicPortEnd,omitempty" json:"publicPortEnd,omitempty"`
|
||||
|
||||
// Internal base port number
|
||||
// Required: true
|
||||
LocalBasePort uint64 `url:"localBasePort" json:"localBasePort" validate:"required"`
|
||||
// Required: false
|
||||
LocalBasePort uint64 `url:"localBasePort,omitempty" json:"localBasePort,omitempty"`
|
||||
|
||||
// Network protocol
|
||||
// Should be one of:
|
||||
|
||||
@@ -33,6 +33,16 @@ type ResizeRequest struct {
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r ResizeRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// Resize resizes compute instance
|
||||
func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
|
||||
127
pkg/cloudbroker/disks/from_platform_disk.go
Normal file
127
pkg/cloudbroker/disks/from_platform_disk.go
Normal file
@@ -0,0 +1,127 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// FromPlatformDiskRequest struct to create template from platform disk
|
||||
type FromPlatformDiskRequest struct {
|
||||
// ID of the disk
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// Name of the rescue disk
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// Boot type of image BIOS or UEFI
|
||||
// Required: true
|
||||
BootType string `url:"boottype" json:"boottype" validate:"imageBootType"`
|
||||
|
||||
// Image type linux, windows or other
|
||||
// Required: true
|
||||
ImageType string `url:"imagetype" json:"imagetype" validate:"imageType"`
|
||||
|
||||
// Binary architecture of this image
|
||||
// Should be:
|
||||
// - X86_64
|
||||
// - PPC64_LE
|
||||
// Required: true
|
||||
Architecture string `url:"architecture" json:"architecture" validate:"imageArchitecture"`
|
||||
|
||||
// Username for the image
|
||||
// Required: false
|
||||
Username string `url:"username,omitempty" json:"username,omitempty"`
|
||||
|
||||
// Password for the image
|
||||
// Required: false
|
||||
Password string `url:"password,omitempty" json:"password,omitempty"`
|
||||
|
||||
// Account ID to make the image exclusive
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// SEP ID
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool for image create
|
||||
// Required: false
|
||||
PoolName string `url:"poolName,omitempty" json:"poolName,omitempty"`
|
||||
|
||||
// List of types of compute suitable for image
|
||||
// Example: [ "KVM_X86" ]
|
||||
// Required: false
|
||||
Drivers []string `url:"drivers" json:"drivers" validate:"min=1,max=2,imageDrivers"`
|
||||
|
||||
// Does this machine supports hot resize
|
||||
// Required: false
|
||||
HotResize bool `url:"hotresize" json:"hotresize"`
|
||||
|
||||
// Bootable image
|
||||
// Required: true
|
||||
Bootable bool `url:"bootable" json:"bootable"`
|
||||
}
|
||||
|
||||
type wrapperFromPlatformDiskRequest struct {
|
||||
FromPlatformDiskRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// FromPlatformDisk creates template from platform disk in sync mode.
|
||||
// It returns id of created disk and error.
|
||||
func (d Disks) FromPlatformDisk(ctx context.Context, req FromPlatformDiskRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/fromPlatformDisk"
|
||||
|
||||
reqWrapped := wrapperFromPlatformDiskRequest{
|
||||
FromPlatformDiskRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// FromPlatformDiskAsync creates template from platform disk in async mode.
|
||||
// It returns guid of task and error.
|
||||
func (d Disks) FromPlatformDiskAsync(ctx context.Context, req FromPlatformDiskRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/fromPlatformDisk"
|
||||
|
||||
reqWrapped := wrapperFromPlatformDiskRequest{
|
||||
FromPlatformDiskRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
result := strings.ReplaceAll(string(res), "\"", "")
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list/list_deleted of disks
|
||||
@@ -48,6 +50,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,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"`
|
||||
@@ -76,6 +82,11 @@ func (d Disks) List(ctx context.Context, req ListRequest) (*ListDisks, error) {
|
||||
|
||||
// ListRaw gets list of the created disks belonging to an account as an array of bytes
|
||||
func (d Disks) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/list"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct to get list of deleted disks
|
||||
@@ -36,6 +38,10 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
Type string `url:"type,omitempty" json:"type,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"`
|
||||
@@ -47,6 +53,11 @@ type ListDeletedRequest struct {
|
||||
|
||||
// ListDeleted gets list of the deleted disks based on filter
|
||||
func (d Disks) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListDisks, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/listDeleted"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListTypesRequest struct to get list of types of disks
|
||||
@@ -12,6 +14,10 @@ type ListTypesRequest struct {
|
||||
// Required: false
|
||||
Detailed bool `url:"detailed" json:"detailed"`
|
||||
|
||||
// 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"`
|
||||
@@ -23,6 +29,11 @@ type ListTypesRequest struct {
|
||||
|
||||
// ListTypes gets list of defined disk types
|
||||
func (d Disks) ListTypes(ctx context.Context, req ListTypesRequest) (*ListTypes, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/listTypes"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListUnattachedRequest struct to get list of unattached disk
|
||||
@@ -40,6 +42,10 @@ type ListUnattachedRequest struct {
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,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"`
|
||||
@@ -51,6 +57,11 @@ type ListUnattachedRequest struct {
|
||||
|
||||
// ListUnattached gets list of unattached disks
|
||||
func (d Disks) ListUnattached(ctx context.Context, req ListUnattachedRequest) (*ListUnattachedDisks, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/listUnattached"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -137,6 +137,9 @@ type InfoDisk struct {
|
||||
// Reference ID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// Replication
|
||||
Replication interface{} `json:"replication"`
|
||||
|
||||
// Resource ID
|
||||
ResID string `json:"resId"`
|
||||
|
||||
|
||||
52
pkg/cloudbroker/disks/replicate.go
Normal file
52
pkg/cloudbroker/disks/replicate.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicateRequest struct to create an empty disk in chosen SEP and pool combination.
|
||||
type ReplicateRequest struct {
|
||||
// Id of the disk to replicate. This disk will become master in replication
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// Name of replica disk to create
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// ID of SEP to create slave disk
|
||||
// Required: true
|
||||
SepID uint64 `url:"sepId" json:"sepId" validate:"required"`
|
||||
|
||||
// Pool name to create slave disk in
|
||||
// Required: true
|
||||
PoolName string `url:"poolName" json:"poolName" validate:"required"`
|
||||
}
|
||||
|
||||
// Create an empty disk in chosen SEP and pool combination.
|
||||
// Starts replication between chosen disk and newly created disk
|
||||
// Note: only TATLIN type SEP are supported for replications between
|
||||
func (d Disks) Replicate(ctx context.Context, req ReplicateRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicate"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
38
pkg/cloudbroker/disks/replication_resume.go
Normal file
38
pkg/cloudbroker/disks/replication_resume.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationResume struct to resume suspended replication
|
||||
type ReplicationResumeRequest struct {
|
||||
// Id of the disk
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
// ReplicationResume resume suspended replication
|
||||
func (d Disks) ReplicationResume(ctx context.Context, req ReplicationResumeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationResume"
|
||||
|
||||
res, err := d.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
|
||||
}
|
||||
38
pkg/cloudbroker/disks/replication_reverse.go
Normal file
38
pkg/cloudbroker/disks/replication_reverse.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationReverseRequest struct to change role between disks replications
|
||||
type ReplicationReverseRequest struct {
|
||||
// Id of the disk
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
// ReplicationReverse change role between disks replications
|
||||
func (d Disks) ReplicationReverse(ctx context.Context, req ReplicationReverseRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationReverse"
|
||||
|
||||
res, err := d.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
|
||||
}
|
||||
43
pkg/cloudbroker/disks/replication_start.go
Normal file
43
pkg/cloudbroker/disks/replication_start.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationStartRequest struct to starts replication between two chosen disks
|
||||
type ReplicationStartRequest struct {
|
||||
// Id of the disk to replicate. Primary disk in replication
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// ID of target disk. Secondary disk in replication
|
||||
// Required: true
|
||||
TargetDiskID uint64 `url:"targetDiskId" json:"targetDiskId" validate:"required"`
|
||||
}
|
||||
|
||||
// ReplicationStart starts replication between two chosen disks. It's required for both disks to have same size to avoid replication conflicts
|
||||
// Note: Source disk's SEP and target SEP supported only of TATLIN type.
|
||||
func (d Disks) ReplicationStart(ctx context.Context, req ReplicationStartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationStart"
|
||||
|
||||
res, err := d.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
|
||||
}
|
||||
37
pkg/cloudbroker/disks/replication_status.go
Normal file
37
pkg/cloudbroker/disks/replication_status.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationStatusRequest struct to get replication status
|
||||
type ReplicationStatusRequest struct {
|
||||
// Id of the disk
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
// ReplicationStatus get replication status
|
||||
func (d Disks) ReplicationStatus(ctx context.Context, req ReplicationStatusRequest) (interface{}, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationStatus"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// result, err := strconv.ParseBool(string(res))
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
return res, nil
|
||||
}
|
||||
38
pkg/cloudbroker/disks/replication_stop.go
Normal file
38
pkg/cloudbroker/disks/replication_stop.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationStopRequest struct to remove replication between disks completely
|
||||
type ReplicationStopRequest struct {
|
||||
// Id of the disk
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
// ReplicationStop remove replication between disks completely
|
||||
func (d Disks) ReplicationStop(ctx context.Context, req ReplicationStopRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationStop"
|
||||
|
||||
res, err := d.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
|
||||
}
|
||||
38
pkg/cloudbroker/disks/replication_suspend.go
Normal file
38
pkg/cloudbroker/disks/replication_suspend.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationSuspendRequest struct to pause replication with possibility to resume from pause moment
|
||||
type ReplicationSuspendRequest struct {
|
||||
// Id of the disk
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
}
|
||||
|
||||
// ReplicationSuspend pause replication with possibility to resume from pause moment
|
||||
func (d Disks) ReplicationSuspend(ctx context.Context, req ReplicationSuspendRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/disks/replicationSuspend"
|
||||
|
||||
res, err := d.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,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of external network
|
||||
@@ -36,6 +38,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,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"`
|
||||
@@ -47,6 +53,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of all available external networks as a ListExtNet struct
|
||||
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error) {
|
||||
|
||||
res, err := e.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -64,6 +71,11 @@ func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error)
|
||||
|
||||
// ListRaw gets list of all available external networks as an array of bytes
|
||||
func (e ExtNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/extnet/list"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of FLIPGroup available to the current user
|
||||
@@ -28,6 +30,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
ByIP string `url:"byIp,omitempty" json:"byIp,omitempty"`
|
||||
|
||||
// Find by accountId
|
||||
// Required: false
|
||||
AccountId uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by resource group ID
|
||||
// Required: false
|
||||
RGID uint64 `url:"rgId,omitempty" json:"rgId,omitempty"`
|
||||
@@ -36,6 +42,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,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"`
|
||||
@@ -43,10 +53,19 @@ type ListRequest struct {
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
|
||||
// Find by connId
|
||||
// Required: false
|
||||
ConnId uint64 `url:"connId,omitempty" json:"connId,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// List gets list of FLIPGroup managed cluster instances available to the current user as a ListFLIPGroups struct
|
||||
func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups, error) {
|
||||
|
||||
res, err := f.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -64,6 +83,11 @@ func (f FLIPGroup) List(ctx context.Context, req ListRequest) (*ListFLIPGroups,
|
||||
|
||||
// ListRaw gets list of FLIPGroup managed cluster instances available to the current user as an array of bytes
|
||||
func (f FLIPGroup) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/flipgroup/list"
|
||||
|
||||
res, err := f.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
42
pkg/cloudbroker/grid/add_custom_backup_path.go
Normal file
42
pkg/cloudbroker/grid/add_custom_backup_path.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package grid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// AddCustomBackupPathRequest struct to add new path to the list of custom backup paths
|
||||
type AddCustomBackupPathRequest struct {
|
||||
// ID of the grid
|
||||
// Required: true
|
||||
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
||||
|
||||
// Absolute path
|
||||
// Required: true
|
||||
Path string `url:"path" json:"path" validate:"required"`
|
||||
}
|
||||
|
||||
// AddCustomBackupPath add new path to the list of custom backup paths
|
||||
func (g Grid) AddCustomBackupPath(ctx context.Context, req AddCustomBackupPathRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/grid/addCustomBackupPath"
|
||||
|
||||
res, err := g.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,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of locations
|
||||
@@ -16,6 +18,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,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"`
|
||||
@@ -27,6 +33,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of all locations as a ListGrids struct
|
||||
func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
|
||||
|
||||
res, err := g.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -44,6 +51,11 @@ func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
|
||||
|
||||
// ListRaw gets list of all locations as an array of bytes
|
||||
func (g Grid) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/grid/list"
|
||||
|
||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
42
pkg/cloudbroker/grid/remove_custom_backup_path.go
Normal file
42
pkg/cloudbroker/grid/remove_custom_backup_path.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package grid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RemoveCustomBackupPathRequest struct to remove path from the list of custom backup paths
|
||||
type RemoveCustomBackupPathRequest struct {
|
||||
// ID of the grid
|
||||
// Required: true
|
||||
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
||||
|
||||
// Absolute path
|
||||
// Required: true
|
||||
Path string `url:"path" json:"path" validate:"required"`
|
||||
}
|
||||
|
||||
// RemoveCustomBackupPath remove path from the list of custom backup paths
|
||||
func (g Grid) RemoveCustomBackupPath(ctx context.Context, req RemoveCustomBackupPathRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/grid/removeCustomBackupPath"
|
||||
|
||||
res, err := g.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
|
||||
}
|
||||
@@ -16,7 +16,7 @@ type RenameRequest struct {
|
||||
|
||||
// New name
|
||||
// Required: true
|
||||
Name string `url:"Name" json:"Name" validate:"required"`
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
// Rename renames a grid
|
||||
|
||||
58
pkg/cloudbroker/grid/set_password_policy.go
Normal file
58
pkg/cloudbroker/grid/set_password_policy.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package grid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// SetPasswordPolicyRequest struct to set password policy for a grid
|
||||
type SetPasswordPolicyRequest struct {
|
||||
// ID of the grid
|
||||
// Required: true
|
||||
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
||||
|
||||
// Available numbers in the password
|
||||
// Default value : true
|
||||
// Required: true
|
||||
Digits bool `url:"digits" json:"digits"`
|
||||
|
||||
// Available special characters in the password
|
||||
// Default value : false
|
||||
// Required: true
|
||||
SpecialSymbols bool `url:"specialSymbols" json:"specialSymbols"`
|
||||
|
||||
// Number of characters in the password
|
||||
// Default value : 9
|
||||
// Required: true
|
||||
PasswordLength uint64 `url:"passwordLength" json:"passwordLength" validate:"required"`
|
||||
|
||||
// Capital letters in the password are available
|
||||
// Default value : true
|
||||
// Required: true
|
||||
Uppercase bool `url:"uppercase" json:"uppercase"`
|
||||
}
|
||||
|
||||
// RemoveCustomBackupPath set set password policy for a grid
|
||||
func (g Grid) SetPasswordPolicy(ctx context.Context, req SetPasswordPolicyRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/grid/setPasswordPolicy"
|
||||
|
||||
res, err := g.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,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of group instances.
|
||||
@@ -16,6 +18,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
User string `url:"user,omitempty" json:"user,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"`
|
||||
@@ -31,6 +37,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of group instances as a ListGroups struct
|
||||
func (g Group) List(ctx context.Context, req ListRequest) (*ListGroups, error) {
|
||||
|
||||
res, err := g.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -48,6 +55,11 @@ func (g Group) List(ctx context.Context, req ListRequest) (*ListGroups, error) {
|
||||
|
||||
// ListRaw gets list of group instances as an array of bytes
|
||||
func (g Group) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/group/list"
|
||||
|
||||
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -22,7 +22,7 @@ func (i Image) ComputeCIUnset(ctx context.Context, req ComputeCIUnsetRequest) (b
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/сomputeciUnset"
|
||||
url := "/cloudbroker/image/computeciUnset"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
|
||||
@@ -27,7 +27,7 @@ type CreateRequest struct {
|
||||
// - bios
|
||||
// - UEFI
|
||||
// Required: true
|
||||
BootType string `url:"boottype" json:"boottype" validate:"imageBootType"`
|
||||
BootType string `url:"boottype" json:"boottype" validate:"required,imageBootType"`
|
||||
|
||||
// Image type
|
||||
// Should be one of:
|
||||
@@ -35,7 +35,14 @@ type CreateRequest struct {
|
||||
// - windows
|
||||
// - or other
|
||||
// Required: true
|
||||
ImageType string `url:"imagetype" json:"imagetype" validate:"imageType"`
|
||||
ImageType string `url:"imagetype" json:"imagetype" validate:"required,imageType"`
|
||||
|
||||
// Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming
|
||||
// Should be:
|
||||
// - eth
|
||||
// - ens (default value)
|
||||
// Required: false
|
||||
NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"`
|
||||
|
||||
// Does this machine supports hot resize
|
||||
// Required: false
|
||||
@@ -78,7 +85,7 @@ type CreateRequest struct {
|
||||
|
||||
// List of types of compute suitable for image
|
||||
// Example: [ "KVM_X86" ]
|
||||
// Required: true
|
||||
// Required: required
|
||||
Drivers []string `url:"drivers" json:"drivers" validate:"min=1,max=2,imageDrivers"`
|
||||
|
||||
// Bootable image or not
|
||||
|
||||
@@ -14,6 +14,13 @@ type EditRequest struct {
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming
|
||||
// Should be:
|
||||
// - eth
|
||||
// - ens (default value)
|
||||
// Required: false
|
||||
NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"`
|
||||
|
||||
// Name for the image
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
@@ -2,7 +2,7 @@ package image
|
||||
|
||||
// FilterById returns ListImages with specified ID.
|
||||
func (li ListImages) FilterByID(id uint64) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
predicate := func(ri ItemImage) bool {
|
||||
return ri.ID == id
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ func (li ListImages) FilterByID(id uint64) ListImages {
|
||||
|
||||
// FilterByName returns ListImages with specified Name.
|
||||
func (li ListImages) FilterByName(name string) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
predicate := func(ri ItemImage) bool {
|
||||
return ri.Name == name
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func (li ListImages) FilterByName(name string) ListImages {
|
||||
|
||||
// FilterByStatus returns ListImages with specified Status.
|
||||
func (li ListImages) FilterByStatus(status string) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
predicate := func(ri ItemImage) bool {
|
||||
return ri.Status == status
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func (li ListImages) FilterByStatus(status string) ListImages {
|
||||
|
||||
// FilterByTechStatus returns ListImages with specified TechStatus.
|
||||
func (li ListImages) FilterByTechStatus(techStatus string) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
predicate := func(ri ItemImage) bool {
|
||||
return ri.TechStatus == techStatus
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func (li ListImages) FilterByTechStatus(techStatus string) ListImages {
|
||||
|
||||
// FilterByBootType returns ListImages with specified BootType.
|
||||
func (li ListImages) FilterByBootType(bootType string) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
predicate := func(ri ItemImage) bool {
|
||||
return ri.BootType == bootType
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func (li ListImages) FilterByBootType(bootType string) ListImages {
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListImages based on a user-specified predicate.
|
||||
func (li ListImages) FilterFunc(predicate func(RecordImage) bool) ListImages {
|
||||
func (li ListImages) FilterFunc(predicate func(ItemImage) bool) ListImages {
|
||||
var result ListImages
|
||||
|
||||
for _, item := range li.Data {
|
||||
@@ -60,9 +60,9 @@ func (li ListImages) FilterFunc(predicate func(RecordImage) bool) ListImages {
|
||||
|
||||
// FindOne returns first found RecordImage
|
||||
// If none was found, returns an empty struct.
|
||||
func (li ListImages) FindOne() RecordImage {
|
||||
func (li ListImages) FindOne() ItemImage {
|
||||
if len(li.Data) == 0 {
|
||||
return RecordImage{}
|
||||
return ItemImage{}
|
||||
}
|
||||
|
||||
return li.Data[0]
|
||||
|
||||
@@ -3,16 +3,9 @@ package image
|
||||
import "testing"
|
||||
|
||||
var images = ListImages{
|
||||
Data: []RecordImage{
|
||||
Data: []ItemImage{
|
||||
{
|
||||
UNCPath: "",
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"osismodel",
|
||||
"cloudbroker",
|
||||
"image",
|
||||
1,
|
||||
},
|
||||
UNCPath: "",
|
||||
AccountID: 0,
|
||||
ACL: []ACL{},
|
||||
Architecture: "X86_64",
|
||||
@@ -55,14 +48,7 @@ var images = ListImages{
|
||||
Virtual: false,
|
||||
},
|
||||
{
|
||||
UNCPath: "",
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"osismodel",
|
||||
"cloudbroker",
|
||||
"image",
|
||||
1,
|
||||
},
|
||||
UNCPath: "",
|
||||
AccountID: 0,
|
||||
ACL: []ACL{},
|
||||
Architecture: "X86_64",
|
||||
@@ -105,14 +91,7 @@ var images = ListImages{
|
||||
Virtual: true,
|
||||
},
|
||||
{
|
||||
UNCPath: "",
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"osismodel",
|
||||
"cloudbroker",
|
||||
"image",
|
||||
1,
|
||||
},
|
||||
UNCPath: "",
|
||||
AccountID: 1,
|
||||
ACL: []ACL{},
|
||||
Architecture: "X86_64",
|
||||
@@ -202,7 +181,7 @@ func TestFilterByBootType(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := images.FilterFunc(func(ri RecordImage) bool {
|
||||
actual := images.FilterFunc(func(ri ItemImage) bool {
|
||||
return ri.Virtual == true
|
||||
})
|
||||
|
||||
|
||||
42
pkg/cloudbroker/image/grant_access.go
Normal file
42
pkg/cloudbroker/image/grant_access.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// GrantAccessRequest struct to share image with accounts
|
||||
type GrantAccessRequest struct {
|
||||
// ID of the image to share
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// ID of the accounts for share image
|
||||
// Required: true
|
||||
AccountIDs []uint64 `url:"accounts" json:"accounts" validate:"required"`
|
||||
}
|
||||
|
||||
// GrantAccess shares specified image with specified accounts
|
||||
func (i Image) GrantAccess(ctx context.Context, req GrantAccessRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/grantAccess"
|
||||
|
||||
res, err := i.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,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of available images
|
||||
@@ -56,6 +58,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
Bootable bool `url:"bootable,omitempty" json:"bootable,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"`
|
||||
@@ -67,6 +73,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of information about images as a ListImages struct
|
||||
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
||||
|
||||
res, err := i.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -84,6 +91,11 @@ func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
|
||||
|
||||
// ListRaw gets list of information about images as an array of bytes
|
||||
func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
if err := validators.ValidateRequest(req); err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/list"
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -33,10 +33,15 @@ type ListStacksRequest struct {
|
||||
// Find by type
|
||||
// Required: false
|
||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
}
|
||||
|
||||
// ListStacks gets list stack by image ID
|
||||
func (i Image) ListStacks(ctx context.Context, req ListStacksRequest) (*ListStacks, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -5,12 +5,6 @@ type RecordImage struct {
|
||||
// UNC path
|
||||
UNCPath string `json:"UNCPath"`
|
||||
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
@@ -26,6 +20,9 @@ type RecordImage struct {
|
||||
// Bootable
|
||||
Bootable bool `json:"bootable"`
|
||||
|
||||
// CdPresentedTo
|
||||
CdPresentedTo interface{} `json:"cdPresentedTo"`
|
||||
|
||||
// Compute CI ID
|
||||
ComputeCIID uint64 `json:"computeciId"`
|
||||
|
||||
@@ -68,6 +65,132 @@ type RecordImage struct {
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// NetworkInterfaceNaming
|
||||
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
|
||||
|
||||
// Password
|
||||
Password string `json:"password"`
|
||||
|
||||
// Pool
|
||||
Pool string `json:"pool"`
|
||||
|
||||
// Present to
|
||||
PresentTo []uint64 `json:"presentTo"`
|
||||
|
||||
// Provider name
|
||||
ProviderName string `json:"provider_name"`
|
||||
|
||||
// Purge attempts
|
||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||
|
||||
// Reference ID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// Resource ID
|
||||
ResID string `json:"resId"`
|
||||
|
||||
// Resource name
|
||||
ResName string `json:"resName"`
|
||||
|
||||
// Rescue CD
|
||||
RescueCD bool `json:"rescuecd"`
|
||||
|
||||
// SEP ID
|
||||
SEPID uint64 `json:"sepId"`
|
||||
|
||||
// List shared with
|
||||
SharedWith []uint64 `json:"sharedWith"`
|
||||
|
||||
// Size
|
||||
Size uint64 `json:"size"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// URL
|
||||
URL string `json:"url"`
|
||||
|
||||
// Username
|
||||
Username string `json:"username"`
|
||||
|
||||
// Version
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
// Detailed information about item of images list
|
||||
type ItemImage struct {
|
||||
// UNC path
|
||||
UNCPath string `json:"UNCPath"`
|
||||
|
||||
// Account ID
|
||||
AccountID uint64 `json:"accountId"`
|
||||
|
||||
// Access Control List
|
||||
ACL ListACL `json:"acl"`
|
||||
|
||||
// Architecture
|
||||
Architecture string `json:"architecture"`
|
||||
|
||||
// Boot type
|
||||
BootType string `json:"bootType"`
|
||||
|
||||
// Bootable
|
||||
Bootable bool `json:"bootable"`
|
||||
|
||||
// CdPresentedTo
|
||||
CdPresentedTo interface{} `json:"cdPresentedTo"`
|
||||
|
||||
// Compute CI ID
|
||||
ComputeCIID uint64 `json:"computeciId"`
|
||||
|
||||
// Deleted time
|
||||
DeletedTime uint64 `json:"deletedTime"`
|
||||
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// Drivers
|
||||
Drivers []string `json:"drivers"`
|
||||
|
||||
// Enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GUID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// List history
|
||||
History ListHistory `json:"history"`
|
||||
|
||||
// Hot resize
|
||||
HotResize bool `json:"hotResize"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// Last modified
|
||||
LastModified uint64 `json:"lastModified"`
|
||||
|
||||
// Link to
|
||||
LinkTo uint64 `json:"linkTo"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// NetworkInterfaceNaming
|
||||
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
|
||||
|
||||
// Password
|
||||
Password string `json:"password"`
|
||||
|
||||
@@ -129,7 +252,7 @@ type RecordImage struct {
|
||||
// List images
|
||||
type ListImages struct {
|
||||
// Data
|
||||
Data []RecordImage `json:"data"`
|
||||
Data []ItemImage `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
|
||||
42
pkg/cloudbroker/image/revoke_access.go
Normal file
42
pkg/cloudbroker/image/revoke_access.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RevokeAccessRequest struct to unshare image with accounts
|
||||
type RevokeAccessRequest struct {
|
||||
// ID of the image to unshare
|
||||
// Required: true
|
||||
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
|
||||
|
||||
// ID of the accounts for unshare image
|
||||
// Required: true
|
||||
AccountIDs []uint64 `url:"accounts" json:"accounts" validate:"required"`
|
||||
}
|
||||
|
||||
// RevokeAccess unshares specified image with specified accounts
|
||||
func (i Image) RevokeAccess(ctx context.Context, req RevokeAccessRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/image/revokeAccess"
|
||||
|
||||
res, err := i.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
|
||||
}
|
||||
@@ -27,7 +27,7 @@ type SyncCreateRequest struct {
|
||||
// - bios
|
||||
// - UEFI
|
||||
// Required: true
|
||||
BootType string `url:"boottype" json:"boottype" validate:"imageBootType"`
|
||||
BootType string `url:"boottype" json:"boottype" validate:"required,imageBootType"`
|
||||
|
||||
// Image type
|
||||
// Should be one of:
|
||||
@@ -35,7 +35,14 @@ type SyncCreateRequest struct {
|
||||
// - windows
|
||||
// - or other
|
||||
// Required: true
|
||||
ImageType string `url:"imagetype" json:"imagetype" validate:"imageType"`
|
||||
ImageType string `url:"imagetype" json:"imagetype" validate:"required,imageType"`
|
||||
|
||||
// Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming
|
||||
// Should be:
|
||||
// - eth
|
||||
// - ens (default value)
|
||||
// Required: false
|
||||
NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"`
|
||||
|
||||
// Does this machine supports hot resize
|
||||
// Required: false
|
||||
|
||||
@@ -19,7 +19,7 @@ type AccessAddRequest struct {
|
||||
}
|
||||
|
||||
// Add accountId to sharedWith access list for k8ci.
|
||||
func (k K8CI) AccessAdd(ctx context.Context, req AccessAddRequest) (string, error) {
|
||||
func (k K8CI) AccessAdd (ctx context.Context, req AccessAddRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -19,7 +19,7 @@ type AccessRemoveRequest struct {
|
||||
}
|
||||
|
||||
// Remove accountId from sharedWith access list for k8ci.
|
||||
func (k K8CI) AccessRemove(ctx context.Context, req AccessRemoveRequest) (string, error) {
|
||||
func (k K8CI) AccessRemove (ctx context.Context, req AccessRemoveRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list information about images
|
||||
@@ -36,6 +38,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
IncludeDisabled bool `url:"includeDisabled,omitempty" json:"includeDisabled,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"`
|
||||
@@ -47,6 +53,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of all k8ci catalog items available to the current user as a ListK8CI struct
|
||||
func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
||||
|
||||
res, err := k.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -64,6 +71,12 @@ func (k K8CI) List(ctx context.Context, req ListRequest) (*ListK8CI, error) {
|
||||
|
||||
// ListRaw gets list of all k8ci catalog items available to the current user as an array of bytes
|
||||
func (k K8CI) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/k8ci/list"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,13 +4,15 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct to get list information about deleted images
|
||||
// ListDeletedRequest struct to get list information about deleted k8ci items
|
||||
type ListDeletedRequest struct {
|
||||
// Find by ID
|
||||
// Required: false
|
||||
ByID uint64 `url:"by_id,omitempty" json:"by_id,omitempty"`
|
||||
ByID uint64 `url:"k8cId,omitempty" json:"k8cId,omitempty"`
|
||||
|
||||
// Find by name
|
||||
// Required: false
|
||||
@@ -26,7 +28,11 @@ type ListDeletedRequest struct {
|
||||
|
||||
// Find by network plugin
|
||||
// Required: false
|
||||
NetworkPlugins string `url:"netPlugins,omitempty" json:"masterDrnetPluginsiver,omitempty"`
|
||||
NetworkPlugins string `url:"netPlugins,omitempty" json:"netPlugins,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
|
||||
@@ -39,6 +45,12 @@ type ListDeletedRequest struct {
|
||||
|
||||
// ListDeleted gets list all deleted k8ci catalog items available to the current user
|
||||
func (k K8CI) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListK8CI, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/k8ci/listDeleted"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -8,8 +8,6 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// type Params []string
|
||||
|
||||
// CreateRequest struct to create K8S
|
||||
type CreateRequest struct {
|
||||
// Name of kubernetes cluster
|
||||
@@ -29,7 +27,7 @@ type CreateRequest struct {
|
||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required,workerGroupName"`
|
||||
|
||||
// Network plugin
|
||||
// Must be one of these values: flunnel, weavenet, calico
|
||||
// Must be one of these values: flannel, weavenet, calico
|
||||
// Required: true
|
||||
NetworkPlugin string `url:"networkPlugin" json:"networkPlugin" validate:"required,networkPlugin"`
|
||||
|
||||
@@ -113,7 +111,7 @@ type CreateRequest struct {
|
||||
|
||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||
// Required: false
|
||||
LbSysctlParams string `url:"lbSysctlParams,omitempty" json:"lbSysctlParams,omitempty"`
|
||||
LbSysctlParams []map[string]interface{} `url:"lbSysctlParams,omitempty" json:"lbSysctlParams,omitempty"`
|
||||
|
||||
// Use Highly Available schema for LB deploy
|
||||
// Required: false
|
||||
@@ -168,40 +166,25 @@ type CreateRequest struct {
|
||||
OidcCertificate string `url:"oidcCertificate,omitempty" json:"oidcCertificate,omitempty"`
|
||||
}
|
||||
|
||||
// type wrapperCreateRequest struct {
|
||||
// CreateRequest
|
||||
// Params []string `url:"lbSysctlParams,omitempty"`
|
||||
// }
|
||||
// GetRAM returns RAM values
|
||||
func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 2)
|
||||
|
||||
res["MasterRAM"] = r.MasterRAM
|
||||
res["WorkerRAM"] = r.WorkerRAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// Create creates a new kubernetes cluster in the specified resource group
|
||||
func (k K8S) Create(ctx context.Context, req CreateRequest) (string, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
// var params []string
|
||||
|
||||
// if len(req.LbSysctlParams) != 0 {
|
||||
// params = make([]string, 0, len(req.LbSysctlParams))
|
||||
|
||||
// for r := range req.LbSysctlParams {
|
||||
// b, err := json.Marshal(req.LbSysctlParams[r])
|
||||
// if err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
|
||||
// params = append(params, string(b))
|
||||
// }
|
||||
// } else {
|
||||
// params = []string{}
|
||||
// }
|
||||
|
||||
// reqWrapped := wrapperCreateRequest{
|
||||
// CreateRequest: req,
|
||||
// Params: params,
|
||||
// }
|
||||
|
||||
url := "/cloudbroker/k8s/create"
|
||||
|
||||
res, err := k.client.DecortApiCallMP(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list information K8S
|
||||
@@ -44,6 +46,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,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"`
|
||||
@@ -55,6 +61,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of all kubernetes clusters as a ListK8S struct
|
||||
func (k K8S) List(ctx context.Context, req ListRequest) (*ListK8S, error) {
|
||||
|
||||
res, err := k.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -72,6 +79,12 @@ func (k K8S) List(ctx context.Context, req ListRequest) (*ListK8S, error) {
|
||||
|
||||
// ListRaw gets list of all kubernetes clusters as an array of bytes
|
||||
func (k K8S) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/k8s/list"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct to get list of deleted kubernetes cluster
|
||||
@@ -36,6 +38,10 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
TechStatus string `url:"techStatus,omitempty" json:"techStatus,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"`
|
||||
@@ -48,6 +54,11 @@ type ListDeletedRequest struct {
|
||||
// ListDeleted gets all deleted kubernetes clusters
|
||||
func (k K8S) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListK8S, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/k8s/listDeleted"
|
||||
|
||||
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -64,6 +64,16 @@ type WorkersGroupAddRequest struct {
|
||||
UserData string `url:"userData,omitempty" json:"userData,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r WorkersGroupAddRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["WorkerRAM"] = r.WorkerRAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// WorkersGroupAdd adds workers group to kubernetes cluster
|
||||
func (k K8S) WorkersGroupAdd(ctx context.Context, req WorkersGroupAddRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
|
||||
@@ -26,6 +26,35 @@ type Interface struct {
|
||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||
}
|
||||
|
||||
// DataDisk detailed struct for DataDisks field in CreateRequest, CreateBlankRequest and MassCreateRequest
|
||||
type DataDisk struct {
|
||||
// Name for disk
|
||||
// Required: true
|
||||
DiskName string `url:"diskName" json:"diskName" validate:"required"`
|
||||
|
||||
// Disk size in GB
|
||||
// Required: true
|
||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// By default the same with boot disk
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool name
|
||||
// By default will be chosen automatically
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Optional description
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
// Specify image id for create disk from template
|
||||
// Required: false
|
||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||
}
|
||||
|
||||
// CreateRequest struct to create KVM PowerPC VM
|
||||
type CreateRequest struct {
|
||||
// ID of the resource group, which will own this VM
|
||||
@@ -63,6 +92,12 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
// To create compute without disks, pass initialized empty slice .
|
||||
// Required: false
|
||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Slice of structs with net interface description.
|
||||
// If not specified, compute will be created with default interface from RG.
|
||||
// To create compute without interfaces, pass initialized empty slice .
|
||||
@@ -98,9 +133,20 @@ type CreateRequest struct {
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates KVM PowerPC VM based on specified OS image
|
||||
@@ -127,9 +173,25 @@ func (k KVMPPC) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
CreateRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/kvmppc/create"
|
||||
|
||||
@@ -41,6 +41,12 @@ type CreateBlankRequest struct {
|
||||
// Required: true
|
||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
// To create compute without disks, pass initialized empty slice .
|
||||
// Required: false
|
||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Slice of structs with net interface description.
|
||||
// If not specified, compute will be created with default interface from RG.
|
||||
// To create compute without interfaces, pass initialized empty slice .
|
||||
@@ -52,9 +58,20 @@ type CreateBlankRequest struct {
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r CreateBlankRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateBlankRequest struct {
|
||||
CreateBlankRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// CreateBlank creates KVM PowerPC VM from scratch
|
||||
@@ -81,9 +98,25 @@ func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateBlankRequest{
|
||||
CreateBlankRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/kvmppc/createBlank"
|
||||
@@ -99,5 +132,4 @@ func (k KVMPPC) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ type MassCreateRequest struct {
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
// To create compute without disks, pass initialized empty slice .
|
||||
// Required: false
|
||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Slice of structs with net interface description.
|
||||
// If not specified, compute will be created with default interface from RG.
|
||||
// To create compute without interfaces, pass initialized empty slice.
|
||||
@@ -71,9 +77,20 @@ type MassCreateRequest struct {
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r MassCreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperMassCreateRequest struct {
|
||||
MassCreateRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// MassCreate creates KVM PPC computes based on specified OS image
|
||||
@@ -100,9 +117,25 @@ func (k KVMPPC) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperMassCreateRequest{
|
||||
MassCreateRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/kvmppc/massCreate"
|
||||
|
||||
@@ -26,6 +26,35 @@ type Interface struct {
|
||||
IPAddr string `url:"ipAddr,omitempty" json:"ipAddr,omitempty"`
|
||||
}
|
||||
|
||||
// DataDisk detailed struct for DataDisks field in CreateRequest, CreateBlankRequest and MassCreateRequest
|
||||
type DataDisk struct {
|
||||
// Name for disk
|
||||
// Required: true
|
||||
DiskName string `url:"diskName" json:"diskName" validate:"required"`
|
||||
|
||||
// Disk size in GB
|
||||
// Required: true
|
||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||
|
||||
// Storage endpoint provider ID
|
||||
// By default the same with boot disk
|
||||
// Required: false
|
||||
SepID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||
|
||||
// Pool name
|
||||
// By default will be chosen automatically
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Optional description
|
||||
// Required: false
|
||||
Description string `url:"desc,omitempty" json:"desc,omitempty"`
|
||||
|
||||
// Specify image id for create disk from template
|
||||
// Required: false
|
||||
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
|
||||
}
|
||||
|
||||
// CreateRequest struct to create KVM x86 VM
|
||||
type CreateRequest struct {
|
||||
// ID of the resource group, which will own this VM
|
||||
@@ -63,6 +92,12 @@ type CreateRequest struct {
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
// To create compute without disks, pass initialized empty slice .
|
||||
// Required: false
|
||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Slice of structs with net interface description.
|
||||
// If not specified, compute will be created with default interface from RG.
|
||||
// To create compute without interfaces, pass initialized empty slice .
|
||||
@@ -106,9 +141,20 @@ type CreateRequest struct {
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// Create creates KVM PowerPC VM based on specified OS image
|
||||
@@ -135,9 +181,25 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
CreateRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/kvmx86/create"
|
||||
|
||||
@@ -41,6 +41,12 @@ type CreateBlankRequest struct {
|
||||
// Required: true
|
||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
// To create compute without disks, pass initialized empty slice .
|
||||
// Required: false
|
||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Slice of structs with net interface description.
|
||||
// If not specified, compute will be created with default interface from RG.
|
||||
// To create compute without interfaces, pass initialized empty slice .
|
||||
@@ -56,9 +62,20 @@ type CreateBlankRequest struct {
|
||||
Driver string `url:"driver,omitempty" json:"driver,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r CreateBlankRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperCreateBlankRequest struct {
|
||||
CreateBlankRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// CreateBlank creates KVM x86 VM from scratch
|
||||
@@ -85,9 +102,25 @@ func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperCreateBlankRequest{
|
||||
CreateBlankRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/kvmx86/createBlank"
|
||||
|
||||
@@ -48,6 +48,12 @@ type MassCreateRequest struct {
|
||||
// Required: false
|
||||
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||
|
||||
// Slice of structs with data disk description. Each disk has parameters: required - diskName, size; optional - sepId, pool, desc and imageId.
|
||||
// If not specified, compute will be created without disks.
|
||||
// To create compute without disks, pass initialized empty slice .
|
||||
// Required: false
|
||||
DataDisks []DataDisk `url:"-" json:"dataDisks,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Slice of structs with net interface description.
|
||||
// If not specified, compute will be created with default interface from RG.
|
||||
// To create compute without interfaces, pass initialized empty slice .
|
||||
@@ -71,9 +77,20 @@ type MassCreateRequest struct {
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// GetRAM returns RAM field values
|
||||
func (r MassCreateRequest) GetRAM() map[string]uint64 {
|
||||
|
||||
res := make(map[string]uint64, 1)
|
||||
|
||||
res["RAM"] = r.RAM
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
type wrapperMassCreateRequest struct {
|
||||
MassCreateRequest
|
||||
Interfaces []string `url:"interfaces,omitempty"`
|
||||
DataDisks []string `url:"dataDisks,omitempty"`
|
||||
}
|
||||
|
||||
// MassCreate creates KVM x86 computes based on specified OS image
|
||||
@@ -100,9 +117,25 @@ func (k KVMX86) MassCreate(ctx context.Context, req MassCreateRequest) ([]uint64
|
||||
interfaces = []string{"[]"}
|
||||
}
|
||||
|
||||
var dataDisks []string
|
||||
|
||||
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||
|
||||
for i := range req.DataDisks {
|
||||
b, err := json.Marshal(req.DataDisks[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dataDisks = append(dataDisks, string(b))
|
||||
}
|
||||
}
|
||||
|
||||
reqWrapped := wrapperMassCreateRequest{
|
||||
MassCreateRequest: req,
|
||||
Interfaces: interfaces,
|
||||
DataDisks: dataDisks,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/kvmx86/massCreate"
|
||||
|
||||
@@ -10,8 +10,6 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
type Params []string
|
||||
|
||||
// CreateRequest struct to create load balancer
|
||||
type CreateRequest struct {
|
||||
// ID of the resource group where this load balancer instance will be located
|
||||
@@ -33,7 +31,7 @@ type CreateRequest struct {
|
||||
|
||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||
// Required: false
|
||||
SysctlParams Params `url:"-" json:"sysctlParams,omitempty" validate:"omitempty,dive"`
|
||||
SysctlParams []map[string]interface{} `url:"-" json:"sysctlParams,omitempty" validate:"omitempty,dive"`
|
||||
|
||||
// Use Highly Available schema for LB deploy
|
||||
// Required: false
|
||||
@@ -68,14 +66,12 @@ func (lb LB) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
|
||||
if len(req.SysctlParams) != 0 {
|
||||
params = make([]string, 0, len(req.SysctlParams))
|
||||
|
||||
for r := range req.SysctlParams {
|
||||
b, err := json.Marshal(req.SysctlParams[r])
|
||||
for _, m := range req.SysctlParams {
|
||||
encodeStr, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
params = append(params, string(b))
|
||||
params = append(params, string(encodeStr))
|
||||
}
|
||||
} else {
|
||||
params = []string{}
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListRequest struct to get list of load balancers
|
||||
@@ -18,7 +20,7 @@ type ListRequest struct {
|
||||
|
||||
// Find by account ID
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountID,omitempty" json:"accountID,omitempty"`
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by resource group ID
|
||||
// Required: false
|
||||
@@ -44,6 +46,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
IncludeDeleted bool `url:"includedeleted,omitempty" json:"includedeleted,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"`
|
||||
@@ -55,6 +61,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of all load balancers as a ListLB struct
|
||||
func (lb LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||
|
||||
res, err := lb.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -72,6 +79,12 @@ func (lb LB) List(ctx context.Context, req ListRequest) (*ListLB, error) {
|
||||
|
||||
// ListRaw gets list of all load balancers as an array of bytes
|
||||
func (lb LB) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/lb/list"
|
||||
|
||||
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ListDeletedRequest struct to get list of deleted load balancers
|
||||
@@ -18,7 +20,7 @@ type ListDeletedRequest struct {
|
||||
|
||||
// Find by account ID
|
||||
// Required: false
|
||||
AccountID uint64 `url:"accountID,omitempty" json:"accountID,omitempty"`
|
||||
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||
|
||||
// Find by resource group ID
|
||||
// Required: false
|
||||
@@ -36,6 +38,10 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
BackIP string `url:"backIp,omitempty" json:"backIp,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"`
|
||||
@@ -47,6 +53,12 @@ type ListDeletedRequest struct {
|
||||
|
||||
// ListDeleted gets list of deleted load balancers
|
||||
func (lb LB) ListDeleted(ctx context.Context, req ListDeletedRequest) (*ListLB, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/lb/listDeleted"
|
||||
|
||||
res, err := lb.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
@@ -192,6 +192,12 @@ type RecordLB struct {
|
||||
// Image ID
|
||||
ImageID uint64 `json:"imageId"`
|
||||
|
||||
// Manager Id
|
||||
ManagerId uint64 `json:"managerId"`
|
||||
|
||||
// Manager Type
|
||||
ManagerType string `json:"managerType"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
@@ -219,6 +225,9 @@ type RecordLB struct {
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
// User Managed flag
|
||||
UserManaged bool `json:"userManaged"`
|
||||
|
||||
// VINS ID
|
||||
VINSID uint64 `json:"vinsId"`
|
||||
}
|
||||
@@ -276,12 +285,21 @@ type ItemLBList struct {
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// ManagerId
|
||||
ManagerId uint64 `json:"managerId"`
|
||||
|
||||
// Name
|
||||
ManagerType string `json:"managerType"`
|
||||
|
||||
// Milestones
|
||||
Milestones uint64 `json:"milestones"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// PartK8s
|
||||
PartK8s bool `json:"partK8s"`
|
||||
|
||||
// Primary node
|
||||
PrimaryNode Node `json:"primaryNode"`
|
||||
|
||||
@@ -309,6 +327,9 @@ type ItemLBList struct {
|
||||
// Updated time
|
||||
UpdatedTime uint64 `json:"updatedTime"`
|
||||
|
||||
// User managed flag
|
||||
UserManaged bool `json:"userManaged"`
|
||||
|
||||
// VINS ID
|
||||
VINSID uint64 `json:"vinsId"`
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@ type RestartRequest struct {
|
||||
// ID of the load balancer instance to restart
|
||||
// Required: true
|
||||
LBID uint64 `url:"lbId" json:"lbId" validate:"required"`
|
||||
|
||||
// restart secondary and primary nodes sequentially in HA mode
|
||||
// Default: true
|
||||
// Required: false
|
||||
Safe bool `url:"safe" json:"safe"`
|
||||
}
|
||||
|
||||
// Restart restarts specified load balancer instance
|
||||
|
||||
@@ -17,7 +17,7 @@ type UpdateSysctParamsRequest struct {
|
||||
|
||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||
// Required: true
|
||||
SysctlParams Params `url:"-" json:"sysctlParams" validate:"required,dive"`
|
||||
SysctlParams []map[string]interface{} `url:"-" json:"sysctlParams" validate:"required,dive"`
|
||||
}
|
||||
|
||||
type wrapperUpdateSysctParamsRequest struct {
|
||||
@@ -26,24 +26,21 @@ type wrapperUpdateSysctParamsRequest struct {
|
||||
}
|
||||
|
||||
// UpdateSysctParams method will create a new load balancer instance
|
||||
func (l LB) UpdateSysctParams(ctx context.Context, req UpdateSysctParamsRequest) (bool, error) {
|
||||
func (l LB) UpdateSysctlParams(ctx context.Context, req UpdateSysctParamsRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
var params []string
|
||||
|
||||
if len(req.SysctlParams) != 0 {
|
||||
params = make([]string, 0, len(req.SysctlParams))
|
||||
|
||||
for r := range req.SysctlParams {
|
||||
b, err := json.Marshal(req.SysctlParams[r])
|
||||
for _, m := range req.SysctlParams {
|
||||
encodeStr, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
params = append(params, string(b))
|
||||
params = append(params, string(encodeStr))
|
||||
}
|
||||
} else {
|
||||
params = []string{}
|
||||
@@ -54,7 +51,7 @@ func (l LB) UpdateSysctParams(ctx context.Context, req UpdateSysctParamsRequest)
|
||||
Params: params,
|
||||
}
|
||||
|
||||
url := "/cloudbroker/lb/updateSysctParams"
|
||||
url := "/cloudbroker/lb/updateSysctlParams"
|
||||
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
8
pkg/cloudbroker/node.go
Normal file
8
pkg/cloudbroker/node.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package cloudbroker
|
||||
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/node"
|
||||
|
||||
// Accessing the Node method group
|
||||
func (cb *CloudBroker) Node() *node.Node {
|
||||
return node.New(cb.client)
|
||||
}
|
||||
37
pkg/cloudbroker/node/apply_ipmi_action.go
Normal file
37
pkg/cloudbroker/node/apply_ipmi_action.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ApplyIpmiActionRequest struct to apply ipmi action on node
|
||||
type ApplyIpmiActionRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NID uint64 `url:"nid" json:"nid" validate:"required"`
|
||||
|
||||
// Action
|
||||
// on of actions power_on shutdown force_shutdown reboot
|
||||
// Required: true
|
||||
Action string `url:"action" json:"action" validate:"required,action"`
|
||||
}
|
||||
|
||||
// ApplyIpmiAction applies ipmi action on node
|
||||
func (n Node) ApplyIpmiAction(ctx context.Context, req ApplyIpmiActionRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/applyIpmiAction"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
40
pkg/cloudbroker/node/consumption.go
Normal file
40
pkg/cloudbroker/node/consumption.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ConsumptionRequest struct to get node summary by resources and consumption
|
||||
type ConsumptionRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NID uint64 `url:"nid" json:"nid" validate:"required"`
|
||||
}
|
||||
|
||||
// Consumption gets node summary by resources and consumption
|
||||
func (n Node) Consumption(ctx context.Context, req ConsumptionRequest) (*ConsumptionInfo, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/consumption"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := ConsumptionInfo{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
37
pkg/cloudbroker/node/decommission.go
Normal file
37
pkg/cloudbroker/node/decommission.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DecommissionRequest struct to set node status to DECOMMISSIONED
|
||||
type DecommissionRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NID uint64 `url:"nid" json:"nid" validate:"required"`
|
||||
|
||||
// Force node decommission
|
||||
// Default: false
|
||||
// Required: false
|
||||
Force bool `url:"force" json:"force"`
|
||||
}
|
||||
|
||||
// Decommission sets node status to DECOMMISSIONED
|
||||
func (n Node) Decommission(ctx context.Context, req DecommissionRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/decommission"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
40
pkg/cloudbroker/node/enable.go
Normal file
40
pkg/cloudbroker/node/enable.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// EnableRequest struct to enable node from maintenance status to enabled
|
||||
type EnableRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NID uint64 `url:"nid" json:"nid" validate:"required"`
|
||||
|
||||
// Message
|
||||
// Required: false
|
||||
Message string `url:"message,omitempty" json:"message,omitempty"`
|
||||
|
||||
// Reason
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// Enable enables node from maintenance status to enabled
|
||||
func (n Node) Enable(ctx context.Context, req EnableRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/enable"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
40
pkg/cloudbroker/node/enable_nodes.go
Normal file
40
pkg/cloudbroker/node/enable_nodes.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// EnableNodesRequest struct to enable nodes from maintenance status to enabled
|
||||
type EnableNodesRequest struct {
|
||||
// List of Node IDs
|
||||
// Required: true
|
||||
NIDs []uint64 `url:"nids" json:"nids" validate:"required"`
|
||||
|
||||
// Message
|
||||
// Required: false
|
||||
Message string `url:"message,omitempty" json:"message,omitempty"`
|
||||
|
||||
// Reason
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
// EnableNodes enables nodes from maintenance status to enabled
|
||||
func (n Node) EnableNodes(ctx context.Context, req EnableNodesRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/enableNodes"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
99
pkg/cloudbroker/node/filter.go
Normal file
99
pkg/cloudbroker/node/filter.go
Normal file
@@ -0,0 +1,99 @@
|
||||
package node
|
||||
|
||||
// FilterByID returns ListNodes with specified ID.
|
||||
func (ln ListNodes) FilterByID(id uint64) ListNodes {
|
||||
predicate := func(in ItemNode) bool {
|
||||
return in.ID == id
|
||||
}
|
||||
|
||||
return ln.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns ListNodes with specified Name.
|
||||
func (ln ListNodes) FilterByName(name string) ListNodes {
|
||||
predicate := func(in ItemNode) bool {
|
||||
return in.Name == name
|
||||
}
|
||||
|
||||
return ln.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByVersion return ListNodes with specified version.
|
||||
func (ln ListNodes) FilterByVersion(version string) ListNodes {
|
||||
predicate := func(in ItemNode) bool {
|
||||
return in.Version == version
|
||||
}
|
||||
|
||||
return ln.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByRelease returns ListNodes with specified Release.
|
||||
func (ln ListNodes) FilterByRelease(release string) ListNodes {
|
||||
predicate := func(in ItemNode) bool {
|
||||
return in.Release == release
|
||||
}
|
||||
|
||||
return ln.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterBySepID returns ListNodes with specified Sep ID.
|
||||
func (ln ListNodes) FilterBySepID(sepId uint64) ListNodes {
|
||||
predicate := func(in ItemNode) bool {
|
||||
for _, s := range in.Seps {
|
||||
if s == sepId {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return ln.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByRole returns ListNodes with specified Role.
|
||||
func (ln ListNodes) FilterByRole(role string) ListNodes {
|
||||
predicate := func(in ItemNode) bool {
|
||||
for _, r := range in.Roles {
|
||||
if r == role {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
return ln.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByStatus return ListNodes with specified status.
|
||||
func (ln ListNodes) FilterByStatus(status string) ListNodes {
|
||||
predicate := func(in ItemNode) bool {
|
||||
return in.Status == status
|
||||
}
|
||||
|
||||
return ln.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListNodes based on a user-specified predicate.
|
||||
func (ln ListNodes) FilterFunc(predicate func(ItemNode) bool) ListNodes {
|
||||
var result ListNodes
|
||||
|
||||
for _, item := range ln.Data {
|
||||
if predicate(item) {
|
||||
result.Data = append(result.Data, item)
|
||||
}
|
||||
}
|
||||
|
||||
result.EntryCount = uint64(len(result.Data))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found ItemNode.
|
||||
// If none was found, returns an empty struct.
|
||||
func (ln ListNodes) FindOne() ItemNode {
|
||||
if len(ln.Data) == 0 {
|
||||
return ItemNode{}
|
||||
}
|
||||
|
||||
return ln.Data[0]
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user