variable "environment" {
  description = "Available values: dev, qa, prod."
}

variable "aws_region" {
  default     = "us-east-1"
  description = "aws resources region"
}

variable "acr_cloud_bucket_id" {
  description = "integer identifier of fingerprint bucket in ACRCloud's system"
}

variable "acr_function_name" {
  description = "name of lambda function for acr fingerprinting"
}

variable "sr_create_function_name" {
  description = "name of lambda function for sound recording creation"
}

variable "sr_add_version_function_name" {
  description = "name of lambda function for sound recording version"
}

variable "sr_fanout_function_name" {
  description = "name of the lambda function for data fanout"
}

variable "sr_record_event_function_name" {
  description = "name of lambda function to record events for FB delivery"
}

variable "sr_delivery_meta_function_name" {
  description = "name of lambda function for Meta delivery"
}

variable "sr_delivery_tiktok_function_name" {
  description = "name of lambda function for TikTok delivery"
  default     = "lambda-sr-delivery-tiktok"
}

variable "sr_delivery_youtube_name" {
  description = "name of lambda function for Youtube delivery"
}

variable "osr_fingerprint_filter_name" {
  description = "name of lambda function for OSR delivery filter"
}

variable "node_fingerprint_filter_name" {
  description = "name of lambda function for Node delivery filter"
}

variable "edge_fingerprint_filter_name" {
  description = "name of lambda function for Edge delivery filter"
}

variable "ar_fingerprint_filter_name" {
  description = "name of lambda function for ArtRelations (track audio/rights attributes) delivery filter"
}

variable "mr_fingerprint_filter_name" {
  description = "name of lambda function for Master Registry filter"
}

variable "sr_delivery_tiktok_filter_function_name" {
  description = "name of lambda function for TikTok delivery filter"
}

variable "sr_delivery_youtube_filter_name" {
  description = "name of lambda function for Youtube delivery filter"
}

variable "sr_delivery_tiktok_ack_processor_name" {
  description = "name of lambda function for processing TikTok delivery acknowledgement messages"
}

variable "sr_fingerprinting_rules_migrator_function_name" {
  description = "name of the lambda function for Rights Registry to fingerprint rules migration"
}

variable "vpc_id" {
  type        = string
  description = "VPC ID"
  default     = "vpc-7f0e841a"
}

variable "vpc_subnet_ids" {
  type        = list(any)
  description = "VPC subnet IDs where the lambdas will execute"
}

variable "lambda_default_timeout" {
  description = "Default value for timeout"
  default     = "300"
}

variable "lambda_max_timeout" {
  description = "Maximum value for timeout"
  default     = "900"
}

variable "sfn_sr_fingerprinter_definition_file" {
  description = "SoundRecording Fingerprinter SFN definition"
  default     = "sfn-sr-fingerprinter.json"
}

variable "sfn_sr_delivery_tiktok_definition_file" {
  description = "SoundRecording Delivery TikTok SFN definition"
  default     = "sfn-sr-delivery-tiktok.json"
}

variable "sr_versions_bucket" {
  default = "sr-versions-bucket"
}

variable "sr_delivery_audit_bucket" {
  default = "sr-delivery-audit-bucket"
}

variable "interm_delivery_bucket_name" {
  default = "sr-interm-delivery-bucket"
}

variable "masters_active_stream_name" {
  default = "2017-12-08T21:38:41.811"
}

variable "assets_msk_topic" {
  description = "Topic containing OrchardAsset change events"
  default     = "cdc.musicGraphV5.orchardAsset"
}

variable "tracks_msk_topic" {
  description = "Topic containing Track change events"
  default     = "cdc.musicGraphV5.track"
}

variable "has_asset_msk_topic" {
  description = "Topic containing Track to OrchardAsset rel change events"
  default     = "cdc.musicGraphV5.hasAsset"
}

variable "has_fingerprint_rule_msk_topic" {
  description = "Topic containing Account/Track to FingerprintRule rel change events"
  default     = "cdc.musicGraphV5.hasFingerprintRule"
}

