package constant

const (
	ENV_DEV     = "dev"
	ENV_STAGING = "staging"
	ENV_PROD    = "prod"
)

const (
	ClusterLabelKey      = "clusterID"
	ClusterNameLabelKey  = "cluster"
	ProjectLabelKey      = "projectID"
	ProjectNameLabelKey  = "project"
	BetaLabelKey         = "beta"
	BetaCategoryLabelKey = "beta-category"
	BranchLabelKey       = "branchID"
	ServicePlanLabelKey  = "service-plan-billing"

	// WarehouseLabelKey is the label key the Lake reporter uses to carry
	// the warehouse name. Lake costs have no clusterID, so WithClusterName
	// falls back to this key when mapping Lake data to the clusterName
	// label. Multi-cluster warehouses share the same warehouse value
	// across warehouseCluster entries, so all small clusters roll up
	// to the same clusterName on bills.
	WarehouseLabelKey = "warehouse"

	// LakeComputeUnitPrefix is the SKU prefix for Lake Compute units
	// (e.g. "databend-compute-business:aws:us-east-2:large:per-second").
	// WithClusterName uses this to decide whether to apply the
	// warehouse fallback described on WarehouseLabelKey: TiDB clusters
	// keep the original clusterID lookup, Lake Compute units skip it
	// and use the warehouse name instead. Other Lake SKUs (storage,
	// cloud service fee) fall through to the default path — they are
	// intentionally not handled here.
	LakeComputeUnitPrefix = "databend-compute"
)

const (
	ServicePlanPremium = "premium"
	// ServicePlanLake is the value WithClusterName writes to the
	// service-plan-billing label for Lake units. Downstream aggregates
	// (cost explorer, bill export) surface this as the service_plan
	// field so Lake costs can be distinguished from tiered clusters.
	ServicePlanLake = "Lake"
)
const (
	BetaLabelValueTrue = "true"
)

const (
	SpendLimitEventType          = "spend-limit"
	SpendLimitThresholdEventType = "spend-limit-threshold"
	SpendLimitEmailKeyPattern    = "spend_limit-%d-%s"
	SpendLimitGroup              = "spend-limit"

	ServerlessSpendLimitEmailTemplateID              = "d-a3ec6399fdfc49cd8139d86e0e766b51"
	ServerlessSpendLimitEmailThresholdKey            = "threshold"
	ServerlessSpendLimitEmailThresholdClusterNameKey = "clusterName"
	ServerlessSpendLimitEmailThresholdClusterIDKey   = "clusterID"
	ServerlessSpendLimitEmailThresholdProjectNameKey = "projectName"
	ServerlessSpendLimitEmailThresholdProjectIDKey   = "projectID"

	ServerlessBudgetMetaProjectIDKey   = "project_id"
	ServerlessBudgetMetaClusterIDKey   = "cluster_id"
	ServerlessBudgetMetaClusterNameKey = "cluster_name"

	NormalSpendingLimitEmailTemplateID      = "d-b46678ed85c3481d8f95aa56fdcde7a2"
	NormalSpendingLimitEmailUserKey         = "userName"
	NormalSpendingLimitEmailOrgNameKey      = "orgName"
	NormalSpendingLimitEmailThresholdKey    = "threshold"
	NormalSpendingLimitEmailActualCostKey   = "actualCost"
	NormalSpendingLimitEmailBudgetNameKey   = "budgetName"
	NormalSpendingLimitEmailBudgetURLKey    = "weblink"
	NormalSpendingLimitEmailBudgetAmountKey = "budgetAmount"
)

const (
	UnknownClusterName = "unknown"
)

const (
	TieredBillingInterval_Monthly = "monthly"

	TieredBillingAction_Free = "free"
)

const (
	UsageType_Normal  = "normal"
	UsageType_FreeCap = "free_cap"
	// UsageType_AgenticPlan routes the agentic plan derived SKUs
	// (Active/Idle hour fees) to plugs.AgenticPlanUsageAdjuster, which
	// replaces the worker's placeholder usage with the aggregated
	// counts inside the pricing transaction.
	UsageType_AgenticPlan = "agentic_plan"

	DiscountType_Package = "package"

	CalcPriceType_Normal = "normal"
)

