{
    "$schema": "http://json-schema.org/schema#",
    "$id": "https://ris-live.ripe.net/schemas/v1/ris_message.schema.json",
    "type": "object",
    "required": [
        "timestamp",
        "peer",
        "peer_asn",
        "id",
        "host",
        "type"
    ],
    "examples": [
	{
	    "timestamp": 1568279357.18,
	    "peer": "192.0.2.0",
	    "peer_asn": "64496",
	    "id": "21-192-0-2-0-11187052",
	    "host": "rrc21",
	    "type": "KEEPALIVE"
	}        
    ],
    "title": "Message from a particular RIS Route Collector",
    "description": "Either a BGP message relayed from a peered router, or a metadata update from a route collector. All ris_message objects have these fields, regardless of subtype, which is given as `type` and corresponds to a particular BGP message type",
    "allOf": [
        {
            "if": {"properties": {"type": {"const": "UPDATE"}}},
            "then": {"$ref": "ris_message-UPDATE.schema.json"}
        },
        {
            "if": {"properties": {"type": {"const": "KEEPALIVE"}}},
            "then": {"$ref": "ris_message-KEEPALIVE.schema.json"}
        },
        {
            "if": {"properties": {"type": {"const": "OPEN"}}},
            "then": {"$ref": "ris_message-OPEN.schema.json"}
        },
        {
            "if": {"properties": {"type": {"const": "NOTIFICATION"}}},
            "then": {"$ref": "ris_message-NOTIFICATION.schema.json"}
        },
        {
            "if": {"properties": {"type": {"const": "RIS_PEER_STATE"}}},
            "then": {"$ref": "ris_message-RIS_PEER_STATE.schema.json"}
        }
    ],
    "properties": {
        "timestamp": {
            "type": "number",
            "description": "Time that the message was received by the RIS Route Collector"
        },
        "peer": {
            "description": "IP address of the BGP peer that sent this message",
            "anyOf": [
                {"type": "string", "format": "ipv4", "title": "IPv4 address"},
                {"type": "string", "format": "ipv6", "title": "IPv6 address"}
            ]
        },
        "peer_asn": {
            "description": "Autonomous system of the peer that sent this message",
            "pattern": "^[0-9]+$",
            "type": "string",
            "examples": [
                "65536"
            ]
        },
        "id": {
            "description": "Globally unique identifier for this message, guaranteed to be sequentially sortable with respect to a particular RIS peering session",
            "type": "string"
        },
        "raw": {
            "description": "Hexadecimal encoding of the raw BGP message in network order, only present if `socketOptions.includeRaw` is true",
            "type": "string",
            "examples": [
                "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0072020000005B4001010040020E02030000F09B00001B1B0000316EC0081466321B1B6632FDF36632FE586632FE6C6632FE9D800E2C00020120200112F8000000000000000002230139FE80000000000000CE2DE0FFFE1E5D040030200107FBFD03"
            ]
        },
        "host": {
            "description": "Hostname of the RIS Route Collector that received this message",
            "type": "string"
        },
        "type": {
            "type": "string",
            "enum": ["UPDATE", "KEEPALIVE", "OPEN", "NOTIFICATION", "RIS_PEER_STATE"]
        }
    }
}