variable "project_used_to_belong_to_msk_topic_v5" {
  description = "Topic containing Project information that was moved from one Vendor/SubAccount to another change events"
  default     = "cdc.musicGraphV5.projectUsedToBelongTo"
}

variable "has_fingerprint_rule_snowflake_msk_topic" {
  description = "Snowflake JDBC source topic for active HAS_FINGERPRINT_RULE rows (replaces the Neo4j CDC feed)"
  default     = "event.snowflake.hasFingerprintRule"
}

variable "deleted_has_fingerprint_rule_snowflake_msk_topic" {
  description = "Snowflake JDBC source topic for DELETED_HAS_FINGERPRINT_RULE (soft-delete) rows"
  default     = "event.snowflake.deletedHasFingerprintRule"
}

variable "product_msk_topic" {
  description = "Topic containing Product change events"
  default     = "cdc.musicGraphV5.product"
}

variable "osr_msk_topic" {
  description = "Topic containing Orchard Sound Recording change events"
  default     = "cdc.musicGraphV5.orchardSoundRecording"
}

variable "vendor_msk_topic" {
  description = "Topic containing Vendor change events"
  default     = "cdc.musicGraphV5.vendor"
}

variable "subaccount_msk_topic" {
  description = "Topic containing SubAccount change events"
  default     = "cdc.musicGraphV5.subAccount"
}

variable "trackaudioattributes_msk_topic" {
  description = "Topic containing art_relations track_audio_attributes change events"
  default     = "cdc.artRelations.trackAudioAttributes"
}

variable "trackrightsattributes_msk_topic" {
  description = "Topic containing art_relations track_rights_attributes change events"
  default     = "cdc.artRelations.trackRightsAttributes"
}

variable "trackmasterrights_msk_topic" {
  description = "Topic containing art_relations track_master_rights change events"
  default     = "cdc.artRelations.trackMasterRights"

}

variable "fingerprint_rules_msk_topic" {
  description = "Topic containing rights registry to fingerprint rule migration events"
  default     = "event.orchardSoundRecording.fingerprintRules"
}

variable "trigger_msk_cluster_name" {
  description = "MSK cluster name"
  default     = "prod-managed-kafka-cdc-destination"
}

variable "trigger_msk_cluster_uuid" {
  description = "MSK cluster uuid"
  default     = "b103e027-ec75-4982-8d15-5bddc5e33831-6"
}

variable "kafka_brokers" {
  description = "comma separated cdc kafka brokers"
  default     = "b-1.prod-managed-kafka-cdc.40dsdw.c6.kafka.us-east-1.amazonaws.com:9094,b-2.prod-managed-kafka-cdc.40dsdw.c6.kafka.us-east-1.amazonaws.com:9094,b-3.prod-managed-kafka-cdc.40dsdw.c6.kafka.us-east-1.amazonaws.com:9094"
}

variable "kafka_delivery_topic" {
  description = "Event kafka topic for OSR delivery events"
  default     = "event.orchardSoundRecording.delivery"
}

variable "kafka_new_version_topic" {
  description = "event kafka topic for OSR newVersion events"
  default     = "event.sr.newVersion"
}

variable "datadog_trace_enabled" {
  description = "Boolean for enabling traces in datadog"
  default     = true
}

variable "meta_sftp_host" {
  description = "SFTP host name to connect to Meta"
}

variable "meta_sftp_base_dirname" {
  description = "Base directory name to be used in Meta SFTP connection"
}

variable "application_family" {
  description = "Application family of which this is a component. Used for tagging"
  default     = "sound-recordings"
}

variable "tiktok_s3_bucket_name" {
  description = "Tiktok s3 bucket name to upload sound recordings"
}

variable "tiktok_s3_base_foldername" {
  description = "Tiktok s3 bucket folder name to upload sound recordings"
}

variable "slack_alert_channel" {
  description = "Slack channels for all DD alerts"
  default     = "@slack-collections-prod-alarms"
}

variable "snowflake_account" {
  description = "snowflake account"
  default     = "delphi.us-east-1"
}

variable "sr_ack_snowflake_user" {
  description = "snowflake user"
  default     = "PROD_LAMBDA_SR_ACK_PROCESSOR"
}

