You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decort-golang-sdk/pkg/cloudapi/rg/delete.go

52 lines
1.3 KiB

package rg
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// DeleteRequest struct to delete resource group
type DeleteRequest struct {
// Resource group ID
// Required: true
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
// Set to True if you want force delete non-empty resource group
// Required: false
Force bool `url:"force,omitempty" json:"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" json:"permanently,omitempty"`
// Reason for action
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// Delete deletes resource group
func (r RG) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/rg/delete"
res, err := r.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
}