v13.5.0
This commit is contained in:
42
pkg/cloudbroker/node/autostart.go
Normal file
42
pkg/cloudbroker/node/autostart.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v13/internal/validators"
|
||||
)
|
||||
|
||||
// AutoStartRequest struct to set node autostart
|
||||
type AutoStartRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
|
||||
// Auto start
|
||||
// Required: true
|
||||
AutoStart bool `url:"autostart" json:"autostart" validate:"required"`
|
||||
}
|
||||
|
||||
// AutoStart sets node autostart
|
||||
func (n Node) AutoStart(ctx context.Context, req AutoStartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/node/autostart"
|
||||
|
||||
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -26,6 +26,11 @@ type MaintenanceRequest struct {
|
||||
// Reason
|
||||
// Required: false
|
||||
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||
|
||||
// Allow node auto-enable
|
||||
// Default: false
|
||||
// Required: false
|
||||
AutoStart bool `url:"autostart" json:"autostart"`
|
||||
}
|
||||
|
||||
// Maintenance places node in maintenance state
|
||||
|
||||
@@ -85,6 +85,12 @@ type RecordNode struct {
|
||||
|
||||
// CPU used by the node
|
||||
UsableCPUs []string `json:"usable_cpus"`
|
||||
|
||||
// AutoStart
|
||||
AutoStart bool `json:"autostart"`
|
||||
|
||||
// AutoStart Count
|
||||
AutoStartCount uint64 `json:"autostart_count"`
|
||||
}
|
||||
|
||||
// Resource consumption of the node
|
||||
@@ -301,6 +307,12 @@ type ItemNode struct {
|
||||
|
||||
// CPU used by the node
|
||||
UsableCPUs []string `json:"usable_cpus"`
|
||||
|
||||
// AutoStart
|
||||
AutoStart bool `json:"autostart"`
|
||||
|
||||
// AutoStart Count
|
||||
AutoStartCount uint64 `json:"autostart_count"`
|
||||
}
|
||||
|
||||
type PackageInfo struct {
|
||||
|
||||
Reference in New Issue
Block a user