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.
43 lines
1.1 KiB
43 lines
1.1 KiB
package disks
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v12/internal/validators"
|
|
)
|
|
|
|
// ChangeDiskStoragePolicyRequest struct to change storage policy for disk
|
|
type ChangeDiskStoragePolicyRequest struct {
|
|
// ID of the disk
|
|
// Required: true
|
|
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
|
|
|
|
// ID of the storage policy to which to connect for disk
|
|
// Required: true
|
|
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
|
}
|
|
|
|
// ChangeDiskStoragePolicy changes storage policy for disk
|
|
func (d Disks) ChangeDiskStoragePolicy(ctx context.Context, req ChangeDiskStoragePolicyRequest) (bool, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudapi/disks/change_disk_storage_policy"
|
|
|
|
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
|
|
}
|