package premium

import (
	pb "github.com/tidbcloud/config-center/proto/config_center"
	"github.com/tidbcloud/config-center/templategen"
)

// BR (backup & restore) templates. These hold ONLY Init Configure parameters
// (values set at initialization). Configurable-only parameters live in the param
// dict (created by ctl), not here. Component images are managed out of band.

var specBRAutoBackup = templategen.Spec{
	ConfigType: pb.SHARED_POOL_CONFIG_TIBR_AUTOBACKUP,
	Name:       "system template of premium br autobackup",
	Base: map[string]*pb.ParamItem{
		"native-br.backup-tolerate-err": templategen.MustParam(true,
			"Controls whether the backup operation should tolerate the unavailability of up to one store node."),
		"native-br.backup-delay": templategen.MustParam("5s",
			"Delay before performing a backup. Also acts as control switch for passing backup_ts to rfengine."),
	},
}

var specBRRestore = templategen.Spec{
	ConfigType: pb.SHARED_POOL_CONFIG_TIBR_RESTORE,
	Name:       "system template of premium br restore",
	Base: map[string]*pb.ParamItem{
		"native-br.lower-memory": templategen.MustParam(true,
			"Enable memory-optimized mode for restore operations."),
	},
}

var specBRT2DFSGC = templategen.Spec{
	ConfigType: pb.SHARED_POOL_CONFIG_TIBRGC_T2_DFSGC,
	Name:       "system template of premium br t2 dfsgc",
	Base: map[string]*pb.ParamItem{
		"file-types-whitelist": templategen.MustParam("sst",
			"File types whitelist; use comma to separate multiple types."),
	},
}

// specBRT3Archive has no Init Configure params, so its template is empty (no
// Base). It still gets a default binding, just to an empty template.
var specBRT3Archive = templategen.Spec{
	ConfigType: pb.SHARED_POOL_CONFIG_TIBRGC_T3_ARCHIVE,
	Name:       "system template of premium br t3 archive",
}

var specBRClassicRestore = templategen.Spec{
	ConfigType: pb.SHARED_POOL_CONFIG_CLASSIC_RESTORE,
	Name:       "system template of premium classic br restore",
	Base: map[string]*pb.ParamItem{
		"tikv-max-restore-concurrency": templategen.MustParam(4,
			"Thread pool size for task execution per store."),
		"ratelimit": templategen.MustParam(50,
			"Restore rate limit in MiB/s."),
		"with-sys-table": templategen.MustParam(true,
			"Whether to restore system privilege tables by default."),
		"check-requirements": templategen.MustParam(false,
			"Whether to start version check before executing command."),
		"checksum": templategen.MustParam(false,
			"Run checksum at end of task."),
		"merge-region-size-bytes": templategen.MustParam(2359296000,
			"Threshold for merging small regions (bytes)."),
		"merge-region-key-count": templategen.MustParam(225000000,
			"Key count threshold for merging small regions."),
		"sys-check-collation": templategen.MustParam(true,
			"Whether to check collation compatibility for system tables."),
		"fast-load-sys-tables": templategen.MustParam(false,
			"Load system tables by renaming temporary system tables."),
	},
}
