{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "id": {
            "type": "string",
            "pattern": "^[A-Fa-f\\d]{24}$"
        },
        "deviceId": {
            "type": "string",
            "pattern": "^[A-Fa-f\\d]{24}$"
        },
        "applicationId": {
            "type": "string",
            "pattern": "^[A-Fa-f\\d]{24}$"
        },
        "creationDate": {
            "type": "string",
            "format": "date-time"
        },
        "lastUpdated": {
            "type": "string",
            "format": "date-time"
        },
        "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
        },
        "description": {
            "type": "string",
            "maxLength": 32767
        },
        "tags": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "key": {
                        "type": "string",
                        "pattern": "^[0-9a-zA-Z_-]{1,255}$"
                    },
                    "value": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255
                    }
                },
                "required": [
                    "key",
                    "value"
                ],
                "additionalProperties": false
            },
            "maxItems": 100
        },
        "attributes": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string",
                        "pattern": "^[0-9a-zA-Z_-]{1,255}$"
                    },
                    "dataType": {
                        "type": "string",
                        "enum": [
                            "string",
                            "number",
                            "gps",
                            "boolean",
                            "blob"
                        ]
                    },
                    "contentType": {
                        "type": "string",
                        "maxLength": 64
                    },
                    "description": {
                        "type": "string",
                        "maxLength": 32767
                    },
                    "attributeTags": {
                        "type": "object",
                        "patternProperties": {
                            "^[0-9a-zA-Z_-]{1,255}$": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 255
                            }
                        },
                        "additionalProperties": false
                    },
                    "system": {
                        "type": "object",
                        "properties": {
                            "aggregation": {
                                "type": "string",
                                "enum": [
                                    "FIRST",
                                    "LAST",
                                    "COUNT",
                                    "MAX",
                                    "MIN",
                                    "MEDIAN",
                                    "MEAN",
                                    "SUM",
                                    "STD_DEV"
                                ]
                            },
                            "aggregationOptions": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "additionalProperties": false
                                },
                                "additionalProperties": false,
                                "maxItems": 0
                            },
                            "childAttributes": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "name": {
                                            "type": "string",
                                            "pattern": "^[0-9a-zA-Z_-]{1,255}$"
                                        },
                                        "mode": {
                                            "type": "string",
                                            "enum": [
                                                "all",
                                                "whitelist",
                                                "blacklist"
                                            ]
                                        },
                                        "deviceIds": {
                                            "type": "array",
                                            "items": {
                                                "type": "string",
                                                "pattern": "^[A-Fa-f\\d]{24}$"
                                            },
                                            "maxItems": 1000
                                        },
                                        "deviceTags": {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "properties": {
                                                    "key": {
                                                        "type": "string",
                                                        "pattern": "^[0-9a-zA-Z_-]{1,255}$"
                                                    },
                                                    "value": {
                                                        "type": "string",
                                                        "minLength": 1,
                                                        "maxLength": 255
                                                    }
                                                },
                                                "additionalProperties": false
                                            },
                                            "maxItems": 100
                                        }
                                    },
                                    "required": [
                                        "name",
                                        "mode"
                                    ],
                                    "additionalProperties": false
                                },
                                "maxItems": 256
                            }
                        },
                        "additionalProperties": false
                    }
                },
                "required": [
                    "name",
                    "dataType"
                ],
                "additionalProperties": false
            },
            "maxItems": 256
        },
        "deviceClass": {
            "type": "string",
            "enum": [
                "standalone",
                "gateway",
                "peripheral",
                "floating",
                "edgeCompute",
                "system"
            ]
        },
        "gatewayId": {
            "type": "string",
            "pattern": "^[A-Fa-f\\d]{24}$"
        },
        "edgeAgentVersion": {
            "type": "string",
            "pattern": "^(0|([1-9]\\d*))\\.(0|([1-9]\\d*))\\.(0|([1-9]\\d*))$"
        },
        "connectionInfo": {
            "type": "object",
            "properties": {
                "time": {
                    "type": "string",
                    "format": "date-time"
                },
                "connected": {
                    "enum": [
                        1,
                        0,
                        null
                    ]
                }
            }
        },
        "parentId": {
            "oneOf": [
                {
                    "type": "string",
                    "pattern": "^[A-Fa-f\\d]{24}$"
                },
                {
                    "type": "null"
                }
            ]
        },
        "systemInterval": {
            "type": "integer",
            "minimum": 5,
            "maximum": 3600
        },
        "keepDuplicates": {
            "type": "boolean"
        }
    }
}