v15.0.0
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v15/internal/validators"
|
||||
)
|
||||
|
||||
// GuestAgentExecuteRequest struct to execute command from user to agent
|
||||
@@ -23,6 +23,12 @@ type GuestAgentExecuteRequest struct {
|
||||
Arguments string `url:"arguments" json:"arguments" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperGuestAgentExecuteRequest struct {
|
||||
GuestAgentExecuteRequest
|
||||
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
}
|
||||
|
||||
// Execute guest agent command
|
||||
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -30,9 +36,14 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperGuestAgentExecuteRequest{
|
||||
GuestAgentExecuteRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/guest_agent_execute"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -46,3 +57,25 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GuestAgentExecuteRequestAsync executes guest agent command with AsyncMode
|
||||
func (c Compute) GuestAgentExecuteRequestAsync(ctx context.Context, req GuestAgentExecuteRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
reqWrapped := wrapperGuestAgentExecuteRequest{
|
||||
GuestAgentExecuteRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
url := "/cloudapi/compute/guest_agent_execute"
|
||||
|
||||
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