{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "definitions": {
        "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
            }
        },
        "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"
                        ]
                    }
                },
                "required": [
                    "name",
                    "dataType"
                ],
                "additionalProperties": false
            }
        },
        "deviceClass": {
            "type": "string",
            "enum": [
                "standalone",
                "master",
                "owned",
                "floating",
                "virtual"
            ]
        },
        "connectionInfo": {
            "type": "object",
            "properties": {
                "time": {
                    "type": "string",
                    "format": "date-time"
                },
                "connected": {
                    "type": "number"
                }
            }
        }
    },
    "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": {
            "$ref": "#/definitions/tags"
        },
        "attributes": {
            "$ref": "#/definitions/attributes"
        },
        "deviceClass": {
            "$ref": "#/definitions/deviceClass"
        },
        "masterId": {
            "type": "string",
            "pattern": "^[A-Fa-f\\d]{24}$"
        },
        "connectionInfo": {
            "$ref": "#/definitions/connectionInfo"
        }
    }
}