{
  "$schema" : "http://json-schema.org/draft-07/schema#",
  "title" : "Source Service Configuration",
  "type" : "object",
  "additionalProperties" : true,
  "properties" : {
    "configuration" : {
      "type" : "object",
      "additionalProperties" : { },
      "description" : "Application specific configuration for this sharedConfig."
    },
    "sslDetails" : {
      "$ref" : "#/definitions/SslDetails",
      "description" : "SSL connection details for Kafka clients."
    },
    "saslDetails" : {
      "$ref" : "#/definitions/SaslDetails",
      "description" : "SASL authentication configuration details.",
      "anyOf" : [ {
        "required" : [ "saslMechanism", "kerberosServiceName" ]
      }, {
        "required" : [ "saslMechanism", "userName", "password" ]
      } ]
    },
    "securityProtocol" : {
      "type" : "string",
      "enum" : [ "PLAINTEXT", "SSL", "SASL_PLAINTEXT", "SASL_SSL" ],
      "description" : "Protocol used to communicate with brokers. By default, 'PLAINTEXT' will be used"
    },
    "regexSubscription" : {
      "type" : "boolean",
      "default" : false,
      "description" : "Flag to specify if the subscription is for Kafka topic pattern"
    },
    "consumerGroupId" : {
      "type" : "string",
      "default" : "Diffusion_Kafka_Adapter_ConsumerGroup",
      "description" : "A unique string that identifies the consumer group for Kafka consumers created for the service",
      "minLength" : 1
    },
    "consumerCount" : {
      "type" : "integer",
      "minimum" : 1,
      "default" : 1,
      "description" : "Number of Kafka consumers to be created for the service"
    },
    "diffusionTopicPattern" : {
      "type" : "string",
      "default" : "${topic}/${partition}",
      "description" : "Diffusion topic pattern to use to create/publish to Diffusion topics. The pattern can contain ${topic}, ${key} and ${partition} which will be replaced by Kafka topic, key and partition value respectively. For e.g: If this configuration's value is: 'diffusion/${topic}/${key}/${partition}', Kafka topic is 'sampleTopic', key is 'key' and partition is 0, resulting diffusion topic created will be 'diffusion/sampleTopic/key/0'",
      "minLength" : 1
    },
    "createTopicHierarchy" : {
      "type" : "boolean",
      "default" : false,
      "description" : "Kafka supports use of '.', '-' and '_' characters in its topic name. If Kafka topic name is to be used in created Diffusion topic name, such characters can be used as they are, or, a Diffusion topic hierarchy can be created by replacing such chars with '/'. This flag can be set to true, if a hierarchical Diffusion topic name should be created from Kafka topic."
    },
    "pollTimeoutMs" : {
      "type" : "integer",
      "minimum" : 1,
      "maximum" : 9223372036854775807,
      "default" : 500,
      "description" : "Kafka consumer poll timeout in milliseconds."
    },
    "updateMode" : {
      "type" : "string",
      "default" : "STREAMING",
      "enum" : [ "SIMPLE", "SIMPLE_SYNC", "STREAMING" ],
      "description" : "Update mode used when publishing data to Diffusion topic"
    },
    "bootstrapServers" : {
      "type" : "array",
      "items" : {
        "type" : "string"
      },
      "description" : "List of host and port pairs of the Kafka brokers in the Kafka cluster, e.g: http://localhost:9092"
    },
    "kafkaTopics" : {
      "type" : "array",
      "items" : {
        "type" : "string"
      },
      "description" : "List of Kafka topics or a regular expression for subscription."
    },
    "payloadConvertor" : {
      "type" : "string",
      "description" : "This property is deprecated. From 2.0 version of the adapter, payload converters should be configured as part of framework configuration."
    },
    "keyType" : {
      "type" : "string",
      "enum" : [ "BYTEARRAY", "BYTEBUFFER", "BYTES", "DOUBLE", "FLOAT", "INTEGER", "LONG", "SHORT", "STRING", "UUID", "JSON", "AVRO" ],
      "description" : "Data type of 'key' for this Kafka topics subscription"
    },
    "valueType" : {
      "type" : "string",
      "enum" : [ "BYTEARRAY", "BYTEBUFFER", "BYTES", "DOUBLE", "FLOAT", "INTEGER", "LONG", "SHORT", "STRING", "UUID", "JSON", "AVRO" ],
      "description" : "Data type of 'value' for this Kafka topics subscription"
    },
    "headers" : {
      "type" : "array",
      "items" : {
        "type" : "string"
      },
      "description" : "This property is deprecated. From 2.0 version of the adapter, headers should be configured as part of 'DefaultConsumerRecordToJsonConverter' payload converter configuration in the framework configuration."
    }
  },
  "definitions" : {
    "Object" : {
      "type" : "object",
      "additionalProperties" : true,
      "properties" : { }
    },
    "SslDetails" : {
      "type" : "object",
      "additionalProperties" : true,
      "properties" : {
        "truststoreLocation" : {
          "type" : "string",
          "description" : "Kafka client's truststore file location. This is used to set value for ssl.truststore.location"
        },
        "truststorePassword" : {
          "type" : "string",
          "format" : "hidden",
          "description" : "Kafka client's truststore password. This is used to set value for ssl.truststore.password"
        },
        "keystoreLocation" : {
          "type" : "string",
          "description" : "Kafka client's keystore file location. This is used to set value for ssl.keystore.location"
        },
        "keystorePassword" : {
          "type" : "string",
          "format" : "hidden",
          "description" : "Kafka client's keystore password. This is used to set value for ssl.keystore.password"
        },
        "sslKeyPassword" : {
          "type" : "string",
          "format" : "hidden",
          "description" : "This is used to set value for ssl.key.password"
        }
      },
      "required" : [ "truststoreLocation" ]
    },
    "SaslDetails" : {
      "type" : "object",
      "additionalProperties" : true,
      "anyOf" : [ {
        "required" : [ "saslMechanism", "kerberosServiceName" ]
      }, {
        "required" : [ "saslMechanism", "userName", "password" ]
      } ],
      "properties" : {
        "saslMechanism" : {
          "type" : "string",
          "enum" : [ "PLAIN", "GSSAPI", "SCRAM_SHA_256", "SCRAM_SHA_512" ],
          "description" : "SASL Authentication mechanism. This is used to set value for sasl.mechanism"
        },
        "userName" : {
          "type" : "string",
          "description" : "Username for PLAIN SASL. This is used to create value for sasl.jaas.config"
        },
        "password" : {
          "type" : "string",
          "format" : "hidden",
          "description" : "Password for PLAIN SASL. This is used to create value for sasl.jaas.config"
        },
        "kerberosServiceName" : {
          "type" : "string",
          "description" : "Kerberos service name for GSSAPI SASL. This is used to set value for sasl.kerberos.service.name"
        }
      },
      "required" : [ "saslMechanism" ]
    }
  }
}