2025-09-27 01:06:15 +03:00
|
|
|
package disks
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"net/http"
|
|
|
|
|
|
2026-08-21 18:12:55 +04:00
|
|
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
2025-09-27 01:06:15 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Migrate struct to move disk to another sep, pool and storage policy
|
|
|
|
|
type MigrateRequest struct {
|
|
|
|
|
// ID of the disk
|
|
|
|
|
// Required: true
|
|
|
|
|
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
|
|
|
|
|
|
|
|
|
|
// ID of the new SEP
|
|
|
|
|
// Required: true
|
|
|
|
|
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
|
|
|
|
|
|
|
|
|
|
// New pool name
|
|
|
|
|
// Required: true
|
|
|
|
|
PoolName string `url:"pool_name" json:"pool_name" validate:"required"`
|
|
|
|
|
|
2026-06-05 17:30:36 +03:00
|
|
|
// ID of the storage policy
|
|
|
|
|
// Required: true
|
|
|
|
|
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
2025-09-27 01:06:15 +03:00
|
|
|
}
|
|
|
|
|
|
2026-08-21 18:12:55 +04:00
|
|
|
type wrapperMigrateRequest struct {
|
|
|
|
|
MigrateRequest
|
|
|
|
|
|
|
|
|
|
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Move moves disk to another sep, pool and storage policy in sync mode
|
2025-09-27 01:06:15 +03:00
|
|
|
func (c Disks) Migrate(ctx context.Context, req MigrateRequest) (string, error) {
|
|
|
|
|
err := validators.ValidateRequest(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-21 18:12:55 +04:00
|
|
|
wrappedReq := wrapperMigrateRequest{
|
|
|
|
|
MigrateRequest: req,
|
|
|
|
|
AsyncMode: false,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
url := "/cloudbroker/disks/migrate"
|
|
|
|
|
|
|
|
|
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result := string(res)
|
|
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Move moves disk to another sep, pool and storage policy in async mode
|
|
|
|
|
func (c Disks) MigrateAsync(ctx context.Context, req MigrateRequest) (string, error) {
|
|
|
|
|
err := validators.ValidateRequest(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wrappedReq := wrapperMigrateRequest{
|
|
|
|
|
MigrateRequest: req,
|
|
|
|
|
AsyncMode: true,
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 01:06:15 +03:00
|
|
|
url := "/cloudbroker/disks/migrate"
|
|
|
|
|
|
2026-08-21 18:12:55 +04:00
|
|
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, wrappedReq)
|
2025-09-27 01:06:15 +03:00
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result := string(res)
|
|
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
|
}
|