{
    "$schema": "http://json-schema.org/schema#",
    "$id": "https://ris-live.ripe.net/schemas/v1/ris_subscribe.schema.json",
    "type": "object",
    "description": "Instructs the server to start sending `ris_message` messages matching the given filters",
    "required": [],
    "additionalProperties": false,
    "examples": [
        {
            "host": "rrc01",
            "type": "UPDATE",
            "require": "announcements",
            "path": "64496,64497$"
        }
    ],
    "properties": {
        "host": {
            "type": "string",
            "description": "Only include messages collected by a particular RRC"
        },
        "type": {
            "type": "string",
            "description": "Only include messages of a given BGP or RIS type",
            "enum": ["UPDATE", "OPEN", "NOTIFICATION", "KEEPALIVE", "RIS_PEER_STATE"]
        },
        "require": {
            "type": "string",
            "description": "Only include messages containing a given key",
            "examples": ["announcements", "withdrawals"]
        },
        "peer": {
            "type": "string",
            "description": "Only include messages sent by the given BGP peer",
            "anyOf": [
                {"format": "ipv4"},
                {"format": "ipv6"}
            ]
        },
        "path": {
            "description": "ASN or pattern to match against the AS PATH attribute",
            "anyOf": [
                {
                    "type": "integer",
                    "title": "ASN"
                },
                {
                    "title": "AS path pattern",
                    "type": "string",
                    "description": "Comma-separated pattern describing all or part of the AS path. Can optionally begin with ^ to match the first item of the path (the last traversed ASN), and/or end with $ to match the last item of the path (the originating ASN). The entire pattern can be prefixed with ! to invert the match. AS_SETs should be written as JSON arrays of integers in ascending order and with no spaces. Note: this is not a regular expression",
                    "examples": [
                        "789$",
                        "^123,456,789,[789,10111]$",
                        "!6666$",
                        "!^3333"
                    ]
                }
            ]
        },
        "prefix": {
            "description": "Filter UPDATE messages by prefixes in announcements or withdrawals",
            "anyOf": [
                {
                    "type": "string",
                    "title": "IPv4 or IPv6 CIDR prefix"
                },
                {
                    "type": "array",
                    "title": "Array of CIDR prefixes",
                    "description": "For the purposes of subsequent `ris_unsubscribe` messages, each prefix results in a separate subscription that can be stopped independently",
                    "items": {
                        "type": "string",
                        "title": "IPv4 or IPv6 CIDR prefix"
                    }
                }
            ]
        },
        "moreSpecific": {
            "type": "boolean",
            "description": "Match prefixes that are more specific (part of) `prefix`",
            "default": true
        },
        "lessSpecific": {
            "type": "boolean",
            "description": "Match prefixes that are less specific (contain) `prefix`",
            "default": false
        },
        "socketOptions": {
            "type": "object",
            "description": "Options that apply to *all* subscriptions over the current WebSocket. If a new subscription contains `socketOptions` it will override those from previous subscriptions",
            "required": [],
            "additionalProperties": false,
            "properties": {
                "includeRaw": {
                    "type": "boolean",
                    "default": false,
                    "description": "Include a Base64-encoded version of the original binary BGP message as `raw` for all subscriptions"
                },
                "acknowledge": {
                    "type": "boolean",
                    "default": false,
                    "description": "Send a `ris_subscribe_ok` message for all succesful subscriptions"
                }
            }
        }
    }
}
