package acsgroups

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 access group
type DeleteRequest struct {
	// ID of the access group
	// Required: true
	GroupID string `url:"access_group_id" json:"access_group_id" validate:"required"`
}

// Delete an access groups
func (i AccessGroups) Delete(ctx context.Context, req DeleteRequest) (string, error) {
	err := validators.ValidateRequest(req)
	if err != nil {
		return "", validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/sdn/access_group/delete"

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

	return string(res), nil
}
