{
    "additionalProperties": false,
    "description": "Schema for SQL Query enrichment configuration",
    "properties": {
        "enabled": {
            "type": "boolean"
        },
        "name": {
            "type": "string"
        },
        "parameters": {
            "additionalProperties": false,
            "properties": {
                "cache": {
                    "additionalProperties": false,
                    "properties": {
                        "size": {
                            "minimum": 0,
                            "type": "integer"
                        },
                        "ttl": {
                            "maximum": 86400,
                            "minimum": 0,
                            "type": "integer"
                        }
                    },
                    "required": [
                        "size",
                        "ttl"
                    ],
                    "type": "object"
                },
                "database": {
                    "additionalProperties": true,
                    "oneOf": [
                        {
                            "additionalProperties": false,
                            "properties": {
                                "postgresql": {
                                    "additionalProperties": false,
                                    "properties": {
                                        "database": {
                                            "minLength": 1,
                                            "type": "string"
                                        },
                                        "host": {
                                            "type": "string"
                                        },
                                        "password": {
                                            "type": "string"
                                        },
                                        "port": {
                                            "maximum": 65535,
                                            "minimum": 1,
                                            "type": "integer"
                                        },
                                        "sslMode": {
                                            "type": "boolean"
                                        },
                                        "username": {
                                            "minLength": 1,
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "host",
                                        "port",
                                        "sslMode",
                                        "username",
                                        "password",
                                        "database"
                                    ],
                                    "type": "object"
                                }
                            },
                            "required": [
                                "postgresql"
                            ],
                            "type": "object"
                        },
                        {
                            "properties": {
                                "mysql": {
                                    "additionalProperties": false,
                                    "properties": {
                                        "database": {
                                            "minLength": 1,
                                            "type": "string"
                                        },
                                        "host": {
                                            "type": "string"
                                        },
                                        "password": {
                                            "type": "string"
                                        },
                                        "port": {
                                            "maximum": 65535,
                                            "minimum": 1,
                                            "type": "integer"
                                        },
                                        "sslMode": {
                                            "type": "boolean"
                                        },
                                        "username": {
                                            "minLength": 1,
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "host",
                                        "port",
                                        "sslMode",
                                        "username",
                                        "password",
                                        "database"
                                    ],
                                    "type": "object"
                                }
                            },
                            "required": [
                                "mysql"
                            ],
                            "type": "object"
                        }
                    ]
                },
                "inputs": {
                    "items": {
                        "additionalProperties": false,
                        "maxProperties": 2,
                        "minProperties": 2,
                        "properties": {
                            "json": {
                                "additionalProperties": false,
                                "properties": {
                                    "field": {
                                        "enum": [
                                            "unstruct_event",
                                            "contexts",
                                            "derived_contexts"
                                        ],
                                        "type": "string"
                                    },
                                    "jsonPath": {
                                        "type": "string"
                                    },
                                    "schemaCriterion": {
                                        "pattern": "^iglu:([a-zA-Z0-9-_.]+)/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)/([1-9][0-9]*|\\*)-((?:0|[1-9][0-9]*)|\\*)-((?:0|[1-9][0-9]*)|\\*)$",
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "field",
                                    "schemaCriterion",
                                    "jsonPath"
                                ],
                                "type": "object"
                            },
                            "placeholder": {
                                "maximum": 64,
                                "minimum": 1,
                                "type": "integer"
                            },
                            "pojo": {
                                "additionalProperties": false,
                                "properties": {
                                    "field": {
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "field"
                                ],
                                "type": "object"
                            }
                        },
                        "required": [
                            "placeholder"
                        ],
                        "type": "object"
                    },
                    "type": "array"
                },
                "output": {
                    "additionalProperties": false,
                    "properties": {
                        "expectedRows": {
                            "enum": [
                                "AT_LEAST_ONE",
                                "AT_LEAST_ZERO",
                                "AT_MOST_ONE",
                                "EXACTLY_ONE"
                            ],
                            "type": "string"
                        },
                        "json": {
                            "additionalProperties": false,
                            "properties": {
                                "describes": {
                                    "enum": [
                                        "ALL_ROWS",
                                        "EVERY_ROW"
                                    ],
                                    "type": "string"
                                },
                                "propertyNames": {
                                    "enum": [
                                        "AS_IS",
                                        "CAMEL_CASE",
                                        "PASCAL_CASE",
                                        "SNAKE_CASE",
                                        "LOWER_CASE",
                                        "UPPER_CASE"
                                    ],
                                    "type": "string"
                                },
                                "schema": {
                                    "pattern": "^iglu:([a-zA-Z0-9-_.]+)/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)/([1-9][0-9]*(?:-(?:0|[1-9][0-9]*)){2})$",
                                    "type": "string"
                                }
                            },
                            "required": [
                                "schema",
                                "propertyNames",
                                "describes"
                            ],
                            "type": "object"
                        }
                    },
                    "type": "object"
                },
                "query": {
                    "additionalProperties": false,
                    "properties": {
                        "sql": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "sql"
                    ],
                    "type": "object"
                }
            },
            "required": [
                "inputs",
                "database",
                "query",
                "output",
                "cache"
            ],
            "type": "object"
        },
        "vendor": {
            "type": "string"
        }
    },
    "required": [
        "name",
        "vendor",
        "enabled",
        "parameters"
    ],
    "self": {
        "format": "jsonschema",
        "name": "sql_query_enrichment_config",
        "vendor": "com.snowplowanalytics.snowplow.enrichments",
        "version": "1-0-0"
    },
    "type": "object"
}