package cluster

import (
	openapidedicatedv1beta1 "github.com/tidbcloud/tidb-management-service/api/spec/tidb_cloud_open_api/dedicated/v1beta1"
	tidbmgmtservicev1 "github.com/tidbcloud/tidb-management-service/api/spec/tidb_mgmt_service/v1"
	"github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/adapter/account"
	"github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/adapter/dedicatedglobal"
	"github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/adapter/nextgenglobal"
	"github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/repository"
	"github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/service/customstatus"
	dedicateclusersvc "github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/service/dedicated/cluster"
	nextgenclusersvc "github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/service/nextgen/cluster"
	serverlessclustersvc "github.com/tidbcloud/tidb-management-service/tidb-mgmt-service/domain/service/serverless/cluster"
)

func NewServer(
	serverlessClusterSvc serverlessclustersvc.Service,
	dedicateClusterSvc dedicateclusersvc.Service,
	nextgenClusterSvc nextgenclusersvc.Service,
	customStatusSvc customstatus.Service,
	dedicatedCli dedicatedglobal.DedicatedGlobal,
	accountCli account.Client,
	nextgenCli nextgenglobal.NextGenGlobal,
	openApiDedicatedRegionApp openapidedicatedv1beta1.RegionServiceServer,
	clusterRepo repository.ClusterRepository,
) tidbmgmtservicev1.ClusterServiceServer {
	return &serverImpl{
		serverlessClusterSvc:      serverlessClusterSvc,
		dedicatedClusterSvc:       dedicateClusterSvc,
		nextgenClusterSvc:         nextgenClusterSvc,
		customStatusSvc:           customStatusSvc,
		dedicatedCli:              dedicatedCli,
		accountCli:                accountCli,
		nextgenCli:                nextgenCli,
		openApiDedicatedRegionApp: openApiDedicatedRegionApp,
		clusterRepo:               clusterRepo,
	}
}

type serverImpl struct {
	serverlessClusterSvc      serverlessclustersvc.Service
	dedicatedClusterSvc       dedicateclusersvc.Service
	nextgenClusterSvc         nextgenclusersvc.Service
	customStatusSvc           customstatus.Service
	dedicatedCli              dedicatedglobal.DedicatedGlobal
	accountCli                account.Client
	nextgenCli                nextgenglobal.NextGenGlobal
	openApiDedicatedRegionApp openapidedicatedv1beta1.RegionServiceServer

	// for list clusters
	clusterRepo repository.ClusterRepository
}
