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,11 +7,14 @@ import (
"strconv"
)
// Request struct for stop service
type StopRequest struct {
// ID of the service to stop
// Required: true
ServiceID uint64 `url:"serviceId"`
}
func (bsrq StopRequest) Validate() error {
func (bsrq StopRequest) validate() error {
if bsrq.ServiceID == 0 {
return errors.New("field ServiceID can not be empty or equal to 0")
}
@@ -19,16 +22,26 @@ func (bsrq StopRequest) Validate() error {
return nil
}
// Stop stops service.
// Stopping a service technically means stopping computes from
// all service groups
func (b BService) Stop(ctx context.Context, req StopRequest) (bool, error) {
if err := req.Validate(); err != nil {
err := req.validate()
if err != nil {
return false, err
}
url := "/cloudapi/bservice/stop"
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
}