package node

import (
	"context"
	"net/http"

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

// SetCoreIsolationRequest struct to isolate selected cores on node boot
type SetCoreIsolationRequest struct {
	// Node ID
	// Required: true
	NID uint64 `url:"nid" json:"nid" validate:"required"`

	// List of core number to isolate
	// Required: false
	CoreList []uint64 `url:"coreList,omitempty" json:"coreList,omitempty"`
}

// SetCoreIsolation isolates selected cores on node boot
func (n Node) SetCoreIsolation(ctx context.Context, req SetCoreIsolationRequest) (string, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return "", validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/cloudbroker/node/setCoreIsolation"

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

	return string(res), nil
}
