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,12 +7,18 @@ import (
"strconv"
)
// Request struct for delete basic service
type DeleteRequest struct {
ServiceID uint64 `url:"serviceId"`
Permanently bool `url:"permanently,omitempty"`
// ID of the BasicService to be delete
// Required: true
ServiceID uint64 `url:"serviceId"`
// If set to False, Basic service will be deleted to recycle bin. Otherwise destroyed immediately
// Required: true
Permanently bool `url:"permanently,omitempty"`
}
func (bsrq DeleteRequest) Validate() error {
func (bsrq DeleteRequest) validate() error {
if bsrq.ServiceID == 0 {
return errors.New("field ServiceID can not be empty or equal to 0")
}
@@ -20,16 +26,24 @@ func (bsrq DeleteRequest) Validate() error {
return nil
}
// Delete deletes BasicService instance
func (b BService) 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/bservice/delete"
res, err := b.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
}