package account import ( "context" "net/http" "strconv" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" ) // DelStoragePolicyRequest struct for deleting storage policy to the account type DelStoragePolicyRequest struct { // ID of account // Required: true AccountID uint64 `url:"account_id" json:"account_id" validate:"required"` // ID of the storage policy to which to disconnect account // Required: true StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"` } type wrapperDelStoragePolicyRequest struct { DelStoragePolicyRequest AsyncMode bool `url:"async_mode" json:"async_mode"` } // DelStoragePolicy delete storage policy to the account. func (a Account) DelStoragePolicy(ctx context.Context, req DelStoragePolicyRequest) (bool, error) { err := validators.ValidateRequest(req) if err != nil { return false, validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/account/del_storage_policy" reqWrapped := wrapperDelStoragePolicyRequest{ DelStoragePolicyRequest: req, AsyncMode: false, } res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) if err != nil { return false, err } result, err := strconv.ParseBool(string(res)) if err != nil { return false, err } return result, nil } // DelStoragePolicyAsync delete storage policy to the account in async mode func (a Account) DelStoragePolicyAsync(ctx context.Context, req DelStoragePolicyRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/account/del_storage_policy" reqWrapped := wrapperDelStoragePolicyRequest{ DelStoragePolicyRequest: req, AsyncMode: true, } res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) if err != nil { return "", err } return string(res), nil }