You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dynamix-golang-sdk/pkg/cloudbroker/account/add_storage_policy.go

47 lines
1.2 KiB

package account
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
)
// AddStoragePolicyRequest struct for adding storage policy to the account
type AddStoragePolicyRequest struct {
// ID of account to add to
// Required: true
AccountID uint64 `url:"account_id" json:"account_id" validate:"required"`
// ID of the storage policy to which to connect account
// Required: true
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
// Limit storage resources GB. Or -1 unlimit
// Required: false
Limit int `url:"limit,omitempty" json:"limit,omitempty"`
}
// AddStoragePolicy add storage policy to the account.
func (a Account) AddStoragePolicy(ctx context.Context, req AddStoragePolicyRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/account/add_storage_policy"
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}