package node

import (
	"context"
	"net/http"

	"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)

// EnableNodesRequest struct to enable nodes from maintenance status to enabled
type EnableNodesRequest struct {
	// List of Node IDs
	// Required: true
	NIDs []uint64 `url:"nids" json:"nids" validate:"required"`

	// Reason
	// Required: false
	Reason string `url:"reason,omitempty" json:"reason,omitempty"`
}

// EnableNodes enables nodes from maintenance status to enabled
func (n Node) EnableNodes(ctx context.Context, req EnableNodesRequest) (string, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return "", validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/cloudbroker/node/enableNodes"

	res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
	if err != nil {
		return "", err
	}

	return string(res), nil
}
