v1.15.0
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user