// Agentic Plan V2 units and suppression targets (design doc §4.1/§4.3).
const (
	// AgenticPlanActiveFeeSKU / AgenticPlanIdleFeeSKU are the derived
	// settlement SKUs. v1 is region-less (mirroring instance-capacity:
	// tier1, which reports no region dimension); per-region split is a
	// future additive change once §9 region pricing is confirmed.
	AgenticPlanActiveFeeSKU = "agentic-plan:active-fee:per-hour"
	AgenticPlanIdleFeeSKU   = "agentic-plan:idle-fee:per-hour"

	// AgenticPlanStarterRUPattern matches the starter RU metering units
	// whose distinct clusterIDs define the Active set (SQL LIKE form,
	// used by the settlement aggregation).
	AgenticPlanStarterRUPattern = "serverless-request-unit:%:starter"

	// AgenticPlanStarterRUPrefix / Suffix are the Go-side equivalents
	// of AgenticPlanStarterRUPattern for in-memory unit routing.
	AgenticPlanStarterRUPrefix = "serverless-request-unit:"
	AgenticPlanStarterRUSuffix = ":starter"

	// AgenticPlanCapacityUnit is the tier1 capacity report unit. For
	// agentic-plan tenants it is suppressed at pricing() (the Active/
	// Idle hourly fees replace the capacity fee — replacement relation
	// per design doc §9 item 1), and its H+1 label total_count is the
	// settlement readiness gate.
	AgenticPlanCapacityUnit = "instance-capacity:tier1"

	// AgenticPlanActiveCostIDFormat / AgenticPlanIdleCostIDFormat
	// derive the deterministic settlement cost IDs (tenant + hour
	// unix). Data contract: metering_events' uk_cost_id arbitrates
	// re-enqueues, and the billed rows key on the same IDs — the
	// worker enqueues with them and the billed output is joinable
	// back by them; the format must never drift.
	AgenticPlanActiveCostIDFormat = "agentic_active_%d_%d"
	AgenticPlanIdleCostIDFormat   = "agentic_idle_%d_%d"

	// AgenticPlanWorkerType is the worker_metering_records
	// discriminator for the agentic plan settlement worker.
	AgenticPlanWorkerType = "agentic_plan"

	// WorkerMeteringRecordCostIDFormat derives the deterministic
	// trigger-record PK (worker_type + tenant + hour unix). Data
	// contract: re-inserting the same trigger hour is a no-op on the
	// PK, which is what makes mark-after-pair retries safe.
	WorkerMeteringRecordCostIDFormat = "%s_%d_%d"
)

const (
	AdjustmentMetaRawPriceKey                     = "raw_price"
	AdjustmentMetaRemainingCreditsInsufficientKey = "remaining_credits_sufficient"
	AdjustmentMetaTieredBillingOverKey            = "tiered_billing_over"
)

const (
	// SystemLabelBindedBillingConfigIDKey carries the producer-stamped
	// billing config anchor on a metering event. Secondary measures
	// bill against a Managing billing config (CPPO per-customer partner
	// books) that the by-timestamp resolver cannot recover — its
	// candidate set is Active/Closing only — so pricing must consume
	// this stamp instead of re-resolving. Written by the outbox enqueue
	// and the inline shadow pool; absent on events enqueued before the
	// stamp existed (pricing falls back to by-timestamp resolution).
	SystemLabelBindedBillingConfigIDKey = "binded_billing_config_id"
)

const (
	DiscountDefaultUnitFilterTargetName = "default-discount"

	DiscountStatus_Valid     = "valid"
	DiscountStatus_Expired   = "expired"
	DiscountStatus_Reclaimed = "reclaimed"

	DiscountUsageCPPO  = "cppo"
	DiscountUsageMCPO  = "mcpo"
	DiscountUsageRerun = "rerun"
)

