v1.16.4
v1.16.4
This commit is contained in:
42
pkg/cloudapi/vmfolder/rename.go
Normal file
42
pkg/cloudapi/vmfolder/rename.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package vmfolder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// RenameRequest struct to rename a VM folder
|
||||
type RenameRequest struct {
|
||||
// ID of a folder to rename
|
||||
// Required: true
|
||||
FolderID uint64 `url:"folder_id" json:"folder_id" validate:"required"`
|
||||
|
||||
// A new name
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
// Rename renames a vm folder
|
||||
func (v VMFolder) Rename(ctx context.Context, req RenameRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/vmfolder/rename"
|
||||
|
||||
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