package routers

import (
	"context"
	"net/http"

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

// DeleteRequest struct for delete router
type DeleteRequest struct {
	// ID of router
	// Required: true
	RouterID string `url:"router_id" json:"router_id" validate:"required"`

	// ID of version
	// Required: true
	VersionID uint64 `url:"version_id" json:"version_id" validate:"required"`

	// Force delete
	// Required: false
	Force interface{} `url:"force,omitempty" json:"force,omitempty" validate:"omitempty,isBool"`
}

// Delete delete a router
func (e Routers) Delete(ctx context.Context, req DeleteRequest) error {
	err := validators.ValidateRequest(req)
	if err != nil {
		return validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/sdn/router/delete"

	_, err = e.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)

	if err != nil {
		return err
	}

	return nil
}
