This commit is contained in:
dayterr
2026-01-23 16:36:21 +03:00
parent 25fa57f583
commit 403574496b
16 changed files with 145 additions and 61 deletions

View File

@@ -10,6 +10,9 @@ type ListZones struct {
// Detailed information about the zone record
type RecordZone struct {
// If true, all nodes belonging to the given zone will be marked for autostart
AutoStart bool `json:"autostart"`
// ID
ID uint64 `json:"id"`

View File

@@ -0,0 +1,43 @@
package zone
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v13/internal/validators"
)
// NodeAutoStartRequest struct to set node autostart in zone
type NodeAutoStartRequest struct {
// ID of zone
// Required: true
ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
// AutoStart nodes in zone
// Required: true
AutoStart bool `url:"autostart" json:"autostart" validate:"required"`
}
// NodeAutoStart sets node autostart in zone
func (e Zone) NodeAutoStart(ctx context.Context, req NodeAutoStartRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/zone/node_autostart"
res, err := e.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
}

View File

@@ -21,6 +21,10 @@ type UpdateRequest struct {
// Description
// Required: false
Description string `url:"description,omitempty" json:"description,omitempty"`
// If true, all nodes belonging to the given zone will be marked for autostart
// Required: false
AutoStart interface{} `url:"autostart,omitempty" json:"autostart,omitempty" validate:"omitempty,isBool"`
}
// Update updates zone object