{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "start": {
            "type": "string",
            "_format": "date-time"
        },
        "end": {
            "type": "string",
            "_format": "date-time"
        },
        "resolution": {
            "type": "number"
        },
        "aggregation": {
            "oneOf": [
                {
                    "oneOf": [
                        {
                            "type": "string",
                            "enum": [
                                "FIRST",
                                "LAST",
                                "COUNT",
                                "MAX",
                                "MIN",
                                "MEDIAN",
                                "MEAN",
                                "SUM",
                                "STD_DEV"
                            ]
                        },
                        {
                            "type": "string",
                            "enum": [
                                "NONE"
                            ]
                        }
                    ]
                },
                {
                    "type": "object",
                    "properties": {
                        "type": {
                            "oneOf": [
                                {
                                    "type": "string",
                                    "enum": [
                                        "FIRST",
                                        "LAST",
                                        "COUNT",
                                        "MAX",
                                        "MIN",
                                        "MEDIAN",
                                        "MEAN",
                                        "SUM",
                                        "STD_DEV"
                                    ]
                                },
                                {
                                    "type": "string",
                                    "enum": [
                                        "NONE"
                                    ]
                                }
                            ]
                        },
                        "options": {
                            "type": "object",
                            "additionalProperties": false
                        }
                    },
                    "additionalProperties": false,
                    "required": [
                        "type"
                    ]
                },
                {
                    "type": "object",
                    "properties": {
                        "type": {
                            "type": "string",
                            "enum": [
                                "TIMEATVALUE"
                            ]
                        },
                        "options": {
                            "type": "object",
                            "properties": {
                                "value": {
                                    "type": "string",
                                    "maxLength": 255
                                }
                            },
                            "additionalProperties": false,
                            "required": [
                                "value"
                            ]
                        }
                    },
                    "additionalProperties": false,
                    "required": [
                        "type",
                        "options"
                    ]
                }
            ]
        },
        "devices": {
            "type": "object",
            "patternProperties": {
                "^[A-Fa-f\\d]{24}$": {
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 255
                        },
                        "points": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "time": {
                                        "type": "string",
                                        "_format": "date-time"
                                    },
                                    "data": {
                                        "type": "object",
                                        "patternProperties": {
                                            "^[0-9a-zA-Z_-]{1,255}$": {
                                                "type": [
                                                    "number",
                                                    "string",
                                                    "boolean"
                                                ]
                                            }
                                        },
                                        "additionalProperties": false
                                    }
                                },
                                "additionalProperties": false,
                                "required": [
                                    "data",
                                    "time"
                                ]
                            }
                        }
                    },
                    "additionalProperties": false,
                    "required": [
                        "name",
                        "points"
                    ]
                }
            },
            "additionalProperties": false
        }
    },
    "additionalProperties": false,
    "required": [
        "start",
        "end",
        "resolution",
        "aggregation",
        "devices"
    ]
}