{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://anectico.com/schemas/agent-events-v1.json",
  "title": "Anectico operational agent event v1",
  "$defs": {
    "issue.first_seen": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "version",
        "occurred_at",
        "delivered_at",
        "attempt",
        "workspace_id",
        "project_id",
        "subject",
        "facts"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "type": {
          "const": "issue.first_seen"
        },
        "version": {
          "const": 1
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "delivered_at": {
          "type": "string",
          "format": "date-time"
        },
        "attempt": {
          "type": "integer",
          "minimum": 1,
          "maximum": 8
        },
        "workspace_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "project_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "subject": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "id"
          ],
          "properties": {
            "kind": {
              "const": "issue"
            },
            "id": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        },
        "facts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "state"
          ],
          "properties": {
            "state": {
              "const": "new"
            }
          }
        },
        "proof_url": {
          "type": "string",
          "format": "uri",
          "maxLength": 2048
        }
      }
    },
    "issue.regressed": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "version",
        "occurred_at",
        "delivered_at",
        "attempt",
        "workspace_id",
        "project_id",
        "subject",
        "facts"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "type": {
          "const": "issue.regressed"
        },
        "version": {
          "const": 1
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "delivered_at": {
          "type": "string",
          "format": "date-time"
        },
        "attempt": {
          "type": "integer",
          "minimum": 1,
          "maximum": 8
        },
        "workspace_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "project_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "subject": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "id"
          ],
          "properties": {
            "kind": {
              "const": "issue"
            },
            "id": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        },
        "facts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "state"
          ],
          "properties": {
            "state": {
              "const": "regressed"
            }
          }
        },
        "proof_url": {
          "type": "string",
          "format": "uri",
          "maxLength": 2048
        }
      }
    },
    "alert.fired": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "version",
        "occurred_at",
        "delivered_at",
        "attempt",
        "workspace_id",
        "project_id",
        "subject",
        "facts"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "type": {
          "const": "alert.fired"
        },
        "version": {
          "const": 1
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "delivered_at": {
          "type": "string",
          "format": "date-time"
        },
        "attempt": {
          "type": "integer",
          "minimum": 1,
          "maximum": 8
        },
        "workspace_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "project_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "subject": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "id"
          ],
          "properties": {
            "kind": {
              "const": "alert"
            },
            "id": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        },
        "facts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "state"
          ],
          "properties": {
            "state": {
              "const": "firing"
            },
            "severity": {
              "enum": [
                "info",
                "warning",
                "critical"
              ]
            }
          }
        }
      }
    },
    "alert.recovered": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "version",
        "occurred_at",
        "delivered_at",
        "attempt",
        "workspace_id",
        "project_id",
        "subject",
        "facts"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "type": {
          "const": "alert.recovered"
        },
        "version": {
          "const": 1
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "delivered_at": {
          "type": "string",
          "format": "date-time"
        },
        "attempt": {
          "type": "integer",
          "minimum": 1,
          "maximum": 8
        },
        "workspace_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "project_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "subject": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "id"
          ],
          "properties": {
            "kind": {
              "const": "alert"
            },
            "id": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        },
        "facts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "state"
          ],
          "properties": {
            "state": {
              "const": "recovered"
            }
          }
        }
      }
    },
    "incident.opened": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "version",
        "occurred_at",
        "delivered_at",
        "attempt",
        "workspace_id",
        "project_id",
        "subject",
        "facts"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "type": {
          "const": "incident.opened"
        },
        "version": {
          "const": 1
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "delivered_at": {
          "type": "string",
          "format": "date-time"
        },
        "attempt": {
          "type": "integer",
          "minimum": 1,
          "maximum": 8
        },
        "workspace_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "project_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "subject": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "id"
          ],
          "properties": {
            "kind": {
              "const": "incident"
            },
            "id": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        },
        "facts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "state"
          ],
          "properties": {
            "state": {
              "const": "open"
            },
            "severity": {
              "enum": [
                "sev1",
                "sev2",
                "sev3",
                "sev4"
              ]
            }
          }
        },
        "proof_url": {
          "type": "string",
          "format": "uri",
          "maxLength": 2048
        }
      }
    },
    "incident.resolved": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "version",
        "occurred_at",
        "delivered_at",
        "attempt",
        "workspace_id",
        "project_id",
        "subject",
        "facts"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "type": {
          "const": "incident.resolved"
        },
        "version": {
          "const": 1
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "delivered_at": {
          "type": "string",
          "format": "date-time"
        },
        "attempt": {
          "type": "integer",
          "minimum": 1,
          "maximum": 8
        },
        "workspace_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "project_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "subject": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "id"
          ],
          "properties": {
            "kind": {
              "const": "incident"
            },
            "id": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        },
        "facts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "state"
          ],
          "properties": {
            "state": {
              "const": "resolved"
            }
          }
        },
        "proof_url": {
          "type": "string",
          "format": "uri",
          "maxLength": 2048
        }
      }
    },
    "test": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "type",
        "version",
        "occurred_at",
        "delivered_at",
        "attempt",
        "workspace_id",
        "project_id",
        "subject",
        "facts"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "type": {
          "const": "test"
        },
        "version": {
          "const": 1
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "delivered_at": {
          "type": "string",
          "format": "date-time"
        },
        "attempt": {
          "type": "integer",
          "minimum": 1,
          "maximum": 8
        },
        "workspace_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "project_id": {
          "type": "string",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "subject": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "id"
          ],
          "properties": {
            "kind": {
              "const": "destination"
            },
            "id": {
              "type": "string",
              "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
            }
          }
        },
        "facts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "state"
          ],
          "properties": {
            "state": {
              "const": "test"
            }
          }
        }
      }
    }
  },
  "oneOf": [
    {
      "$ref": "#/$defs/issue.first_seen"
    },
    {
      "$ref": "#/$defs/issue.regressed"
    },
    {
      "$ref": "#/$defs/alert.fired"
    },
    {
      "$ref": "#/$defs/alert.recovered"
    },
    {
      "$ref": "#/$defs/incident.opened"
    },
    {
      "$ref": "#/$defs/incident.resolved"
    },
    {
      "$ref": "#/$defs/test"
    }
  ]
}
