package repo

import (
	"context"

	"github.com/tidbcloud/pkgv2/bizerr"
	"github.com/tidbcloud/serverless-service/internal/domain/constant"
	"github.com/tidbcloud/serverless-service/internal/domain/entity"
)

type DMTaskRepo interface {
	// ListTasks returns a list of DMTask entities.
	ListTasks(ctx context.Context, filter *entity.DMTaskFilter) ([]*entity.DMTask, bizerr.BizError)
	// GetTask returns a DMTask by its ID.
	GetTask(
		ctx context.Context,
		clusterID string,
		taskID string,
		stages []constant.DMTaskStage,
	) (*entity.DMTask, bizerr.BizError)
	// CreateTask creates a new DMTask.
	CreateTask(ctx context.Context, task *entity.DMTask) bizerr.BizError
	// CountTasks returns the count of DMTask entities matching the filter.
	CountTasks(ctx context.Context, filter *entity.DMTaskFilter) (int64, bizerr.BizError)
	// UpdateTask updates a DMTask with the given ID and updates map.
	UpdateTask(ctx context.Context, id string, stages []constant.DMTaskStage, updates map[string]any) bizerr.BizError
	// UpdateSource updates a DMSource with the given ID and updates map.
	UpdateSource(ctx context.Context, id string, updates map[string]any) bizerr.BizError
	// CreatePrecheck creates a new DMPrecheck.
	CreatePrecheck(ctx context.Context, precheck *entity.DMPrecheck) bizerr.BizError
	// ListPrechecks returns a list of DMPrecheck entities.
	ListPrechecks(ctx context.Context, filter *entity.DMPrecheckFilter) ([]*entity.DMPrecheck, bizerr.BizError)
	// GetPrecheck returns a DMPrecheck by its ID and clusterID.
	GetPrecheck(ctx context.Context, clusterID, id string) (*entity.DMPrecheck, bizerr.BizError)
	// UpdatePrecheck updates a DMPrecheck with the given ID and updates map.
	UpdatePrecheck(ctx context.Context, id string, updates map[string]any) bizerr.BizError
	// CreatePrecheckItem creates a new DMPrecheckItem.
	CreatePrecheckItem(ctx context.Context, item *entity.DMPrecheckItem) bizerr.BizError
	// UpdatePrecheckItem updates a DMPrecheckItem (by id) with given updates.
	UpdatePrecheckItem(ctx context.Context, id string, updates map[string]any) bizerr.BizError
	// CreateVpcEndpoint persists a DMVpcEndpoint record.
	CreateVpcEndpoint(ctx context.Context, endpoint *entity.DMVpcEndpoint) bizerr.BizError
	// GetVpcEndpoint returns a DMVpcEndpoint by cluster id and endpoint id.
	GetVpcEndpoint(ctx context.Context, clusterID, id string) (*entity.DMVpcEndpoint, bizerr.BizError)
	// UpdateVpcEndpoint updates a DMVpcEndpoint record by internal id with provided updates.
	UpdateVpcEndpoint(ctx context.Context, id string, updates map[string]any) bizerr.BizError
	// ListVpcEndpoints returns DMVpcEndpoint records matching filter (non-deleted).
	ListVpcEndpoints(ctx context.Context, filter *entity.VpcEndpointFilter) ([]*entity.DMVpcEndpoint, bizerr.BizError)
}
