package disks import ( "context" "encoding/json" "net/http" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" ) // MigrateV2Target describes a target storage for a group of disks type MigrateV2Target struct { // IDs of detached disks to migrate // Required: true DiskIDs []uint64 `url:"disk_ids" json:"disk_ids" validate:"required,min=1,max=100,unique,dive,required"` // SEP ID // Required: true SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` // Name of a pool // Required: true PoolName string `url:"pool_name" json:"pool_name" validate:"required"` // Storage policy ID // Required: false StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"` } // MigrateV2Storage describes a destination for disks type MigrateV2Storage struct { // Targets for migration // Required: true Targets []MigrateV2Target `url:"targets" json:"targets" validate:"required,min=1,dive"` // Whether a separate source-disk cleanup job should be started after full success // Default: true // Required: false AutoCleanup interface{} `url:"auto_cleanup,omitempty" json:"auto_cleanup,omitempty" validate:"omitempty,isBool"` } // MigrateV2Request struct to start an offline migration of a group of detached disks type MigrateV2Request struct { // Bandwidth limit in bytes per second // Required: false BandwidthBytesPerSecond uint64 `url:"bandwidth_bytes_per_second,omitempty" json:"bandwidth_bytes_per_second,omitempty"` // Number of simultaneous copies // Required: false CopyParallelism uint64 `url:"copy_parallelism,omitempty" json:"copy_parallelism,omitempty"` // Destination for disks // Required: true Storage MigrateV2Storage `url:"storage" json:"storage"` } // MigrateV2 starts an offline migration of a group of detached disks and returns workflow job ID func (d Disks) MigrateV2(ctx context.Context, req MigrateV2Request) (string, error) { err := validators.ValidateRequest(req) if err != nil { return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/disks/migrate_v2" res, err := d.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req) if err != nil { return "", err } var resp string err = json.Unmarshal(res, &resp) if err != nil { return "", err } return resp, nil }