{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://fermihdi.io/schemas/dynamic_webhook_payload.schema.json",
  "title": "Message Bus Ingester Configuration Schema",
  "description": "JSON schema for the dynamic configuration payload received by the Ingester via the /v1/ingest/config endpoint.",
  "type": "object",
  "properties": {
    "ingression_type": {
      "type": "string",
      "enum": ["kafka", "rabbitmq", "mqtt", "file", "s3"]
    },
    "input_format": {
      "type": "string",
      "enum": ["json", "rowbinary", "csv"]
    },
    "schema_file": {
      "type": "string"
    },
    "batch_interval_seconds": {
      "type": ["integer", "null"],
      "description": "Optional override for batch rotation window in seconds."
    },
    "batch_id_field": {
      "type": "string",
      "description": "Field in the payload to use as Batch ID."
    },
                "round_batch_id_field": {
                    "description": "If true, rounds the extracted batch ID to the time index interval.",
                    "type": "boolean"
                },
    "tcp_max_session_duration_sec": {
      "type": "integer"
    },
    "kafka": {
      "type": "object",
      "properties": {
        "brokers": { "type": "string" },
        "topic": { "type": "string" },
        "group_id": { "type": "string" }
      }
    },
    "rabbitmq": {
      "type": "object",
      "properties": {
        "url": { "type": "string" },
        "queue": { "type": "string" }
      }
    },
    "mqtt": {
      "type": "object",
      "properties": {
        "address": { "type": "string" },
        "client_id": { "type": "string" },
        "topic": { "type": "string" }
      }
    },
    "file": {
      "type": "object",
      "properties": {
        "directory": { "type": "string" },
        "sort_by": { "type": "string", "enum": ["alphanumeric", "modified_time"] }
      }
    },
    "s3": {
      "type": "object",
      "properties": {
        "bucket": { "type": "string" },
        "prefix": { "type": "string" },
        "region": { "type": "string" },
        "endpoint": { "type": "string" },
        "sort_by": { "type": "string", "enum": ["alphanumeric", "modified_time"] }
      }
    },
    "scc_targets": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["address", "port"],
        "properties": {
          "address": { "type": "string" },
          "port": { "type": "integer" },
          "description": { "type": "string" }
        }
      }
    },
    "target_storage_clusters": {
      "type": "array",
      "items": { "type": "string" }
    },
    "env": {
      "type": "string",
      "enum": ["production", "development"]
    },
    "node_name": { "type": "string" },
    "log_level": {
      "type": "string",
      "enum": ["DEBUG", "INFO", "WARN", "ERROR"]
    },
    "otel_collector_url": { "type": "string" },
    "dms_url": { "type": "string" },
    "healthcheck_port": { "type": "integer" },
    "opt_in": { "type": "boolean" },
    "sentry_dsn": { "type": "string" },
    "bootstrap_token": { "type": "string" },
    "k8s_token": { "type": "string" },
    "client_cert_file": { "type": "string" },
    "client_key_file": { "type": "string" }
  },
  "additionalProperties": false
}
