{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Widgets",
    "type": "object",
    "definitions": {
        "cloudstatus": {
            "type": "object",
            "properties": {
                "providerId": {
                    "type": "string",
                    "enum": [
                        "amazon",
                        "digitalOcean",
                        "google",
                        "joyent",
                        "linode",
                        "rackspace",
                        "salesforce",
                        "softlayer",
                        "windowsAzure"
                    ]
                },
                "feedUrl": {
                    "type": "string"
                }
            },
            "required": [
                "providerId",
                "feedUrl"
            ]
        },
        "elasticGraph": {
            "type": "object",
            "properties": {
                "filter": {
                    "type": "object"
                },
                "type": {
                    "type": "string",
                    "enum": [
                        "line",
                        "area"
                    ]
                },
                "searchFilter": {
                    "type": "string"
                },
                "tall": {
                    "type": "boolean"
                },
                "seriesStates": {
                    "type": "object",
                    "properties": {
                        "series": {
                            "type": "object",
                            "properties": {
                                "^\\w+{24}: .+": {
                                    "type": "string",
                                    "enum": [
                                        "left",
                                        "right",
                                        "disabled"
                                    ]
                                }
                            }
                        }
                    }
                },
                "sectionFilter": {
                    "type": "string"
                }
            },
            "required": [
                "filter",
                "type",
                "searchFilter"
            ]
        },
        "graph": {
            "type": "object",
            "properties": {
                "filter": {
                    "type": "object"
                },
                "type": {
                    "type": "string",
                    "enum": [
                        "line",
                        "area"
                    ]
                },
                "tall": {
                    "type": "boolean"
                },
                "seriesStates": {
                    "type": "object",
                    "properties": {
                        "series": {
                            "type": "object",
                            "properties": {
                                "^\\w+{24}: .+": {
                                    "type": "string",
                                    "enum": [
                                        "left",
                                        "right",
                                        "disabled"
                                    ]
                                }
                            }
                        }
                    }
                }
            },
            "required": [
                "filter",
                "type"
            ]
        },
        "rss": {
            "type": "object",
            "properties": {
                "feedUrl": {
                    "type": "string"
                }
            },
            "required": [
                "feedUrl"
            ]
        },
        "serviceStatus": {
            "type": "object",
            "properties": {
                "serviceId": {
                    "type": "string",
                    "format": "mongoId"
                }
            },
            "required": [
                "serviceId"
            ]
        },
        "openAlerts": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "type": {
                    "type": "string",
                    "enum": [
                        "device",
                        "serviceGroup",
                        "deviceGroup",
                        "service"
                    ]
                },
                "isGroup": {
                    "type": "boolean"
                }
            },
            "additionalProperties": false
        }
    },
    "properties": {
        "dashboardId": {
            "type": "string",
            "format": "mongoId"
        },
        "type": {
            "type": "string",
            "enum": [
                "cloudstatus",
                "elasticGraph",
                "graph",
                "openAlerts",
                "rss",
                "serviceStatus"
            ]
        },
        "config": {
            "oneOf": [
                {
                    "$ref": "#/definitions/elasticGraph"
                },
                {
                    "$ref": "#/definitions/cloudstatus"
                },
                {
                    "$ref": "#/definitions/graph"
                },
                {
                    "$ref": "#/definitions/rss"
                },
                {
                    "$ref": "#/definitions/serviceStatus"
                },
                {
                    "$ref": "#/definitions/openAlerts"
                }
            ]
        }
    },
    "required": [
        "dashboardId",
        "type",
        "config"
    ]
}