This commit is contained in:
2026-06-05 17:30:36 +03:00
parent 3e2edf53a5
commit f1112e5a11
1246 changed files with 6117 additions and 1589 deletions

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
)
// PowerCycleRequest struct to force stop and start compute
@@ -15,6 +15,12 @@ type PowerCycleRequest struct {
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
}
type wrapperPowerCycleRequest struct {
PowerCycleRequest
AsyncMode bool `url:"asyncMode"`
}
// PowerCycle makes force stop and start compute
func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -22,9 +28,14 @@ func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, e
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPowerCycleRequest{
PowerCycleRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/powerCycle"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -36,3 +47,25 @@ func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, e
return result, nil
}
// PowerCycleAsync makes force stop and start compute with AsyncMode
func (c Compute) PowerCycleAsync(ctx context.Context, req PowerCycleRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPowerCycleRequest{
PowerCycleRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/powerCycle"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}