v15.0.0
This commit is contained in:
@@ -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"
|
||||
)
|
||||
|
||||
// RedeployRequest struct to redeploy
|
||||
@@ -44,6 +44,12 @@ type RedeployRequest struct {
|
||||
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperRedeployRequest struct {
|
||||
RedeployRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Redeploy redeploys compute
|
||||
func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -51,9 +57,14 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperRedeployRequest{
|
||||
RedeployRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/redeploy"
|
||||
|
||||
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
|
||||
}
|
||||
@@ -65,3 +76,25 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RedeployAsync redeploys compute with AsyncMode
|
||||
func (c Compute) RedeployAsync(ctx context.Context, req RedeployRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperRedeployRequest{
|
||||
RedeployRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/redeploy"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user