package endpoint

import (
	"context"

	globaldedicatedv1 "github.com/tidbcloud/tidb-management-service/api/spec/global/dedicated/v1"
	"github.com/tidbcloud/tidb-management-service/dedicated-global-service/domain/entity"
	"github.com/tidbcloud/tidb-management-service/utilities/bizerr"
)

type PrivateLinkEndpointFilter struct {
	TenantIDs    []uint64
	ProjectIDs   []uint64
	ClusterIDs   []uint64
	IDs          []uint64 // repo pk
	EndpointIDs  []string // cloud provider resource id/name
	TidbGroupIDs []uint64
	Types        []globaldedicatedv1.PrivateLinkEndpoint_Type
}

//go:generate go run go.uber.org/mock/mockgen@latest -source=$GOFILE -package=mock_$GOPACKAGE -destination=./mock_$GOPACKAGE/mock_$GOFILE
type PrivateLinkEndpointRepo interface {
	Create(ctx context.Context, endpoint *entity.PrivateLinkEndpoint) bizerr.BizError
	// DeleteByIDOrEndpointID will delete the record using id when it is greater than 0, otherwise, using the endpointID
	// For some historical reasons, some endpoints do not save in DB and do not have id
	DeleteByIDOrEndpointID(ctx context.Context, clusterID, id, tidbGroupId uint64, endpointID string) bizerr.BizError
	DeleteByTidbGroupID(ctx context.Context, clusterID, tidbGroupId uint64) (affectedLines int64, _ bizerr.BizError)
	DeleteByClusterID(ctx context.Context, clusterID uint64) bizerr.BizError
	Query(ctx context.Context, filter *PrivateLinkEndpointFilter) ([]*entity.PrivateLinkEndpoint, bizerr.BizError)
	Load(ctx context.Context, id uint64) (*entity.PrivateLinkEndpoint, bizerr.BizError)
	CutoverEndpointMeta(ctx context.Context, sourceClusterId, sourceTidbGroupId, targetClusterId, targetTidbGroupId uint64) bizerr.BizError
}
