variable "azure_subscription_id" {
  description = "Azure subscription in which this environment is allowed to run."
  type        = string
  default     = "7f070020-6caa-4321-a999-2d9cce2a6c17"
}

variable "azure_subscription_name" {
  description = "Expected human-readable subscription name, checked before deployment."
  type        = string
  default     = "data-integration-team-internal-azure"
}

variable "azure_location" {
  type    = string
  default = "japaneast"
}

variable "kafka_privatelink_availability_zone" {
  description = "Azure logical availability zone used by the Premium Kafka custom-domain endpoint (for example, 1)."
  type        = string
  default     = "1"

  validation {
    condition     = can(regex("^[1-3]$", var.kafka_privatelink_availability_zone))
    error_message = "kafka_privatelink_availability_zone must be an Azure logical zone: 1, 2, or 3."
  }
}

variable "name_prefix" {
  type    = string
  default = "date-integration-test"

  validation {
    condition     = can(regex("^[a-z][a-z0-9-]{2,23}$", var.name_prefix))
    error_message = "name_prefix must contain 3-24 lowercase letters, digits, or hyphens."
  }
}

variable "vnet_cidr" {
  type    = string
  default = "10.90.0.0/20"
}

variable "vm_size" {
  type    = string
  default = "Standard_D2pls_v6"
}

variable "root_disk_size_gib" {
  type    = number
  default = 30
}

variable "data_disk_size_gib" {
  type    = number
  default = 50
}

variable "desired_state" {
  type    = string
  default = "running"

  validation {
    condition     = contains(["running", "stopped"], var.desired_state)
    error_message = "desired_state must be running or stopped."
  }
}

variable "remove_privatelink_when_stopped" {
  type    = bool
  default = false
}

variable "port_base" {
  type     = number
  default  = null
  nullable = true

  validation {
    condition     = var.port_base == null ? true : var.port_base >= 20000 && var.port_base <= 60000 && floor(var.port_base) == var.port_base
    error_message = "port_base must be a whole number between 20000 and 60000."
  }
}

variable "private_link_subscription_ids" {
  description = "Subscriptions allowed to discover and auto-approve the test Private Link Services."
  type        = set(string)
  default = [
    "7f070020-6caa-4321-a999-2d9cce2a6c17", # data-integration-team-internal-azure
    "85b598b9-a080-4476-bc96-ba89e64f92d1", # tidb-dedicated-nonprod-dataplane
  ]
}

variable "kafka_privatelink_root_domain_name" {
  type    = string
  default = "date-integration.azure.kafka.test"
}

variable "e2e_project_ids" {
  description = "Comma-separated TiDB Cloud E2E project IDs associated with Azure Private Link Kafka dependencies."
  type        = string
  default     = "1369847559694040763,1369847559694040575"

  validation {
    condition     = length(trimspace(var.e2e_project_ids)) > 0
    error_message = "e2e_project_ids must not be empty."
  }
}

variable "mysql_user" {
  type    = string
  default = "e2e_admin"
}

variable "mysql_root_password" {
  type      = string
  default   = null
  nullable  = true
  sensitive = true
}

variable "mysql_password" {
  type      = string
  default   = null
  nullable  = true
  sensitive = true
}

variable "kafka_sasl_username" {
  type      = string
  default   = null
  nullable  = true
  sensitive = true
}

variable "kafka_sasl_password" {
  type      = string
  default   = null
  nullable  = true
  sensitive = true
}

variable "pulsar_token_secret" {
  type      = string
  default   = null
  nullable  = true
  sensitive = true
}

variable "enable_pulsar" {
  type    = bool
  default = true
}

variable "enable_schema_registry" {
  type    = bool
  default = false
}

variable "schema_registry_username" {
  type      = string
  default   = null
  nullable  = true
  sensitive = true
}

variable "schema_registry_password" {
  type      = string
  default   = null
  nullable  = true
  sensitive = true
}

variable "blob_sas_expiry" {
  description = "Absolute UTC expiry for the long-lived test Blob SAS token."
  type        = string
  default     = "2036-01-01T00:00:00Z"

  validation {
    condition     = can(formatdate("YYYY-MM-DD'T'hh:mm:ssZ", var.blob_sas_expiry))
    error_message = "blob_sas_expiry must be an RFC3339 timestamp."
  }
}

variable "storage_account_name" {
  type     = string
  default  = null
  nullable = true
}
