{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://interchange.stellarview.net/schemas/alert_rule.schema.json",
  "title": "An alert rule: to which roles, by which route, with which escalation. A path names it; the path decides which events.",
  "type": "object",
  "required": [
    "id",
    "roles",
    "route",
    "escalation"
  ],
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9_.-]*$"
    },
    "about": {
      "type": "string"
    },
    "roles": {
      "type": "object",
      "required": [
        "from"
      ],
      "additionalProperties": false,
      "properties": {
        "from": {
          "enum": [
            "asset_role_links",
            "listed"
          ],
          "description": "asset_role_links: the asset's own role links. listed: the roles named here."
        },
        "listed": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "when_asset_has_none": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Stated roles for an asset with no role links. Recorded on the alert as the reason."
        }
      }
    },
    "route": {
      "type": "string",
      "description": "A route id."
    },
    "escalation": {
      "type": [
        "string",
        "null"
      ],
      "description": "An escalation id, or null for none."
    }
  }
}