This commit is contained in:
2026-06-05 17:14:39 +03:00
parent e9adcfec1c
commit fea00bbb42
157 changed files with 4837 additions and 251 deletions

View File

@@ -20,6 +20,12 @@ type PinToNodeRequest struct {
AutoStart bool `url:"autoStart" json:"autoStart"`
}
type wrapperPinToNodeRequest struct {
PinToNodeRequest
AsyncMode bool `url:"asyncMode"`
}
// PinToNode pin compute to current node
func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, error) {
err := validators.ValidateRequest(req)
@@ -27,9 +33,14 @@ func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, err
return false, validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPinToNodeRequest{
PinToNodeRequest: req,
AsyncMode: false,
}
url := "/cloudapi/compute/pin_to_node"
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,3 +52,25 @@ func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, err
return result, nil
}
// PinToNodeAsync pins compute to current node with AsyncMode
func (c Compute) PinToNodeAsync(ctx context.Context, req PinToNodeRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
reqWrapped := wrapperPinToNodeRequest{
PinToNodeRequest: req,
AsyncMode: true,
}
url := "/cloudapi/compute/pin_to_node"
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}