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/bservice/delete.go

50 lines
1011 B

3 years ago
package bservice
import (
"context"
"errors"
"net/http"
3 years ago
"strconv"
)
3 years ago
// Request struct for delete basic service
3 years ago
type DeleteRequest struct {
3 years ago
// 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"`
3 years ago
}
3 years ago
func (bsrq DeleteRequest) validate() error {
3 years ago
if bsrq.ServiceID == 0 {
return errors.New("field ServiceID can not be empty or equal to 0")
}
return nil
}
3 years ago
// Delete deletes BasicService instance
func (b BService) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
3 years ago
err := req.validate()
if err != nil {
3 years ago
return false, err
}
url := "/cloudapi/bservice/delete"
3 years ago
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
3 years ago
if err != nil {
return false, err
}
3 years ago
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
3 years ago
}