package config_manager

import (
	"context"

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

type ConfigCenterManager interface {
	// GetConfigVersion gets config and image of a component
	GetConfigVersion(ctx context.Context, req *domain.GetConfigVersionReq) (*domain.ConfigVersionInfo, bizerr.BizError)
	// InitConfigVersion initializes config and version of a component
	InitConfigVersion(ctx context.Context, req *domain.InitConfigVersionReq) bizerr.BizError
	// InitConfigVersion + GetConfigVersion
	GetAndInitConfigVersion(
		ctx context.Context, req *domain.InitConfigVersionReq) (*domain.ConfigVersionInfo, bizerr.BizError)
	// UpdateConfigVersion updates config or version of a component
	// it is only used to complete the request of ops portal
	UpdateConfigVersion(ctx context.Context, req *domain.UpdateConfigVersionReq) bizerr.BizError
	// UpdateVersion only updates the version of a component, will update image and config template
	UpdateVersion(ctx context.Context, req *domain.UpdateVersionReq) bizerr.BizError
	// GetComponentDefaultConfigVersion get version of a component
	GetComponentDefaultConfigVersion(
		ctx context.Context, req *domain.GetDefaultVersionReq,
	) (*domain.DefaultVersionInfo, bizerr.BizError)
}

type TiCDCClusterConfigManager interface {
	Create(
		ctx context.Context, req *domain.CreateTiCDCClusterConfigReq,
	) (*domain.CreateTiCDCClusterConfigResp, bizerr.BizError)
	Update(ctx context.Context, req *domain.UpdateTiCDCClusterConfigReq) bizerr.BizError
	Get(ctx context.Context, req *domain.GetTiCDCClusterConfigReq) (*domain.GetTiCDCClusterConfigResp, bizerr.BizError)
	PatchConfig(ctx context.Context, req *domain.PatchTiCDCClusterConfigReq) bizerr.BizError
	GetNewClusterImage(
		ctx context.Context, req *domain.GetNewTiCDCClusterImageReq,
	) (*domain.GetNewTiCDCClusterImageResp, bizerr.BizError)
	// GetVersionAndImageTag reads the configured version and effective image tag
	// of a TiCDC cluster component from the config center.
	GetVersionAndImageTag(
		ctx context.Context, req *domain.GetTiCDCClusterVersionAndImageTagReq,
	) (*domain.GetTiCDCClusterVersionAndImageTagResp, bizerr.BizError)
}

type ChangefeedConfigManager interface {
	Create(
		ctx context.Context, req *domain.CreateChangefeedConfigReq,
	) (*domain.CreateChangefeedConfigResp, bizerr.BizError)
	Update(ctx context.Context, req *domain.UpdateChangefeedConfigReq) bizerr.BizError
	Get(ctx context.Context, req *domain.GetChangefeedConfigReq) (*domain.GetChangefeedConfigResp, bizerr.BizError)
}
