package hypervisors

import (
	"context"
	"net/http"

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

// ConnectNodeRequest to connect a node
type ConnectNodeRequest struct {
	// Node to connect
	// Required: true
	NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
}

func (hv Hypervisors) ConnectNode(ctx context.Context, req ConnectNodeRequest) (string, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return "", validators.ValidationErrors(validators.GetErrors(err))
	}
	url := "/sdn/hypervisor/connect_node"
	result, err := hv.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
	if err != nil {
		return "", err
	}

	return string(result), nil
}
