parent
42271b7a65
commit
12e0b306ba
@ -0,0 +1,46 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddStoragePolicyRequest struct for adding storage policy to the resource group
|
||||||
|
type AddStoragePolicyRequest struct {
|
||||||
|
// ID of resource group to add to
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"resgroup_id" json:"resgroup_id" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the storage policy to which to connect resource group
|
||||||
|
// 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 (r RG) AddStoragePolicy(ctx context.Context, req AddStoragePolicyRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/rg/add_storage_policy"
|
||||||
|
|
||||||
|
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := strconv.ParseBool(string(res))
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DelStoragePolicyRequest struct for deleting storage policy to the resource group
|
||||||
|
type DelStoragePolicyRequest struct {
|
||||||
|
// ID of resource group
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"resgroup_id" json:"resgroup_id" validate:"required"`
|
||||||
|
|
||||||
|
// ID of the storage policy to which to disconnect account
|
||||||
|
// Required: true
|
||||||
|
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelStoragePolicy delete storage policy to the account.
|
||||||
|
func (r RG) DelStoragePolicy(ctx context.Context, req DelStoragePolicyRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/rg/del_storage_policy"
|
||||||
|
|
||||||
|
res, err := r.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
|
||||||
|
}
|
||||||
Loading…
Reference in new issue