v1.3.0
This commit is contained in:
@@ -2,45 +2,34 @@ package grid
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for execute script
|
||||
type ExecuteMaintenanceScriptRequest struct {
|
||||
// Grid (platform) ID
|
||||
// Required: true
|
||||
GID string `url:"gid" json:"gid"`
|
||||
GID string `url:"gid" json:"gid" validate:"required"`
|
||||
|
||||
// Type of nodes you want to apply the action on
|
||||
// Required: true
|
||||
NodesType string `url:"nodestype" json:"nodestype"`
|
||||
NodesType string `url:"nodestype" json:"nodestype" validate:"required"`
|
||||
|
||||
// The script you want to run
|
||||
// Required: true
|
||||
Script string `url:"script" json:"script"`
|
||||
}
|
||||
|
||||
func (grq ExecuteMaintenanceScriptRequest) validate() error {
|
||||
if grq.GID == "" {
|
||||
return errors.New("validation-error: field GID must be set")
|
||||
}
|
||||
if grq.NodesType == "" {
|
||||
return errors.New("validation-error: field NodesType must be set")
|
||||
}
|
||||
if grq.Script == "" {
|
||||
return errors.New("validation-error: field Script must be set")
|
||||
}
|
||||
|
||||
return nil
|
||||
Script string `url:"script" json:"script" validate:"required"`
|
||||
}
|
||||
|
||||
// ExecuteMaintenanceScript executes maintenance script
|
||||
func (g Grid) ExecuteMaintenanceScript(ctx context.Context, req ExecuteMaintenanceScriptRequest) (bool, error) {
|
||||
err := req.validate()
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
url := "/cloudbroker/grid/executeMaintenanceScript"
|
||||
|
||||
Reference in New Issue
Block a user