variable "snowflake_database" {
  description = "snowflake database"
  default     = "FACTS"
}

variable "snowflake_schema" {
  description = "snowflake schema"
  default     = "PROD"
}

variable "snowflake_warehouse" {
  description = "snowflake warehouse"
  default     = "PROD_OWS_WAREHOUSE"
}

variable "snowflake_delivery_history_table" {
  description = "snowflake delivery history table name"
  default     = "ORCHARD_SOUND_RECORDING_DELIVERY_HISTORY"
}

variable "snowflake_role" {
  description = "snowflake role"
  default     = "PROD_LAMBDA_SR_ACK_PROCESSOR"
}

locals {
  datadog_api_key = "arn:aws:secretsmanager:${var.aws_region}:${data.aws_caller_identity.current.account_id}:secret:${var.environment}/datadog/DD_API_KEY"
}

variable "notification_endpoints" {
  default = "@slack-collections-prod-alarms"
}

variable "temp_notification_endpoints" {
  default = "@slack-sound-recording-alerts"
}

variable "new_eligibility_flow" {
  description = "True means use the new logic to determine eligibility for delivery. False means use old logic."
  default     = true
  type        = bool
}

variable "sfn_delivery_max_running" {
  description = "Maximum number of running executions for the delivery state machine"
  default     = "150"
}

variable "sfn_fingerprinting_max_running" {
  description = "Maximum number of running executions for the fingerprinting state machine"
  default     = "160"
}

variable "osr_sfn_throttle_sleep_seconds" {
  description = "Duration before the OSR filter re-tries to invoke the fingerprinting state machine, in seconds"
  default     = "15"
}

variable "edge_sfn_throttle_sleep_seconds" {
  description = "Duration before the edge filter re-tries to invoke the fingerprinting state machine, in seconds"
  default     = "15"
}

variable "youtube_sftp_hostname" {
  description = "SFTP hostname for Youtube deliveries"
  default     = "partnerupload.google.com"
}

variable "youtube_private_key_secret_name" {
  description = "YOUTUBE CMS private key secret name in Secrets Manager"
  default     = "YOUTUBE_CMS_FP_PRIVATE_KEY"
}

variable "youtube_sftp_port" {
  description = "SFTP port for Youtube deliveries"
  type        = number
  default     = 19321
}

variable "youtube_sftp_username" {
  description = "SFTP username for Youtube deliveries"
  default     = "yt-theorchardcid-ddex"
}

variable "process_asset" {
  description = "True means attempt to download and upload audio asset files. False means ignoring the files, but still using their metadata in DDEX."
  default     = true
  type        = bool
}

variable "perform_final_ddex_comparison" {
  description = "True means perform final DDEX comparison before delivery. False means skip final comparison."
  default     = false
  type        = bool
}

variable "ddex_file_version_youtube" {
  description = "DDEX file version to use for Youtube deliveries"
  default     = "4.3"
  type        = string

  validation {
    condition     = contains(["3.8", "4.3"], var.ddex_file_version_youtube)
    error_message = "DDEX file version must be either '3.8' or '4.3'."
  }
}

variable "ddex_file_version_tiktok" {
  description = "DDEX file version to use for TikTok deliveries"
  default     = "3.8"
  type        = string

  validation {
    condition     = contains(["3.8", "4.3"], var.ddex_file_version_tiktok)
    error_message = "DDEX file version must be either '3.8' or '4.3'."
  }
}

variable "teams" {
  description = "List of teams to be used for tagging"
  type        = list(string)
  default     = ["collections-fingerprinting"]
}

variable "team_name" {
  description = "Team name to be used for tagging"
  default     = "collections-fingerprinting"
}

locals {
  # Reusable tag builder
  env_tags = [
    "env:${var.environment}",
    "environment:${var.environment}",
  ]
  team_tags = [for team in var.teams : "team:${team}"]
}

variable "ack_processor_secret_names" {
  type = list(string)
  default = [
    "SNOWFLAKE_KEY",
    "SNOWFLAKE_KEY_PASSPHRASE"
  ]
}
