{
  "$schema" : "https://json-schema.org/draft/2020-12/schema",
  "$id" : "https://voltdb.com/voltsp/schemas/source/mqtt",
  "title" : "Mqtt Source Configuration",
  "description" : "The `mqtt` source connects to an MQTT broker to consume publish messages from specified topics.\nIt supports configuration of basic attributes like the broker’s host and port, topic filter,\nshared subscription group name, and message Quality of Service (QoS) level. Additionally it supports\nbasic authentication, TLS as well as OAuth.\n\nConsumed messages are represented by the `MqttPublishMessage` record, which encapsulates MQTT-specific\nattributes such as the payload, retain flag, message expiry, payload format, and user properties.\n\nMQTT source uses shared subscription to distribute incoming messages between all the workers.\n",
  "type" : "object",
  "properties" : {
    "mqtt" : {
      "type" : "object",
      "properties" : {
        "identifier" : {
          "type" : "string",
          "description" : "Identifier of the client used to connect to brokers. If no value was provided it will use a random UUID with `voltsp-source-` prefix."
        },
        "address" : {
          "type" : "string",
          "description" : "Sets the address of the MQTT broker to connect to in `host:port` format. When omitted the port is set to `1883`.",
          "default" : "1883",
          "anyOf" : [ {
            "type" : "string",
            "format" : "hostname"
          }, {
            "type" : "string",
            "format" : "ipv4"
          }, {
            "type" : "string",
            "format" : "ipv6"
          } ]
        },
        "topicFilter" : {
          "type" : "string",
          "description" : "Specifies the MQTT topic filter to subscribe to, supporting wildcards for flexible subscriptions."
        },
        "groupName" : {
          "type" : "string",
          "description" : "Shared subscription group name."
        },
        "websocket" : {
          "type" : "object",
          "description" : "Configuration for a WebSocket transport to use by MQTT clients.",
          "properties" : {
            "subpath" : {
              "type" : "string",
              "description" : "The path that should be used when connecting to websocket endpoint."
            }
          },
          "additionalProperties" : false
        },
        "qos" : {
          "type" : "string",
          "description" : "Quality of Service (QoS) according to the MQTT specification.",
          "default" : "AT_LEAST_ONCE",
          "enum" : [ "at_most_once", "at_least_once", "exactly_once", "AT_MOST_ONCE", "AT_LEAST_ONCE", "EXACTLY_ONCE" ]
        },
        "ssl" : {
          "type" : "object",
          "description" : "Secure transport configuration.",
          "properties" : {
            "trustStoreFile" : {
              "type" : "string",
              "description" : "Truststore file or trusted CA certificate; supported formats include JKS, PKCS#12, or PEM."
            },
            "trustStorePassword" : {
              "type" : "string",
              "description" : "Truststore password."
            },
            "keyStoreFile" : {
              "type" : "string",
              "description" : "Keystore file; supported formats include JKS, PKCS#12, or PEM"
            },
            "keyStorePassword" : {
              "type" : "string",
              "description" : "Keystore password."
            },
            "keyPassword" : {
              "type" : "string",
              "description" : "Private key password. Optional — if not set, the key store password will be used."
            },
            "insecure" : {
              "type" : "boolean",
              "description" : "If set to true, disables SSL certificate and hostname validation.\nIntended for debugging purposes only. Doesn't work with mTLS.\n"
            },
            "hostnameVerifier" : {
              "type" : "string",
              "description" : "Custom hostname verifier for SSL connections.\nIf not specified and 'insecure' is true, hostname verification will be disabled.\n"
            }
          },
          "additionalProperties" : false
        },
        "auth" : {
          "type" : "object",
          "description" : "If not specified no authentication is used.",
          "properties" : {
            "username" : {
              "type" : "string",
              "description" : "Username used for authentication."
            },
            "password" : {
              "type" : "string",
              "description" : "Password used for authentication."
            }
          },
          "additionalProperties" : false
        },
        "connect" : {
          "type" : "object",
          "description" : "Additional connect options.",
          "properties" : {
            "userProperties" : {
              "type" : "array",
              "description" : "List of key value paris that will be passed to MQTT client as user properties"
            },
            "keepAlive" : {
              "type" : "string",
              "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
              "description" : "Sets the keep alive property, must be in the range from 0 to 2^16 -1 (unsigned short)"
            }
          },
          "additionalProperties" : false
        },
        "reconnect" : {
          "type" : "object",
          "description" : "Automatic reconnect strategy using an exponential backoff with configurable initial and maximum delays.",
          "properties" : {
            "initialDelay" : {
              "type" : "string",
              "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
              "description" : "The initial delay before attempting to reconnect."
            },
            "maxDelay" : {
              "type" : "string",
              "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
              "description" : "Whatever the delay value that backoff strategy arrives at it will be capped by the `maxDelay` specified."
            }
          },
          "additionalProperties" : false
        },
        "oauth" : {
          "type" : "object",
          "description" : "Configures the OAuth details.",
          "properties" : {
            "scopes" : {
              "description" : "List of scopes to request together with the access token.",
              "anyOf" : [ {
                "type" : "string"
              }, {
                "type" : "array",
                "items" : {
                  "type" : "string"
                }
              } ]
            },
            "tokenUrl" : {
              "type" : "string",
              "description" : "OAuth 2.0 token endpoint URL (e.g. `https://idp.example.com/realms/foo/protocol/openid-connect/token`)."
            },
            "clientId" : {
              "type" : "string",
              "description" : "OAuth 2.0 client identifier registered with the identity provider."
            },
            "clientSecret" : {
              "type" : "string",
              "description" : "OAuth 2.0 client secret paired with `clientId`."
            },
            "grantType" : {
              "type" : "string",
              "description" : "OAuth 2.0 grant type used when requesting the token.",
              "default" : "client_credentials"
            },
            "username" : {
              "type" : "string",
              "description" : "Resource owner username"
            },
            "password" : {
              "type" : "string",
              "description" : "Resource owner password"
            },
            "audience" : {
              "type" : "string",
              "description" : "OAuth 2.0 audience parameter restricting the recipients the issued access\ntoken is intended for. The value is propagated to the `aud` claim of the JWT\nby identity providers that honor it (e.g. Keycloak via an audience mapper).\n\nAudience handling depends on the identity provider: some providers\n(e.g. Auth0, Okta) reject unknown audiences with HTTP 400, others\n(e.g. Keycloak with the `client_credentials` grant) silently ignore\nthe parameter. In the latter case, audience enforcement happens at\nthe resource server when it validates the `aud` claim.\n"
            },
            "ssl" : {
              "type" : "object",
              "description" : "TLS configuration for the HTTP client that calls the OAuth token endpoint.\nSet this when the token endpoint uses HTTPS with a certificate that the JVM\ndoes not already trust (e.g. private CA, self-signed) or when the identity\nprovider requires mTLS.\n",
              "properties" : {
                "trustStoreFile" : {
                  "type" : "string",
                  "description" : "Truststore file or trusted CA certificate; supported formats include JKS, PKCS#12, or PEM."
                },
                "trustStorePassword" : {
                  "type" : "string",
                  "description" : "Truststore password."
                },
                "keyStoreFile" : {
                  "type" : "string",
                  "description" : "Keystore file; supported formats include JKS, PKCS#12, or PEM"
                },
                "keyStorePassword" : {
                  "type" : "string",
                  "description" : "Keystore password."
                },
                "keyPassword" : {
                  "type" : "string",
                  "description" : "Private key password. Optional — if not set, the key store password will be used."
                },
                "insecure" : {
                  "type" : "boolean",
                  "description" : "If set to true, disables SSL certificate and hostname validation.\nIntended for debugging purposes only. Doesn't work with mTLS.\n"
                },
                "hostnameVerifier" : {
                  "type" : "string",
                  "description" : "Custom hostname verifier for SSL connections.\nIf not specified and 'insecure' is true, hostname verification will be disabled.\n"
                }
              },
              "additionalProperties" : false
            }
          },
          "additionalProperties" : false
        }
      },
      "required" : [ "address", "topicFilter", "groupName" ],
      "additionalProperties" : false
    }
  },
  "required" : [ "mqtt" ],
  "additionalProperties" : false
}
