{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "~#PROJECT#~ config",
    "description": "JSON schema for ~#PROJECT#~ configuration",
    "type": "object",
    "properties": {
        "remoteConfigProvider": {
            "description": "Remote configuration source (if any)",
            "type": "string",
            "default": "",
            "enum": [
                "",
                "consul",
                "etcd",
                "envvar"
            ]
        },
        "remoteConfigEndpoint": {
            "description": "Remote configuration URL (ip:port)",
            "type": "string",
            "default": ""
        },
        "remoteConfigPath": {
            "description": "Remote configuration path in which to search for the configuration file (e.g. '/config/~#PROJECT#~')",
            "type": "string",
            "default": ""
        },
        "remoteConfigSecretKeyring": {
            "description": "Path to the openpgp secret keyring used to decrypt the remote configuration data (e.g. '/etc/~#PROJECT#~/configkey.gpg'); if empty a non secure connection will be used instead",
            "type": "string",
            "default": ""
        },
        "serverAddress": {
            "description": "Internal HTTP address (ip:port) or just (:port)",
            "type": "string",
            "default": ":8017"
        },
        "tls": {
            "description": "TLS configuration",
            "type": "object",
            "properties": {
                "enabled": {
                    "description": "Enable the server in HTTS-only mode",
                    "type": "boolean",
                    "default": false
                },
                "certPem": {
                    "description": "TLS certificate in PEM format",
                    "type": "string",
                    "default": ""
                },
                "keyPem": {
                    "description": "TLS private key in PEM format",
                    "type": "string",
                    "default": ""
                }
            },
            "additionalProperties": false,
            "required": [
                "enabled",
                "certPem",
                "keyPem"
            ]
        },
        "log": {
            "description": "Logging settings",
            "type": "object",
            "properties": {
                "level": {
                    "description": "Defines the default log level",
                    "type": "string",
                    "default": "DEBUG",
                    "enum": [
                        "EMERGENCY",
                        "ALERT",
                        "CRITICAL",
                        "ERROR",
                        "WARNING",
                        "NOTICE",
                        "INFO",
                        "DEBUG"
                    ]
                },
                "network": {
                    "description": "(OPTIONAL) Network type used by the Syslog",
                    "type": "string",
                    "default": "",
                    "enum": [
                        "",
                        "udp",
                        "tcp"
                    ]
                },
                "address": {
                    "description": "(OPTIONAL) Network address of the Syslog daemon (ip:port) or just (:port)",
                    "type": "string",
                    "default": ""
                }
            },
            "additionalProperties": false,
            "required": [
                "level",
                "network",
                "address"
            ]
        },
        "stats": {
            "description": "StatsD is used to collect usage metrics",
            "type": "object",
            "properties": {
                "prefix": {
                    "description": "StatsD client's string prefix that will be used in every bucket name",
                    "type": "string",
                    "default": "~#PROJECT#~"
                },
                "network": {
                    "description": "Network type used by the StatsD client",
                    "type": "string",
                    "default": "udp",
                    "enum": [
                        "udp",
                        "tcp"
                    ]
                },
                "address": {
                    "description": "Network address of the StatsD daemon (ip:port) or just (:port)",
                    "type": "string",
                    "default": ":8125"
                },
                "flush_period": {
                    "description": "Sets how often (in milliseconds) the StatsD client's buffer is flushed. When 0 the buffer is only flushed when it is full",
                    "type": "integer",
                    "default": 100,
                    "minimum": 0,
                    "maximum": 1000
                }
            },
            "additionalProperties": false,
            "required": [
                "prefix",
                "network",
                "address",
                "flush_period"
            ]
        },
        "user": {
            "description": "user names and hashed passwords with resources/hash/hash",
            "type": "object"
        },
        "jwt": {
            "description": "JWT Authentication",
            "type": "object",
            "properties": {
                "enabled": {
                    "description": "Enable the JWT authentication",
                    "type": "boolean",
                    "default": false
                },
                "key": {
                    "description": "Shared JWT signing key",
                    "type": "string",
                    "default": ""
                },
                "exp": {
                    "description": "JWT token expiration time in minutes",
                    "type": "integer",
                    "default": 5,
                    "minimum": 1
                },
                "renewTime": {
                    "description": "Time in second before the JWT expiration time when the renewal is allowed",
                    "type": "integer",
                    "default": 30,
                    "minimum": 1
                }
            },
            "additionalProperties": false,
            "required": [
                "enabled",
                "key",
                "exp"
            ]
        },
        "proxyAddress": {
            "description": "URL of the server to proxy",
            "type": "string",
            "default": ""
        },
        "mysql": {
            "description": "Mysql settings",
            "type": "object",
            "properties": {
                "DSN": {
                    "description": "MySQL DSN in the format: username:password@protocol(address)/dbname?param=value",
                    "type": "string",
                    "default": ""
                }
            },
            "additionalProperties": false,
            "required": [
                "DSN"
            ]
        },
        "mongodb": {
            "description": "MongoDB Settings",
            "type": "object",
            "properties": {
                "address": {
                    "description": "MongoDB address: [mongodb://][user:pass@]host1[:port1][,host2[:port2],...][/database][?options]",
                    "type": "string",
                    "default": "mongodb://127.0.0.1:27017"
                },
                "database": {
                    "description": "Database name",
                    "type": "string",
                    "default": "annotation-service"
                },
                "user": {
                    "description": "Database user",
                    "type": "string",
                    "default": ""
                },
                "password": {
                    "description": "Database password",
                    "type": "string",
                    "default": ""
                },
                "timeout": {
                    "description": "Connection timeout in seconds",
                    "type": "integer",
                    "default": 60
                }
            },
            "additionalProperties": false,
            "required": [
                "address",
                "database"
            ]
        },
        "elasticsearch": {
            "description": "ElasticSearch Settings",
            "type": "object",
            "properties": {
                "url": {
                    "description": "ElasticSearch url",
                    "type": "string",
                    "default": "http://127.0.0.1:9200"
                },
                "index": {
                    "description": "ElasticSearch main Index",
                    "type": "string",
                    "default": ""
                },
                "username": {
                    "description": "ElasticSearch user name",
                    "type": "string",
                    "default": ""
                },
                "password": {
                    "description": "ElasticSearch password",
                    "type": "string",
                    "default": ""
                }
            },
            "additionalProperties": false,
            "required": [
                "url",
                "index"
            ]
        }
    },
    "additionalProperties": false,
    "required": [
        "serverAddress",
        "tls",
        "log",
        "stats",
        "user",
        "jwt",
        "proxyAddress",
        "mysql",
        "mongodb",
        "elasticsearch"
    ]
}