package ticdc

import (
	"context"

	"github.com/tidbcloud/dataflow-service/app/models/domain"
	"github.com/tidbcloud/pkgv2/bizerr"
)

type MachineManager interface {
	Query(
		ctx context.Context, req *domain.QuerySpecificationReq,
	) (*domain.QuerySpecificationResp, bizerr.BizError)
	ListSpecifications(
		ctx context.Context, req *domain.ListSpecificationsReq,
	) (*domain.ListSpecificationsResp, bizerr.BizError)
}

//nolint:interfacebloat
type ClusterModel interface {
	Create(ctx context.Context, req *domain.CreateTiCDCClusterReq) (*domain.CreateTiCDCClusterResp, bizerr.BizError)
	Scale(ctx context.Context, req *domain.ScaleTiCDCClusterReq) (*domain.ScaleTiCDCClusterResp, bizerr.BizError)
	Query(ctx context.Context, req *domain.QueryTiCDCClusterReq) (*domain.QueryTiCDCClusterResp, bizerr.BizError)
	Delete(ctx context.Context, req *domain.DeleteTiCDCClusterReq) (*domain.DeleteTiCDCClusterResp, bizerr.BizError)
	ApplyConfig(ctx context.Context, req *domain.ApplyTiCDCClusterConfigReq) bizerr.BizError
	UpdateStorage(ctx context.Context, req *domain.UpdateTiCDCClusterStorageReq) bizerr.BizError
	List(ctx context.Context, req *domain.ListTiCDCClustersReq) (*domain.ListTiCDCClustersResp, bizerr.BizError)
	Restart(ctx context.Context, req *domain.RestartTiCDCClusterReq) bizerr.BizError
	GetRole(ctx context.Context, req *domain.GetTiCDCClusterRoleReq) (*domain.GetTiCDCClusterRoleResp, bizerr.BizError)
	GetExistingClusterVersion(
		ctx context.Context, req *domain.GetExistingTiCDCClusterVersionReq,
	) (*domain.GetExistingTiCDCClusterVersionResp, bizerr.BizError)
	GetNewClusterVersion(
		ctx context.Context, req *domain.GetNewTiCDCClusterVersionReq,
	) (*domain.GetNewTiCDCClusterVersionResp, bizerr.BizError)
}

//nolint:interfacebloat
type ChangefeedModel interface {
	CreateChangefeed(ctx context.Context, req *domain.CreateChangefeedReq) (*domain.CreateChangefeedResp, bizerr.BizError)
	DeleteChangefeed(ctx context.Context, req *domain.DeleteChangefeedReq) (*domain.DeleteChangefeedResp, bizerr.BizError)
	ModifyChangefeedConfig(
		ctx context.Context, req *domain.ModifyChangefeedConfigReq) (*domain.ModifyChangefeedConfigResp, bizerr.BizError)
	PauseChangefeed(ctx context.Context, req *domain.PauseChangefeedReq) (*domain.PauseChangefeedResp, bizerr.BizError)
	ResumeChangefeed(ctx context.Context, req *domain.ResumeChangefeedReq) (*domain.ResumeChangefeedResp, bizerr.BizError)
	ListChangefeeds(ctx context.Context, req *domain.ListChangefeedsReq) (*domain.ListChangefeedsResp, bizerr.BizError)
	QueryChangefeed(ctx context.Context, req *domain.QueryChangefeedReq) (*domain.QueryChangefeedResp, bizerr.BizError)
	MarkChangefeedDeleted(
		ctx context.Context, req *domain.MarkChangefeedDeletedReq,
	) (*domain.MarkChangefeedDeletedResp, bizerr.BizError)
	// GetChangefeedDetail returns the ticdc kernel changefeed configuration the for E2E test cases
	GetChangefeedDetail(ctx context.Context,
		req *domain.GetChangefeedDetailReq) (*domain.GetChangefeedDetailResp, bizerr.BizError)
	// GetTiCDCCluster return the ticdc cluster deployment topology detail information for E2E test cases
	GetTiCDCCluster(ctx context.Context,
		req *domain.GetChangefeedClusterReq) (*domain.GetChangefeedClusterResp, bizerr.BizError)
	ListTiCDCClusters(ctx context.Context,
		req *domain.ListTiCDCClusterReq) (*domain.ListTiCDCClusterResp, bizerr.BizError)
	DescribeSchemaTable(ctx context.Context,
		req *domain.DescribeSchemaTableReq,
	) (*domain.DescribeSchemaTableResp, bizerr.BizError)
}

type LongTermSynchronization interface {
	SyncAllChangefeed(ctx context.Context) bizerr.BizError
}

type ChangefeedTrafficMeter interface {
	MeterChangefeedTraffic(
		ctx context.Context, req *domain.MeterChangefeedTrafficReq) (*domain.MeterChangefeedTrafficResp, bizerr.BizError)
}

type ClusterWorker interface {
	SyncAllTiCDCClusters(ctx context.Context) bizerr.BizError
}
