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

@@ -3,8 +3,9 @@ package compute
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
)
// ChangeLinkStateRequest struct to change link state
@@ -23,6 +24,12 @@ type ChangeLinkStateRequest struct {
State string `url:"state" json:"state" validate:"required,interfaceState"`
}
type wrapperChangeLinkStateRequest struct {
ChangeLinkStateRequest
AsyncMode bool `url:"asyncMode"`
}
// ChangeLinkState changes the status link virtual of compute
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -30,9 +37,14 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeLinkStateRequest{
ChangeLinkStateRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/changeLinkState"
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
}
@@ -41,5 +53,28 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
if err != nil {
return false, err
}
return result, nil
}
// ChangeLinkStateAsync changes the status link virtual of compute with AsyncMode
func (c Compute) ChangeLinkStateAsync(ctx context.Context, req ChangeLinkStateRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperChangeLinkStateRequest{
ChangeLinkStateRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/changeLinkState"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}