43 lines
915 B
Go
43 lines
915 B
Go
|
|
package vmfolder
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"net/http"
|
||
|
|
"strconv"
|
||
|
|
|
||
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||
|
|
)
|
||
|
|
|
||
|
|
// MoveRequest to move a vm folder to a compute
|
||
|
|
type MoveRequest struct {
|
||
|
|
// VM Folder ID
|
||
|
|
// Required: true
|
||
|
|
FolderID uint64 `url:"folder_id" json:"folder_id"`
|
||
|
|
|
||
|
|
// New parent folder ID
|
||
|
|
// Required: true
|
||
|
|
NewParentID uint64 `url:"new_parent_id" json:"new_parent_id"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// Move moves a vm folder to a compute
|
||
|
|
func (v VMFolder) Move(ctx context.Context, req MoveRequest) (bool, error) {
|
||
|
|
err := validators.ValidateRequest(req)
|
||
|
|
if err != nil {
|
||
|
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||
|
|
}
|
||
|
|
|
||
|
|
url := "/cloudapi/vmfolder/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
|
||
|
|
}
|