102 lines
2.6 KiB
Go
102 lines
2.6 KiB
Go
package disks
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
|
)
|
|
|
|
// MigrateV2ListRequest struct to get list of disks migrations
|
|
type MigrateV2ListRequest struct {
|
|
// Migration workflow job ID
|
|
// Required: false
|
|
WorkflowJobID string `url:"workflow_job_id,omitempty" json:"workflow_job_id,omitempty"`
|
|
|
|
// Disk ID
|
|
// Required: false
|
|
DiskID uint64 `url:"disk_id,omitempty" json:"disk_id,omitempty"`
|
|
|
|
// Account ID
|
|
// Required: false
|
|
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
|
|
|
|
// User name
|
|
// Required: false
|
|
User string `url:"user,omitempty" json:"user,omitempty"`
|
|
|
|
// User match mode
|
|
// Should be one of:
|
|
// - exact
|
|
// - prefix
|
|
// Default: exact
|
|
// Required: false
|
|
UserMatch string `url:"user_match,omitempty" json:"user_match,omitempty" validate:"omitempty,migrateV2UserMatch"`
|
|
|
|
// Find migrations without user
|
|
// Required: false
|
|
UserIsNull interface{} `url:"user_is_null,omitempty" json:"user_is_null,omitempty" validate:"omitempty,isBool"`
|
|
|
|
// Migration status
|
|
// Should be one of:
|
|
// - QUEUED
|
|
// - VALIDATING
|
|
// - PREPARING
|
|
// - MIGRATING
|
|
// - COMPLETING
|
|
// - ABORTING
|
|
// - NEEDS_ATTENTION
|
|
// - COMPLETED
|
|
// - PARTIALLY_COMPLETED
|
|
// - ABORTED
|
|
// - ERROR
|
|
// - RESOLVED
|
|
// Required: false
|
|
Status string `url:"status,omitempty" json:"status,omitempty" validate:"omitempty,migrateV2Status"`
|
|
|
|
// Whether retained source disks still require cleanup
|
|
// Required: false
|
|
CleanupRequired interface{} `url:"cleanup_required,omitempty" json:"cleanup_required,omitempty" validate:"omitempty,isBool"`
|
|
|
|
// Page number
|
|
// Default: 1
|
|
// Required: false
|
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
|
|
|
// Page size
|
|
// Default: 100
|
|
// Required: false
|
|
Size uint64 `url:"size,omitempty" json:"size,omitempty" validate:"omitempty,max=500"`
|
|
}
|
|
|
|
// MigrateV2List gets list of disks migrations as a ListMigrateV2 struct
|
|
func (d Disks) MigrateV2List(ctx context.Context, req MigrateV2ListRequest) (*ListMigrateV2, error) {
|
|
res, err := d.MigrateV2ListRaw(ctx, req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
list := ListMigrateV2{}
|
|
|
|
err = json.Unmarshal(res, &list)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &list, nil
|
|
}
|
|
|
|
// MigrateV2ListRaw gets list of disks migrations as an array of bytes
|
|
func (d Disks) MigrateV2ListRaw(ctx context.Context, req MigrateV2ListRequest) ([]byte, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/disks/migrate_v2_list"
|
|
|
|
res, err := d.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
|
return res, err
|
|
}
|