update go.mod and imports
This commit is contained in:
@@ -2,20 +2,21 @@ package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for move compute new resource group
|
||||
type MoveToRGRequest struct {
|
||||
// ID of the compute instance to move
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"computeId" json:"computeId"`
|
||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||
|
||||
// ID of the target resource group
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId"`
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// New name for the compute upon successful move,
|
||||
// if name change required.
|
||||
@@ -33,22 +34,13 @@ type MoveToRGRequest struct {
|
||||
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
||||
}
|
||||
|
||||
func (crq MoveToRGRequest) validate() error {
|
||||
if crq.ComputeID == 0 {
|
||||
return errors.New("validation-error: field ComputeID can not be empty or equal to 0")
|
||||
}
|
||||
if crq.RGID == 0 {
|
||||
return errors.New("validation-error: field RGID can not be empty or equal to 0")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MoveToRG moves compute instance to new resource group
|
||||
func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/moveToRg"
|
||||
|
||||
Reference in New Issue
Block a user