package segments

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 segment
type DeleteRequest struct {
	// ID of segment
	// Required: true
	SegmentID string `url:"segment_id" json:"segment_id" validate:"required"`

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

	// Force delete
	// Required: false
	Force bool `url:"force,omitempty" json:"force,omitempty"`
}

// Delete delete an segment
func (s Segments) Delete(ctx context.Context, req DeleteRequest) error {
	err := validators.ValidateRequest(req)
	if err != nil {
		return validators.ValidationErrors(validators.GetErrors(err))
	}

	url := "/sdn/segment/delete"

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

	if err != nil {
		return err
	}

	return nil
}
