package secpolicies

import (
	"context"
	"net/http"

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

// DeleteRequest struct to delete security policy
type DeleteRequest struct {
	// Security policy ID
	// Required: true
	SecurityPolicyID string `url:"security_policy_id" json:"security_policy_id" validate:"required"`

	// Version ID
	// 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 a security policy
func (i SecurityPolicies) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return false, validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/sdn/security_policy/delete"

	_, err = i.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
	if err != nil {
		return false, err
	}

	return true, nil
}
