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

51 lines
1.3 KiB
Go
Raw Normal View History

2025-09-23 14:34:24 +03:00
package compute
import (
"context"
2026-07-10 15:44:33 +03:00
"encoding/json"
2025-09-23 14:34:24 +03:00
"net/http"
2026-06-05 17:30:36 +03:00
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
2025-09-23 14:34:24 +03:00
)
// MigrateStorageInfoRequest struct to get info about migration
type MigrateStorageInfoRequest struct {
// ID of the compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
// MigrateStorageInfo gets info about last (include ongoing) storage migration
2026-07-10 15:44:33 +03:00
func (c Compute) MigrateStorageInfo(ctx context.Context, req MigrateStorageInfoRequest) (*RecordMigrateStorageInfo, error) {
res, err := c.MigrateStorageInfoRaw(ctx, req)
if err != nil {
return nil, err
}
info := RecordMigrateStorageInfo{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// MigrateStorageInfoRaw gets info about last (include ongoing) storage migration as an array of bytes
func (c Compute) MigrateStorageInfoRaw(ctx context.Context, req MigrateStorageInfoRequest) ([]byte, error) {
2025-09-23 14:34:24 +03:00
err := validators.ValidateRequest(req)
if err != nil {
2026-07-10 15:44:33 +03:00
return nil, validators.ValidationErrors(validators.GetErrors(err))
2025-09-23 14:34:24 +03:00
}
url := "/cloudbroker/compute/migrateStorageInfo"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
2026-07-10 15:44:33 +03:00
return nil, err
2025-09-23 14:34:24 +03:00
}
2026-07-10 15:44:33 +03:00
return res, nil
2025-09-23 14:34:24 +03:00
}