v9.0.0
This commit is contained in:
50
pkg/cloudbroker/node/maintenance.go
Normal file
50
pkg/cloudbroker/node/maintenance.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/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
|
||||
}
|
||||
Reference in New Issue
Block a user