# Proposed event contract, version 1 (AsyncAPI 3.0). Status: proposal for review, not confirmed design.
asyncapi: 3.0.0
info:
  title: Status Events
  version: 1.0.0
  description: 'Incidents, component statuses and maintenances. Inside status they republish the static feed.
    Envelope and delivery guarantees: `common/v1/events.yaml`. Status: proposal for review, not confirmed design.'
defaultContentType: application/cloudevents+json
servers:
  prod:
    host: pubsub.googleapis.com
    protocol: googlepubsub
    description: Pub/Sub in the project that hosts the system, prod.
  stage:
    host: pubsub.googleapis.com
    protocol: googlepubsub
    description: Pub/Sub in the project that hosts the system, stage.
channels:
  status.events.v1:
    address: status.events.v1
    description: Every event status publishes.
    messages:
      incident_opened_v1:
        $ref: '#/components/messages/incident_opened_v1'
      incident_updated_v1:
        $ref: '#/components/messages/incident_updated_v1'
      incident_resolved_v1:
        $ref: '#/components/messages/incident_resolved_v1'
      component_status_changed_v1:
        $ref: '#/components/messages/component_status_changed_v1'
      maintenance_changed_v1:
        $ref: '#/components/messages/maintenance_changed_v1'
    bindings:
      googlepubsub:
        messageRetentionDuration: 604800s
operations:
  publish_incident_opened_v1:
    action: send
    channel:
      $ref: '#/channels/status.events.v1'
    messages:
    - $ref: '#/channels/status.events.v1/messages/incident_opened_v1'
    summary: An incident was opened, by the probes or by staff.
    x-moonitoring-producer: status
    x-moonitoring-consumers:
    - status
    x-moonitoring-webhook: false
    x-moonitoring-requirements: []
  publish_incident_updated_v1:
    action: send
    channel:
      $ref: '#/channels/status.events.v1'
    messages:
    - $ref: '#/channels/status.events.v1/messages/incident_updated_v1'
    summary: An incident got an update, or its impact or components changed.
    x-moonitoring-producer: status
    x-moonitoring-consumers:
    - status
    x-moonitoring-webhook: false
    x-moonitoring-requirements: []
  publish_incident_resolved_v1:
    action: send
    channel:
      $ref: '#/channels/status.events.v1'
    messages:
    - $ref: '#/channels/status.events.v1/messages/incident_resolved_v1'
    summary: An incident was resolved.
    x-moonitoring-producer: status
    x-moonitoring-consumers:
    - status
    x-moonitoring-webhook: false
    x-moonitoring-requirements: []
  publish_component_status_changed_v1:
    action: send
    channel:
      $ref: '#/channels/status.events.v1'
    messages:
    - $ref: '#/channels/status.events.v1/messages/component_status_changed_v1'
    summary: A component's status changed, by the probes or by staff.
    x-moonitoring-producer: status
    x-moonitoring-consumers:
    - status
    x-moonitoring-webhook: false
    x-moonitoring-requirements: []
  publish_maintenance_changed_v1:
    action: send
    channel:
      $ref: '#/channels/status.events.v1'
    messages:
    - $ref: '#/channels/status.events.v1/messages/maintenance_changed_v1'
    summary: A maintenance was scheduled, moved, started, completed or cancelled.
    x-moonitoring-producer: status
    x-moonitoring-consumers:
    - status
    x-moonitoring-webhook: false
    x-moonitoring-requirements: []
x-moonitoring-consumes:
- event: staff_membership.changed.v1, staff_role.updated.v1
  producer: access
  why: Authorizes the staff who manage incidents.
components:
  messages:
    incident_opened_v1:
      name: incident.opened.v1
      title: incident.opened.v1
      summary: An incident was opened, by the probes or by staff.
      traits:
      - $ref: ../../../common/v1/events.yaml#/components/messageTraits/Event
      payload:
        allOf:
        - $ref: ../../../common/v1/events.yaml#/components/schemas/EventEnvelope
        - type: object
          properties:
            type:
              type: string
              const: incident.opened.v1
            subject:
              type: string
              description: The incident id.
            data: &id001
              type: object
              description: What changed; consumers read the current state from status-backend.
              properties:
                version:
                  type: integer
              required:
              - version
    incident_updated_v1:
      name: incident.updated.v1
      title: incident.updated.v1
      summary: An incident got an update, or its impact or components changed.
      traits:
      - $ref: ../../../common/v1/events.yaml#/components/messageTraits/Event
      payload:
        allOf:
        - $ref: ../../../common/v1/events.yaml#/components/schemas/EventEnvelope
        - type: object
          properties:
            type:
              type: string
              const: incident.updated.v1
            subject:
              type: string
              description: The incident id.
            data: *id001
    incident_resolved_v1:
      name: incident.resolved.v1
      title: incident.resolved.v1
      summary: An incident was resolved.
      traits:
      - $ref: ../../../common/v1/events.yaml#/components/messageTraits/Event
      payload:
        allOf:
        - $ref: ../../../common/v1/events.yaml#/components/schemas/EventEnvelope
        - type: object
          properties:
            type:
              type: string
              const: incident.resolved.v1
            subject:
              type: string
              description: The incident id.
            data: *id001
    component_status_changed_v1:
      name: component_status.changed.v1
      title: component_status.changed.v1
      summary: A component's status changed, by the probes or by staff.
      traits:
      - $ref: ../../../common/v1/events.yaml#/components/messageTraits/Event
      payload:
        allOf:
        - $ref: ../../../common/v1/events.yaml#/components/schemas/EventEnvelope
        - type: object
          properties:
            type:
              type: string
              const: component_status.changed.v1
            subject:
              type: string
              description: The component id.
            data: *id001
    maintenance_changed_v1:
      name: maintenance.changed.v1
      title: maintenance.changed.v1
      summary: A maintenance was scheduled, moved, started, completed or cancelled.
      traits:
      - $ref: ../../../common/v1/events.yaml#/components/messageTraits/Event
      payload:
        allOf:
        - $ref: ../../../common/v1/events.yaml#/components/schemas/EventEnvelope
        - type: object
          properties:
            type:
              type: string
              const: maintenance.changed.v1
            subject:
              type: string
              description: The maintenance id.
            data: *id001
