v1.16.4
v1.16.4
This commit is contained in:
42
pkg/cloudapi/vmfolder/computes_move.go
Normal file
42
pkg/cloudapi/vmfolder/computes_move.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// ComputesMoveRequest struct to move computes to a vm folder
|
||||
type ComputesMoveRequest struct {
|
||||
// IDs of computes to move
|
||||
// Required: true
|
||||
ComputeIDs []uint64 `url:"compute_ids" json:"compute_ids" validate:"required"`
|
||||
|
||||
// Target vm folder ID
|
||||
// Required: true
|
||||
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||
}
|
||||
|
||||
// ComputesMove moves computes to a vm folder
|
||||
func (v VMFolder) ComputesMove(ctx context.Context, req ComputesMoveRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vmfolder/computes_move"
|
||||
|
||||
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user