Files
decort-golang-sdk/pkg/cloudbroker/grid/services_restart.go

43 lines
956 B
Go
Raw Normal View History

2022-12-22 17:56:47 +03:00
package grid
import (
"context"
"net/http"
"strconv"
2023-03-24 17:09:30 +03:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
2022-12-22 17:56:47 +03:00
)
2023-10-25 17:37:18 +03:00
// ServicesRestartRequest struct to restart services
2022-12-22 17:56:47 +03:00
type ServicesRestartRequest struct {
// Grid (platform) ID
// Required: true
2023-10-25 17:37:18 +03:00
GID uint64 `url:"gid" json:"gid" validate:"required"`
2022-12-22 17:56:47 +03:00
// Node ID
// Required: true
2023-10-25 17:37:18 +03:00
NID uint64 `url:"nid" json:"nid" validate:"required"`
2022-12-22 17:56:47 +03:00
}
// ServicesRestart restarts decort services on the node
func (g Grid) ServicesRestart(ctx context.Context, req ServicesRestartRequest) (bool, error) {
2023-03-24 17:09:30 +03:00
err := validators.ValidateRequest(req)
2022-12-22 17:56:47 +03:00
if err != nil {
2023-10-25 17:37:18 +03:00
return false, validators.ValidationErrors(validators.GetErrors(err))
2022-12-22 17:56:47 +03:00
}
url := "/cloudbroker/grid/servicesRestart"
res, err := g.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
}