{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "$ref": "#/definitions/GatewayConfig",
    "definitions": {
        "GatewayConfig": {
            "properties": {
                "id": {
                    "type": "string",
                    "description": "Gateway id this block addresses. A running gateway consumes only the block matching the gateway id its credential authorizes. The id does not need to belong to an already-registered gateway at release time; release validation warns (never blocks) so configuration can be authored ahead of provisioning."
                },
                "connections": {
                    "items": {
                        "$ref": "#/definitions/subcor.v1.GatewayConnection"
                    },
                    "type": "array"
                },
                "mappings": {
                    "items": {
                        "$ref": "#/definitions/subcor.v1.GatewayMapping"
                    },
                    "type": "array"
                }
            },
            "additionalProperties": true,
            "type": "object",
            "title": "Gateway Config",
            "description": "GatewayConfig is one gateway's authored configuration block: the connections it opens and the mappings it evaluates."
        },
        "subcor.v1.GatewayConnection": {
            "properties": {
                "id": {
                    "type": "string",
                    "description": "Unique within the gateway's block; mappings reference it by id."
                },
                "mqtt": {
                    "$ref": "#/definitions/subcor.v1.MqttConnection",
                    "additionalProperties": true
                },
                "line_protocol": {
                    "$ref": "#/definitions/subcor.v1.LineProtocolConnection",
                    "additionalProperties": true
                }
            },
            "additionalProperties": true,
            "type": "object",
            "title": "Gateway Connection",
            "description": "GatewayConnection describes one data source the gateway connects to. The connection kind is the populated arm of `config`; each kind carries exactly the settings that kind understands. String settings support ${env:NAME} interpolation, resolved from the gateway host's environment when the gateway loads the configuration — never at release time — so secrets referenced by environment name are not stored in the release."
        },
        "subcor.v1.GatewayMapping": {
            "properties": {
                "field": {
                    "type": "string",
                    "description": "Canonical dotted model field path, e.g. \"boiler.drum.level\"."
                },
                "connection": {
                    "type": "string",
                    "description": "References a GatewayConnection.id in the same block."
                },
                "key": {
                    "type": "string",
                    "description": "Subscription key on that connection (the topic, for MQTT)."
                },
                "payload": {
                    "enum": [
                        "PAYLOAD_KIND_UNSPECIFIED",
                        0,
                        "PAYLOAD_KIND_JSON",
                        1,
                        "PAYLOAD_KIND_TEXT",
                        2,
                        "PAYLOAD_KIND_LINE_PROTOCOL",
                        3
                    ],
                    "oneOf": [
                        {
                            "type": "string"
                        },
                        {
                            "type": "integer"
                        }
                    ],
                    "title": "Payload Kind",
                    "description": "PayloadKind selects how the raw bytes of an incoming message are decoded before the mapping expressions run."
                },
                "value": {
                    "type": "string",
                    "description": "CEL expression producing the value."
                },
                "quality": {
                    "type": "string",
                    "description": "CEL expression producing the quality."
                },
                "event_time": {
                    "type": "string",
                    "description": "CEL expression producing the event time."
                },
                "qos": {
                    "type": "integer",
                    "description": "MQTT subscription QoS (0–2). Optional; defaults to 1. Ignored by non-MQTT connections."
                }
            },
            "additionalProperties": true,
            "type": "object",
            "title": "Gateway Mapping",
            "description": "GatewayMapping turns messages arriving on one connection key into datapoints on one model field. The value, quality, and event_time expressions are CEL; they are compiled when configuration loads (a compile error fails the release, and would fail gateway startup), while a per-message evaluation error drops that message and is counted."
        },
        "subcor.v1.LineProtocolConnection": {
            "properties": {
                "listen": {
                    "type": "string",
                    "description": "\"stdin\", or a unix socket address of the form \"unix:///path\". At most one connection per gateway may listen on stdin."
                }
            },
            "additionalProperties": true,
            "type": "object",
            "title": "Line Protocol Connection",
            "description": "LineProtocolConnection ingests InfluxDB line protocol from a local stream."
        },
        "subcor.v1.MqttConnection": {
            "properties": {
                "url": {
                    "type": "string",
                    "description": "Broker URL, e.g. \"mqtt://broker.local:1883\"."
                },
                "username": {
                    "type": "string"
                },
                "password": {
                    "type": "string",
                    "description": "Supports ${env:NAME}; an inline literal draws a release-validation warning because it would be stored in the release."
                },
                "client_id": {
                    "type": "string",
                    "description": "MQTT client id. Optional; the gateway derives one when unset."
                }
            },
            "additionalProperties": true,
            "type": "object",
            "title": "Mqtt Connection",
            "description": "MqttConnection subscribes to topics on an MQTT broker."
        }
    }
}