{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "light": {
            "oneOf": [
                {
                    "type": "object",
                    "properties": {
                        "type": {
                            "enum": [
                                "adafruit_lpd8806",
                                "epistar_lpd8806"
                            ]
                        },
                        "num_leds": {
                            "type": "integer",
                            "minimum": 1
                        },
                        "simulate_mode": {
                            "type": "boolean"
                        },
                        "spidev": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "type",
                        "num_leds"
                    ],
                    "additionalProperties": false
                },
                {
                    "type": "object",
                    "properties": {
                        "type": {
                            "enum": [
                                "console"
                            ]
                        },
                        "num_leds": {
                            "type": "integer",
                            "minimum": 1
                        }
                    },
                    "required": [
                        "type",
                        "num_leds"
                    ],
                    "additionalProperties": false
                }
            ]
        },
        "ci_server": {
            "oneOf": [
                {
                    "type": "object",
                    "properties": {
                        "type": {
                            "enum": [
                                "jenkins"
                            ]
                        },
                        "url": {
                            "type": "string",
                            "pattern": "^https?://[0-9a-zA-Z-_.]+:?[0-9]+$"
                        },
                        "pollrate_s": {
                            "type": "integer",
                            "minimum": 1
                        }
                    },
                    "required": [
                        "type",
                        "url",
                        "pollrate_s"
                    ],
                    "additionalProperties": false
                },
                {
                    "type": "object",
                    "properties": {
                        "type": {
                            "enum": [
                                "circleci",
                                "buildkite"
                            ]
                        },
                        "api_token": {
                            "type": "string"
                        },
                        "username": {
                            "type": "string"
                        },
                        "pollrate_s": {
                            "type": "integer",
                            "minimum": 1
                        }
                    },
                    "required": [
                        "type",
                        "api_token",
                        "username",
                        "pollrate_s"
                    ],
                    "additionalProperties": false
                },
                {
                    "type": "object",
                    "properties": {
                        "type": {
                            "enum": [
                                "travisci"
                            ]
                        },
                        "username": {
                            "type": "string"
                        },
                        "pollrate_s": {
                            "type": "integer",
                            "minimum": 1
                        }
                    },
                    "required": [
                        "type",
                        "username",
                        "pollrate_s"
                    ],
                    "additionalProperties": false
                },
                {
                    "type": "object",
                    "properties": {
                        "type": {
                            "enum": [
                                "bamboo"
                            ]
                        },
                        "username": {
                            "$ref": "#/definitions/nonEmptyString"
                        },
                        "password": {
                            "$ref": "#/definitions/nonEmptyString"
                        },
                        "url": {
                            "type": "string"
                        },
                        "pollrate_s": {
                            "type": "integer",
                            "minimum": 1
                        }
                    },
                    "required": [
                        "type",
                        "url",
                        "pollrate_s"
                    ],
                    "additionalProperties": false
                }
            ]
        },
        "jobs": {
            "type": "array",
            "_uniqueItems": true,
            "minItems": 0,
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string"
                    },
                    "branch": {
                        "type": "string"
                    }
                },
                "required": [
                    "name",
                    "branch"
                ],
                "additionalProperties": false
            }
        }
    },
    "required": [
        "light",
        "ci_server",
        "jobs"
    ],
    "definitions": {
        "nonEmptyString": {
            "type": "string",
            "minLength": 1
        }
    }
}