This commit is contained in:
stSolo
2022-12-22 17:56:47 +03:00
parent 8712561853
commit d4b1ab7133
672 changed files with 28509 additions and 4419 deletions

View File

@@ -7,14 +7,27 @@ import (
"strconv"
)
// Request struct for delete resource group
type DeleteRequest struct {
RGID uint64 `url:"rgId"`
Force bool `url:"force,omitempty"`
Permanently bool `url:"permanently,omitempty"`
Reason string `url:"reason,omitempty"`
// Resource group ID
// Required: true
RGID uint64 `url:"rgId"`
// Set to True if you want force delete non-empty resource group
// Required: false
Force bool `url:"force,omitempty"`
// Set to True if you want to destroy resource group and all linked resources, if any, immediately.
// Otherwise, they will be placed into recycle bin and could be restored later within recycle bin's purge period
// Required: false
Permanently bool `url:"permanently,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty"`
}
func (rgrq DeleteRequest) Validate() error {
func (rgrq DeleteRequest) validate() error {
if rgrq.RGID == 0 {
return errors.New("field RGID can not be empty or equal to 0")
}
@@ -22,16 +35,24 @@ func (rgrq DeleteRequest) Validate() error {
return nil
}
// Delete deletes resource group
func (r RG) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
if err := req.Validate(); err != nil {
err := req.validate()
if err != nil {
return false, err
}
url := "/cloudapi/rg/delete"
res, err := r.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
return strconv.ParseBool(string(res))
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}