const (
	GeneralTypeName = "General"
	GeneralTypeID   = uint(1)
	GeneralPriority = 100000
	CompKey         = "component"
	TiDBComp        = "COMPONENT_TYPE_TIDB"
	TiKVComp        = "COMPONENT_TYPE_TIKV"
	TiFlashComp     = "COMPONENT_TYPE_TIFLASH"

	ServerlessTierTypeName       = "TiDB Serverless"
	ServerlessTierPriority       = 3000
	ServerlessRUTypeName         = "Serverless Request Units"
	ServerlessRUPriority         = 300
	ServerlessRowStorageTypeName = "Serverless Row-based Storage"
	ServerlessRowStoragePriority = 200
	ServerlessColStorageTypeName = "Serverless Columnar Storage"
	ServerlessColStoragePriority = 100
	//  Starter
	ServerlessStarterTypeName           = "TiDB Cloud Starter"
	ServerlessStarterTierPriority       = 2900
	ServerlessStarterRUTypeName         = "Starter Request Units"
	ServerlessStarterRUPriority         = 300
	ServerlessStarterRowStorageTypeName = "Starter Row-based Storage"
	ServerlessStarterRowStoragePriority = 200
	ServerlessStarterColStorageTypeName = "Starter Columnar Storage"
	ServerlessStarterColStoragePriority = 100
	// Essential
	ServerlessEssentialTypeName           = "TiDB Cloud Essential"
	ServerlessEssentialPriority           = 2800
	ServerlessEssentialRCUTypeName        = "Essential Request Capacity Units"
	ServerlessEssentialRCUPriority        = 300
	ServerlessEssentialRowStorageTypeName = "Essential Row-based Storage"
	ServerlessEssentialRowStoragePriority = 200
	ServerlessEssentialColStorageTypeName = "Essential Columnar Storage"
	ServerlessEssentialColStoragePriority = 100

	//DedicatedTierTypeName     = "Dedicated Tier"
	NodeComputeTypeName       = "Node Compute"
	NodeComputePriority       = 10000
	TiDBNodeTypeName          = "TiDB Node"
	TiDBNodePriority          = 100
	TiKVNodeTypeName          = "TiKV Node"
	TiKVNodePriority          = 80
	TiFlashNodeTypeName       = "TiFlash Node"
	TiFlashNodePriority       = 60
	StorageTypeName           = "Node Storage"
	StoragePriority           = 4000
	TiKVStorageTypeName       = "TiKV Storage"
	TiKVStoragePriority       = 80
	TiFlashStorageTypeName    = "TiFlash Storage"
	TiFlashStoragePriority    = 60
	BackupTypeName            = "Backup"
	BackupPriority            = 5000
	BackupStorageTypeName     = "Backup Storage"
	BackupStoragePriority     = 80
	BackupReplicationTypeName = "Backup Replication"
	BackupReplicationPriority = 60
	TiCDC                     = "TiCDC"
	TiCDCName                 = "Changefeed"
	TiCDCPriority             = 8000
	DM                        = "DM"
	DMPriority                = 7000
)

const (
	MetricsLabelKeyUnit     = "unit"
	MetricsLabelKeyTenantID = "tenant_id"
)

const (
	DiscountActive   = "normal"
	DiscountInactive = "inactive"
)

const (
	GetTenantEffectivePlanCacheName = "GetTenantEffectivePlan"
)

const (
	TestHeaderKey   = "X-FUNCTION-TEST"
	TestHeaderValue = "true"
)
const (
	GCPAccountProvider      = "gcp_account_provider"
	AwsAccountProvider      = "aws_account_provider"
	MSPAccountProvider      = "msp_account_provider"
	AzureAccountProvider    = "azure_account_provider"
	AliCloudAccountProvider = "alicloud_account_provider"
)
const (
	MSPCustomer        = "msp_customer"
	MSPUser            = "msp"
	MSPCustomerIDLabel = "MSPCustomerID"

	MarketplaceResellerManagedCustomerIDLabel = MSPCustomerIDLabel
)
const (
	QueryBillsMonthLimit = -6
)
const (
	PaymentMethodChangedEventType    = "payment-method-changed"
	SupportPlanLevelChangedEventType = "support-plan-level-changed"
)
const (
	TenantEventTypeCreate   = "create"
	TenantEventTypeActivate = "activate"
	TenantEventTypeUpdate   = "update"
	TenantEventTypeDelete   = "delete"

	// msp customer org conver to customer , table [msp_customer]  status=pending
	TenantEventTypeSchedule = "schedule"

	// msp customer org conver to customer , table [msp_customer]  status=active
	TenantEventTypeScheduleActivate = "schedule_activate"

	// msp customer org cancel  conver to customer
	TenantEventTypeScheduleCancel = "schedule_cancel"
)
const (
	AllTenantRegisteredEventType = "OrgEvent"
	AddUserToOrgEventType        = "AddUserToOrgEvent"
	RemoveUserFromOrgEventType   = "RemoveUserFromOrgEvent"

	BillingConfigSwitchedEvent = "billing-config-switched"
)

