This commit is contained in:
2024-11-12 12:51:21 +03:00
parent f1e0f7abb6
commit 80491ed643
226 changed files with 3033 additions and 2633 deletions

View File

@@ -17,11 +17,22 @@ type EnableRequest struct {
// Required: false
Message string `url:"message,omitempty" json:"message,omitempty"`
// Do not check locks, iscsi-sessions or disk-present
// Default: true
// Required: false
Force interface{} `url:"force" json:"force" validate:"isBool" `
// Reason
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
type wrapperEnableRequest struct {
EnableRequest
AsyncMode bool `url:"asyncMode"`
}
// Enable enables node from maintenance status to enabled
func (n Node) Enable(ctx context.Context, req EnableRequest) (string, error) {
err := validators.ValidateRequest(req)
@@ -29,9 +40,44 @@ func (n Node) Enable(ctx context.Context, req EnableRequest) (string, error) {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
if req.Force == nil {
req.Force = true
}
reqWrapped := wrapperEnableRequest{
EnableRequest: req,
AsyncMode: false,
}
url := "/cloudbroker/node/enable"
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}
return string(res), nil
}
// EnableAsync enables node from maintenance status to enabled with AsyncMode
func (n Node) EnableAsync(ctx context.Context, req EnableRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
if req.Force == nil {
req.Force = true
}
reqWrapped := wrapperEnableRequest{
EnableRequest: req,
AsyncMode: true,
}
url := "/cloudbroker/node/enable"
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}

View File

@@ -16,10 +16,6 @@ type EnableNodesRequest struct {
// Message
// Required: false
Message string `url:"message,omitempty" json:"message,omitempty"`
// Reason
// Required: false
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}
// EnableNodes enables nodes from maintenance status to enabled