package sep

import (
	"context"
	"encoding/json"
	"net/http"

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

// DelConsumerNodesRequest struct to exclude consumer nodes
type DelConsumerNodesRequest struct {
	// Storage endpoint provider ID
	// Required: true
	SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`

	// List of consumer node IDs
	// Required: true
	ConsumerNIDs []uint64 `url:"consumer_nids" json:"consumer_nids" validate:"min=1"`

	// The force flag must be set to true only if the node will never come back online
	// Default: false
	// Required: false
	Force bool `url:"force" json:"force"`
}

// DelConsumerNodes excludes consumer nodes from SEP parameters
func (s SEP) DelConsumerNodes(ctx context.Context, req DelConsumerNodesRequest) (interface{}, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return nil, validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/cloudbroker/sep/delConsumerNodes"

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

	var result interface{}

	err = json.Unmarshal(res, &result)
	if err != nil {
		return nil, err
	}

	return result, nil
}
