You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
package node
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
)
|
|
|
|
// MaintenanceRequest struct to place node in maintenance state
|
|
type MaintenanceRequest struct {
|
|
// Node ID
|
|
// Required: true
|
|
NID uint64 `url:"nid" json:"nid" validate:"required"`
|
|
|
|
// VM Action
|
|
// Default: stop
|
|
// Required: false
|
|
VMAction string `url:"vmaction,omitempty" json:"vmaction,omitempty" validate:"omitempty,vmaction"`
|
|
|
|
// Offline
|
|
// Default: false
|
|
// Required: false
|
|
Offline bool `url:"offline" json:"offline"`
|
|
|
|
// VDiskAction
|
|
// Required: false
|
|
VDiskAction string `url:"vdiskaction,omitempty" json:"vdiskaction,omitempty"`
|
|
|
|
// Reason
|
|
// Required: false
|
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
|
}
|
|
|
|
// Maintenance places node in maintenance state
|
|
func (n Node) Maintenance(ctx context.Context, req MaintenanceRequest) (string, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/node/maintenance"
|
|
|
|
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return string(res), nil
|
|
}
|