package service

import (
	"context"
	"sync"
	"time"

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

const (
	PiTREndTimeLimit             = 1 * time.Minute
	CustomStatusMutexErrorCode   = 49900003
	RestoreTimeout               = 3 * time.Hour
	deletedClusterQueryBatchSize = 100
	UserBackupInterval           = 24 * time.Hour
)

var generateIdMutex sync.Mutex

type BackupRestoreService interface {
	ListBackups(ctx context.Context, opt *vo.ListUserBackupsOpt) ([]*vo.Backup, uint32, bizerr.BizError)
	GetBackup(ctx context.Context, tenantId, clusterId, backupId string) (*vo.Backup, bizerr.BizError)
	ListRecycledInstances(
		ctx context.Context,
		opt *vo.ListRecycledInstancesOpt,
	) ([]*vo.RecycledInstance, uint32, bizerr.BizError)
	GetRecycledInstance(ctx context.Context, tenantId, clusterId string) (*vo.RecycledInstance, bizerr.BizError)
	ListRecycledInstanceBackups(ctx context.Context, opt *vo.ListUserBackupsOpt) ([]*vo.Backup, uint32, bizerr.BizError)
	DeleteRecycledInstanceBackup(ctx context.Context, tenantId, clusterId, backupId string) bizerr.BizError
	Restore(ctx context.Context, restore *vo.Restore) (string, bizerr.BizError)
	ListRestores(ctx context.Context, opt *vo.ListRestoresOpt) ([]*vo.RestoreJob, uint32, bizerr.BizError)
	ListBackupSchedules(ctx context.Context, opt *vo.ListBackupSchedulesOpt) ([]*vo.BackupSchedule, bizerr.BizError)
	UpdateBackupSchedules(ctx context.Context, opt *vo.UpdateBackupSchedulesOpt) (*vo.BackupSchedule, bizerr.BizError)
	GetBackupRetention(ctx context.Context, tenantId, clusterId string) (time.Duration, bizerr.BizError)
}
