{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://itworx.local/pulse/specs/live-message.schema.json", "title": "Pulse live protocol message", "oneOf": [ { "$ref": "#/$defs/subscribe" }, { "$ref": "#/$defs/unsubscribe" }, { "$ref": "#/$defs/samples" }, { "$ref": "#/$defs/status" }, { "$ref": "#/$defs/error" }, { "$ref": "#/$defs/ping" }, { "$ref": "#/$defs/pong" } ], "$defs": { "base": { "type": "object", "required": [ "schemaVersion", "type" ], "properties": { "schemaVersion": { "type": "integer", "const": 1 }, "type": { "type": "string" } } }, "subscribe": { "type": "object", "additionalProperties": false, "required": [ "schemaVersion", "type", "subscriptionId", "query", "intervalSeconds" ], "properties": { "schemaVersion": { "type": "integer", "const": 1 }, "type": { "const": "subscribe" }, "subscriptionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "query": { "type": "object", "maxProperties": 20 }, "intervalSeconds": { "type": "integer", "minimum": 1, "maximum": 300 } } }, "unsubscribe": { "type": "object", "additionalProperties": false, "required": [ "schemaVersion", "type", "subscriptionId" ], "properties": { "schemaVersion": { "type": "integer", "const": 1 }, "type": { "const": "unsubscribe" }, "subscriptionId": { "type": "string", "minLength": 1, "maxLength": 128 } } }, "sample": { "type": "object", "additionalProperties": false, "required": [ "series", "timestamp", "value", "freshness" ], "properties": { "series": { "type": "string", "maxLength": 512 }, "timestamp": { "type": "string", "format": "date-time" }, "value": { "type": [ "number", "null" ] }, "freshness": { "type": "string", "enum": [ "fresh", "delayed", "stale", "unavailable" ] }, "labels": { "type": "object", "maxProperties": 30 } } }, "samples": { "type": "object", "additionalProperties": false, "required": [ "schemaVersion", "type", "subscriptionId", "sequence", "serverTime", "samples" ], "properties": { "schemaVersion": { "type": "integer", "const": 1 }, "type": { "const": "samples" }, "subscriptionId": { "type": "string", "minLength": 1, "maxLength": 128 }, "sequence": { "type": "integer", "minimum": 0 }, "serverTime": { "type": "string", "format": "date-time" }, "samples": { "type": "array", "maxItems": 10000, "items": { "$ref": "#/$defs/sample" } }, "coalesced": { "type": "boolean" } } }, "status": { "type": "object", "additionalProperties": false, "required": [ "schemaVersion", "type", "subscriptionId", "state" ], "properties": { "schemaVersion": { "type": "integer", "const": 1 }, "type": { "const": "status" }, "subscriptionId": { "type": "string", "maxLength": 128 }, "state": { "type": "string", "enum": [ "subscribed", "resync-required", "paused", "unsubscribed" ] }, "detail": { "type": [ "string", "null" ], "maxLength": 500 } } }, "error": { "type": "object", "additionalProperties": false, "required": [ "schemaVersion", "type", "code", "message", "correlationId" ], "properties": { "schemaVersion": { "type": "integer", "const": 1 }, "type": { "const": "error" }, "subscriptionId": { "type": [ "string", "null" ], "maxLength": 128 }, "code": { "type": "string", "pattern": "^[A-Z0-9_]+$", "maxLength": 80 }, "message": { "type": "string", "maxLength": 500 }, "correlationId": { "type": "string", "maxLength": 128 } } }, "ping": { "type": "object", "additionalProperties": false, "required": [ "schemaVersion", "type", "nonce" ], "properties": { "schemaVersion": { "type": "integer", "const": 1 }, "type": { "const": "ping" }, "nonce": { "type": "string", "maxLength": 128 } } }, "pong": { "type": "object", "additionalProperties": false, "required": [ "schemaVersion", "type", "nonce" ], "properties": { "schemaVersion": { "type": "integer", "const": 1 }, "type": { "const": "pong" }, "nonce": { "type": "string", "maxLength": 128 } } } } }