{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "properties": {
        "close_reason": {
          "anyOf": [
            {
              "enum": [
                "redeployed",
                "recovered",
                "deployment_stopped",
                "product_closed"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "closed_at": {
          "anyOf": [
            {
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "deployment_id": {
          "pattern": "^dep_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "detail": {
          "additionalProperties": false,
          "properties": {
            "finding_codes": {
              "items": {
                "maxLength": 64,
                "minLength": 1,
                "type": "string"
              },
              "maxItems": 10,
              "type": "array"
            },
            "phase": {
              "enum": [
                "apply",
                "startup",
                "health_check"
              ],
              "type": "string"
            }
          },
          "required": [
            "phase",
            "finding_codes"
          ],
          "type": "object"
        },
        "environment_id": {
          "pattern": "^env_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "environment_type": {
          "enum": [
            "staging",
            "production"
          ],
          "type": "string"
        },
        "episode_id": {
          "pattern": "^brk_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "kind": {
          "const": "deployment_failed",
          "type": "string"
        },
        "occurrences": {
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991,
          "type": "integer"
        },
        "opened_at": {
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
          "type": "string"
        },
        "product_id": {
          "pattern": "^prod_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "revision_id": {
          "pattern": "^rev_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "state": {
          "enum": [
            "open",
            "closed"
          ],
          "type": "string"
        },
        "workspace_id": {
          "pattern": "^ws_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        }
      },
      "required": [
        "episode_id",
        "workspace_id",
        "product_id",
        "environment_id",
        "environment_type",
        "state",
        "opened_at",
        "closed_at",
        "close_reason",
        "occurrences",
        "deployment_id",
        "revision_id",
        "kind",
        "detail"
      ],
      "type": "object"
    },
    {
      "properties": {
        "close_reason": {
          "anyOf": [
            {
              "enum": [
                "redeployed",
                "recovered",
                "deployment_stopped",
                "product_closed"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "closed_at": {
          "anyOf": [
            {
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "deployment_id": {
          "pattern": "^dep_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "detail": {
          "additionalProperties": false,
          "properties": {
            "detected_by": {
              "enum": [
                "visitor",
                "probe"
              ],
              "type": "string"
            }
          },
          "required": [
            "detected_by"
          ],
          "type": "object"
        },
        "environment_id": {
          "pattern": "^env_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "environment_type": {
          "enum": [
            "staging",
            "production"
          ],
          "type": "string"
        },
        "episode_id": {
          "pattern": "^brk_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "kind": {
          "const": "workload_lost",
          "type": "string"
        },
        "occurrences": {
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991,
          "type": "integer"
        },
        "opened_at": {
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
          "type": "string"
        },
        "product_id": {
          "pattern": "^prod_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "revision_id": {
          "pattern": "^rev_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "state": {
          "enum": [
            "open",
            "closed"
          ],
          "type": "string"
        },
        "workspace_id": {
          "pattern": "^ws_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        }
      },
      "required": [
        "episode_id",
        "workspace_id",
        "product_id",
        "environment_id",
        "environment_type",
        "state",
        "opened_at",
        "closed_at",
        "close_reason",
        "occurrences",
        "deployment_id",
        "revision_id",
        "kind",
        "detail"
      ],
      "type": "object"
    },
    {
      "properties": {
        "close_reason": {
          "anyOf": [
            {
              "enum": [
                "redeployed",
                "recovered",
                "deployment_stopped",
                "product_closed"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "closed_at": {
          "anyOf": [
            {
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "deployment_id": {
          "pattern": "^dep_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "detail": {
          "additionalProperties": false,
          "properties": {
            "health_state": {
              "enum": [
                "unhealthy",
                "not_running"
              ],
              "type": "string"
            },
            "reason_code": {
              "anyOf": [
                {
                  "enum": [
                    "http_status",
                    "timeout",
                    "connection_failed",
                    "process_exited",
                    "not_registered",
                    "workload_absent"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "health_state",
            "reason_code"
          ],
          "type": "object"
        },
        "environment_id": {
          "pattern": "^env_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "environment_type": {
          "enum": [
            "staging",
            "production"
          ],
          "type": "string"
        },
        "episode_id": {
          "pattern": "^brk_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "kind": {
          "const": "health_check_failed",
          "type": "string"
        },
        "occurrences": {
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991,
          "type": "integer"
        },
        "opened_at": {
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
          "type": "string"
        },
        "product_id": {
          "pattern": "^prod_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "revision_id": {
          "pattern": "^rev_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "state": {
          "enum": [
            "open",
            "closed"
          ],
          "type": "string"
        },
        "workspace_id": {
          "pattern": "^ws_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        }
      },
      "required": [
        "episode_id",
        "workspace_id",
        "product_id",
        "environment_id",
        "environment_type",
        "state",
        "opened_at",
        "closed_at",
        "close_reason",
        "occurrences",
        "deployment_id",
        "revision_id",
        "kind",
        "detail"
      ],
      "type": "object"
    },
    {
      "properties": {
        "close_reason": {
          "anyOf": [
            {
              "enum": [
                "redeployed",
                "recovered",
                "deployment_stopped",
                "product_closed"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "closed_at": {
          "anyOf": [
            {
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "deployment_id": {
          "pattern": "^dep_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "detail": {
          "additionalProperties": false,
          "properties": {
            "finding_count": {
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991,
              "type": "integer"
            },
            "highest_severity": {
              "enum": [
                "info",
                "warning",
                "error",
                "critical"
              ],
              "type": "string"
            }
          },
          "required": [
            "finding_count",
            "highest_severity"
          ],
          "type": "object"
        },
        "environment_id": {
          "pattern": "^env_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "environment_type": {
          "enum": [
            "staging",
            "production"
          ],
          "type": "string"
        },
        "episode_id": {
          "pattern": "^brk_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "kind": {
          "const": "vulnerability_found",
          "type": "string"
        },
        "occurrences": {
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991,
          "type": "integer"
        },
        "opened_at": {
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
          "type": "string"
        },
        "product_id": {
          "pattern": "^prod_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "revision_id": {
          "pattern": "^rev_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        },
        "state": {
          "enum": [
            "open",
            "closed"
          ],
          "type": "string"
        },
        "workspace_id": {
          "pattern": "^ws_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
          "type": "string"
        }
      },
      "required": [
        "episode_id",
        "workspace_id",
        "product_id",
        "environment_id",
        "environment_type",
        "state",
        "opened_at",
        "closed_at",
        "close_reason",
        "occurrences",
        "deployment_id",
        "revision_id",
        "kind",
        "detail"
      ],
      "type": "object"
    }
  ]
}
