variable "auto_resume" {
  description = "Automatically start Warehouse when query is executed"
  default     = true
}

variable "auto_suspend" {
  description = "Idle timeout in seconds after which warehouse is suspended. Set to 0 to disable auto-suspend."
  default     = 60
}

variable "enable_query_acceleration" {
  description = "Whether to enable query acceleration"
  default     = false
}

variable "max_cluster_count" {
  default = 1
}

variable "min_cluster_count" {
  default = 1
}

variable "max_concurrency_level" {
  type        = number
  description = "The maximum concurrency level for SQL statements executed by the warehouse"
  default     = 8
}

variable "name" {
  description = "Name of the warehouse"
}

variable "query_acceleration_max_scale_factor" {
  description = "Specifies the maximum scale factor for leasing compute resources for query acceleration"
  default     = 8
}

variable "resource_monitor_enabled" {
  description = "Whether to enable resource monitor for the warehouse"
  default     = false # Disabled by default because resource monitor creation can currently only be done by ACCOUNTADMIN role
}

variable "resource_monitor_frequency" {
  description = "How often quota resets"
  default     = "DAILY"
}

variable "resource_monitor_quota" {
  description = "Quota for this monitor"
  default     = 250
}

variable "resource_monitor_start_timestamp" {
  description = "Start timestamp for quota"
  default     = "2023-03-01 00:00"
}

variable "size" {
  description = "Size of the warehouse"
  type        = string
  default     = "XSMALL"
  validation {
    condition = contains(
      [
        "XSMALL", "X-SMALL", "SMALL", "MEDIUM", "LARGE", "XLARGE",
        "X-LARGE", "XXLARGE", "X2LARGE", "2X-LARGE", "XXXLARGE", "X3LARGE",
        "3X-LARGE", "X4LARGE", "4X-LARGE", "X5LARGE", "5X-LARGE", "X6LARGE",
        "6X-LARGE"
      ],
    var.size)
    error_message = "Warehouse size verification failed"
  }
}

variable "statement_timeout_in_seconds" {
  description = "Specifies the time, in seconds, after which a running SQL statement is canceled by the system/"
  type        = number
  default     = 7200
}

variable "statement_queued_timeout_in_seconds" {
  description = "Specifies the time, in seconds, a SQL statement can be queued on a warehouse before it is canceled by the system. Set to 0 to disable (default)."
  type        = number
  default     = 0
}

variable "comment" {
  description = "Warehouse description"
  type        = string
  default     = null
}

variable "scaling_policy" {
  description = "Specifies the policy for automatically starting and shutting down the warehouse in response to a defined level of user activity"
  type        = string
  default     = "STANDARD"
  validation {
    condition = contains(
      ["STANDARD", "ECONOMY"],
      var.scaling_policy
    )
    error_message = "Scaling policy verification failed"
  }
}

variable "warehouse_type" {
  description = "Specifies the warehouse type."
  type        = string
  default     = "STANDARD"
  validation {
    condition = contains(
      ["STANDARD", "SNOWPARK-OPTIMIZED"],
      var.warehouse_type
    )
    error_message = "Warehouse type verification failed"
  }
}

variable "generation" {
  type        = string
  description = "Specifies the generation for the warehouse. Only available for standard warehouses. Valid values are: [1, 2]."
  default     = "1"
  validation {
    condition     = var.generation != null ? var.warehouse_type == "STANDARD" : true
    error_message = "To set generation you must set warehouse_type to STANDARD."
  }
  validation {
    condition     = var.generation != null ? contains(["1", "2"], var.generation) : true
    error_message = "Generation value verification failed."
  }
}

variable "resource_constraint" {
  type        = string
  description = "Specifies the resource constraint for the warehouse. Only available for snowpark-optimized warehouses."
  default     = null
  validation {
    condition     = var.resource_constraint != null ? var.warehouse_type == "SNOWPARK-OPTIMIZED" : true
    error_message = "To set resource_constraint you must set warehouse_type to SNOWPARK-OPTIMIZED."
  }
  validation {
    condition = var.resource_constraint != null ? contains([
      "MEMORY_1X",
      "MEMORY_1X_x86",
      "MEMORY_16X",
      "MEMORY_16X_x86",
      "MEMORY_64X",
      "MEMORY_64X_x86",
    ], var.resource_constraint) : true
    error_message = "Resource constraint value verification failed."
  }
}

variable "team" {
  type        = string
  description = "Team name warehouse belongs to."
  default     = ""
}

variable "team_tag_name" {
  default     = "SNOWFLAKE_SETTINGS.TAGS.TEAM"
}
