Files
dynamix-golang-sdk/pkg/cloudbroker/compute/migrate_storage.go

55 lines
1.4 KiB
Go
Raw Normal View History

2025-09-23 14:34:24 +03:00
package compute
import (
"context"
"net/http"
"strings"
2025-12-08 16:30:08 +03:00
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v13/internal/validators"
2025-09-23 14:34:24 +03:00
)
// MigrateStorageRequest struct for migration
type MigrateStorageRequest struct {
// ID of the compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// SEP ID to migrate disks
// Required: true
SEPID uint64 `url:"sepId" json:"sepId" validate:"required"`
// SEP pool name to migrate disks
// Required: true
PoolName string `url:"poolName" json:"poolName" validate:"required"`
2025-12-08 16:30:08 +03:00
// Target node ID
2025-09-23 14:34:24 +03:00
// Required: true
2025-12-08 16:30:08 +03:00
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
2025-09-23 14:34:24 +03:00
// Async API call
// Required: true
Sync bool `url:"sync" json:"sync" validate:"required"`
}
// MigrateStorage gets complex compute migration
2025-12-08 16:30:08 +03:00
// Compute will be migrated to specified node, and compute disks will
2025-09-23 14:34:24 +03:00
// be migrated to specified SEP to specified pool.
// This action can take up to 84 hours
func (c Compute) MigrateStorage(ctx context.Context, req MigrateStorageRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/compute/migrateStorage"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
result := strings.ReplaceAll(string(res), "\"", "")
return result, nil
}