{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "id": "https://sharphosting.uk/schemas/sites",
    "title": "Sites",
    "description": "Schema for data describing web server configurations.",
    "type": "object",
    "properties": {
        "web_server": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string",
                    "pattern": "^[a-z]([a-z0-9_-]*[a-z])?$"
                },
                "user": {
                    "type": "string"
                },
                "group": {
                    "type": "string"
                }
            },
            "required": [
                "type",
                "user",
                "group"
            ],
            "additionalProperties": false
        },
        "directory_structure": {
            "type": "object",
            "properties": {
                "user": {
                    "type": "string"
                },
                "group": {
                    "type": "string"
                },
                "d_mode": {
                    "type": "string",
                    "pattern": "^[0-7]{3,4}$"
                },
                "f_mode": {
                    "type": "string",
                    "pattern": "^[0-7]{3,4}$"
                },
                "directories": {
                    "type": "object",
                    "patternProperties": {
                        "^[^/ ]+$": {
                            "title": "Directory",
                            "type": "object",
                            "properties": {
                                "allow_specials": {
                                    "type": "boolean"
                                },
                                "user": {
                                    "type": "string"
                                },
                                "group": {
                                    "type": "string"
                                },
                                "d_mode": {
                                    "type": "string",
                                    "pattern": "^[0-7]{3,4}$"
                                },
                                "f_mode": {
                                    "type": "string",
                                    "pattern": "^[0-7]{3,4}$"
                                },
                                "optional": {
                                    "type": "string",
                                    "pattern": "^[a-z]([a-z0-9_-]*[a-z])?$"
                                },
                                "optional_default": {
                                    "type": "boolean"
                                },
                                "contents": {
                                    "user": {
                                        "type": "string"
                                    },
                                    "group": {
                                        "type": "string"
                                    },
                                    "d_mode": {
                                        "type": "string",
                                        "pattern": "^[0-7]{3,4}$"
                                    },
                                    "f_mode": {
                                        "type": "string",
                                        "pattern": "^[0-7]{3,4}$"
                                    }
                                }
                            },
                            "additionalProperties": false,
                            "dependencies": {
                                "optional_default": [
                                    "optional"
                                ]
                            }
                        }
                    },
                    "additionalProperties": false
                }
            },
            "required": [
                "user",
                "group",
                "d_mode",
                "f_mode",
                "directories"
            ],
            "additionalProperties": false
        },
        "site_types": {
            "type": "object",
            "patternProperties": {
                "^[a-z]([a-z0-9_-]*[a-z])?$": {
                    "title": "Site Type",
                    "type": "object",
                    "properties": {
                        "temp_dirs": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "pattern": "^(/[^/ ]+)+$"
                            }
                        },
                        "world_writable_dirs": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "pattern": "^(/[^/ ]+)+$"
                            }
                        },
                        "read_only_files": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "pattern": "^(/[^/ ]+)+$"
                            }
                        },
                        "server_owned_files": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "pattern": "^(/[^/ ]+)+$"
                            }
                        },
                        "ignore_permissions": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "pattern": "^(/[^/ ]+)+/?$"
                            }
                        },
                        "options": {
                            "type": "object",
                            "patternProperties": {
                                "^[a-z]([a-z0-9_-]*[a-z])?$": {
                                    "type": "boolean"
                                }
                            },
                            "additionalProperties": false
                        }
                    },
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        },
        "sites": {
            "type": "object",
            "patternProperties": {
                "^(/[^/ ]+)+$": {
                    "title": "Site Folder",
                    "type": "object",
                    "properties": {
                        "user": {
                            "type": "string"
                        },
                        "type": {
                            "type": "string"
                        },
                        "temp_dirs": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "pattern": "^(/[^/ ]+)+$"
                            }
                        },
                        "world_writable_dirs": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "pattern": "^(/[^/ ]+)+$"
                            }
                        },
                        "read_only_files": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "pattern": "^(/[^/ ]+)+$"
                            }
                        },
                        "server_owned_files": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "pattern": "^(/[^/ ]+)+$"
                            }
                        },
                        "ignore_permissions": {
                            "type": "array",
                            "items": {
                                "type": "string",
                                "pattern": "^(/[^/ ]+)+/?$"
                            }
                        },
                        "options": {
                            "type": "object",
                            "patternProperties": {
                                "^[a-z]([a-z0-9_-]*[a-z])?$": {
                                    "type": "boolean"
                                }
                            },
                            "additionalProperties": false
                        }
                    },
                    "required": [
                        "user",
                        "type"
                    ],
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        }
    },
    "additionalProperties": false
}