This commit is contained in:
2023-03-24 17:09:30 +03:00
parent 437841c8dd
commit 84b64b7d80
433 changed files with 4246 additions and 6516 deletions

View File

@@ -2,49 +2,33 @@ package compute
import (
"context"
"errors"
"net/http"
"strings"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for migration
type MigrateStorageRequest struct {
// ID of the compute instance
// Required: true
ComputeID uint64 `url:"computeId" json:"computeId"`
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
// SEP ID to migrate disks
// Required: true
SEPID uint64 `url:"sepId" json:"sepId"`
SEPID uint64 `url:"sepId" json:"sepId" validate:"required"`
// SEP pool name to migrate disks
// Required: true
PoolName string `url:"poolName" json:"poolName"`
PoolName string `url:"poolName" json:"poolName" validate:"required"`
// Target stack ID
// Required: true
StackID uint64 `url:"stackId" json:"stackId"`
StackID uint64 `url:"stackId" json:"stackId" validate:"required"`
// Async API call
// Required: true
Sync bool `url:"sync" json:"sync"`
}
func (crq MigrateStorageRequest) validate() error {
if crq.ComputeID == 0 {
return errors.New("validation-error: field ComputeID must be set")
}
if crq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if crq.PoolName == "" {
return errors.New("validation-error: field PoolName must be set")
}
if crq.StackID == 0 {
return errors.New("validation-error: field StackID must be set")
}
return nil
Sync bool `url:"sync" json:"sync" validate:"required"`
}
// MigrateStorage gets complex compute migration
@@ -52,9 +36,11 @@ func (crq MigrateStorageRequest) validate() error {
// 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 := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return "", err
for _, validationError := range validators.GetErrors(err) {
return "", validators.ValidationError(validationError)
}
}
url := "/cloudbroker/compute/migrateStorage"