{
  "$schema" : "https://json-schema.org/draft/2020-12/schema",
  "$id" : "https://voltdb.com/voltsp/schemas/sink/mqtt",
  "title" : "Mqtt Sink Configuration",
  "description" : "The `mqtt` sink connects to an MQTT broker to publish messages to specified topic.\nIt supports configuration of basic attributes like the broker’s host and port and topic filter.\nAdditionally it supports basic authentication, TLS as well as OAuth.\n",
  "type" : "object",
  "properties" : {
    "mqtt" : {
      "type" : "object",
      "properties" : {
        "identifier" : {
          "type" : "string"
        },
        "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"
          } ]
        },
        "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
        },
        "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" : "General connection options such as keep alive and user properties to pass to client.",
          "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" : "Configuration for an exponential backoff reconnect strategy.",
          "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
        },
        "retry" : {
          "type" : "object",
          "properties" : {
            "retries" : {
              "type" : "integer",
              "description" : "Number of retry attempts after a request failure.",
              "default" : "3",
              "minimum" : -2147483648,
              "maximum" : 2147483647
            },
            "backoffDelay" : {
              "type" : "string",
              "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
              "description" : "Initial delay before the first retry attempt.",
              "default" : "PT0.2S"
            },
            "maxBackoffDelay" : {
              "type" : "string",
              "pattern" : "^(\\d+[smhd]|P(T|\\d+[YMD]).*)",
              "description" : "Maximum delay between consecutive retry attempts.",
              "default" : "PT3S"
            }
          },
          "additionalProperties" : false
        },
        "exceptionHandler" : {
          "type" : "string",
          "description" : "Custom exception handler enabling interception of all errors related to this sink."
        }
      },
      "required" : [ "address" ],
      "additionalProperties" : false
    }
  },
  "required" : [ "mqtt" ],
  "additionalProperties" : false
}