// Role binding roles
const (
	RoleBindingFixedRoleImpersonated = "impersonated"
	RoleOrgOwner                     = "org:owner"
	RoleOrgMember                    = "org:member"
	RoleOrgBillingAdmin              = "org:billing_admin"
	RoleOrgAuditAdmin                = "org:audit_admin"
	RoleOrgImpersonated              = "org:impersonated"
	RoleProjectOwner                 = "project:owner"
	RoleProjectDev                   = "project:dev"
	RoleProjectReadOnly              = "project:readonly"
	RoleImpersonateOrgOwner          = "impersonate:org:owner"
	RoleOrgBillingingViewer          = "org:billing_viewer"
	RoleProjectCtlPlaneViewer        = "project:ctl_plane_viewer"
)

// FE use
const (
	UserRoleOwner                 = "owner"
	UserRoleMember                = "member"
	UserRoleBillingAdmin          = "billing_admin"
	UserRoleAuditAdmin            = "audit_admin"
	UserRoleImpersonated          = "impersonated"
	UserRoleProjectOwner          = "project_owner"
	UserRoleProjectDev            = "project_developer"
	UserRoleProjectReadOnly       = "project_readonly"
	UserRoleOrgBillingViewer      = "billing_viewer"
	UserRoleProjectCtlPlaneViewer = "project_ctl_plane_viewer"
)
const (
	ScopeOrg     = "ORG"
	ScopeProject = "PROJECT"
)

const (
	FixedPrice_SKU       = "support-plan:fixed_price"
	PercentagePrice_SKU  = "support-plan:percentage_price"
	TieredPrice_SKU      = "support-plan:tiered_price"
	CommintmentPrice_SKU = "support-plan:commitment_price"
)

const (
	// LakeCloudServiceFee_SKU is the unit key for the Lake Cloud Service
	// Fee, whose price equals a fraction of the Lake Warehouse daily cost.
	LakeCloudServiceFee_SKU = "databend-cloudservice-fee:based-on-warehouse:per-day"
)

const (
	TiDBServerlessCatName = "TiDB Serverless"
	TiDBDedicatedCatName  = "TiDB Dedicated"
	TiDBStarterCatName    = "TiDB Cloud Starter"
	TiDBEssentialCatName  = "TiDB Cloud Essential"
	TiDBPremiumCatName    = "TiDB Cloud Premium"
	TiDBLakeCatName       = "TiDB Cloud Lake"
	TiDBBYOCCatName       = "TiDB Cloud BYOC"
	SupportPlanCatName    = "Support Plan"
)

const (
	ContainerAppNameBilling2       = "billing2"
	ContainerAppNameBilling2Api    = "billing2-api"
	ContainerAppNameBilling2Worker = "billing2-worker"
)

const (
	// msp partner
	OrgTagMsp         string = "msp"
	OrgTagMspCustomer string = "msp_customer"

	// resale partner
	OrgTagResalePartner  string = "resale_partner"
	OrgTagResaleCustomer string = "resale_customer"

	// tcpn asw cppo partner
	OrgTagAwsCppo         string = "aws_cppo"
	OrgTagAwsCppoCustomer string = "aws_cppo_customer"

	OrgTagGcpMCPOReseller string = "gcp_mcpo_reseller"
	OrgTagGcpMCPOCustomer string = "aws_cppo_customer"
)

const (
	AzureSubscriptionStatusPending      string = "PendingFulfillmentStart"
	AzureSubscriptionStatusSubscribed   string = "Subscribed"
	AzureSubscriptionStatusUnsubscribed string = "Unsubscribed"
)

const (
	OtherCountryCode = "X"
)
