# Proposed contract, version 1: endpoints, errors, paging, idempotency, security and the capability of every
# operation. Status: proposal for review, not confirmed design. Conventions: docs/05-interfaces/choosing-an-interface.md.
# Vendor extensions: x-moonitoring-audience (who calls), x-moonitoring-capability (the capability checked),
# x-moonitoring-requirements (the requirements of 1.requisiti-raffinati.txt the operation serves; none yet for status).
openapi: 3.1.0
info:
  title: Status Feed
  version: 1.0.0
  description: The data of the public status page as one static file, published by status-backend at every change and at least
    every minute, and served by status-watchdog from Cloudflare while Google Cloud is down. Not an API for other tools.
servers:
- url: https://status.moonitoring.com/api/v1
  description: Prod
security: []
tags:
- name: Feed
paths:
  /summary.json:
    get:
      summary: Read the summary
      operationId: getSummary
      description: Everything the page shows, in one file.
      tags:
      - Feed
      responses:
        '200':
          description: The result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Summary'
      x-moonitoring-audience: public
      x-moonitoring-requirements: []
components:
  schemas:
    Page:
      type: object
      properties:
        name:
          type: string
        url:
          type: string
          format: uri
        updated_at: &id004
          type: string
          format: date-time
        stale_after:
          type: string
          format: date-time
          description: After this time the page warns that the data may be out of date.
      required:
      - name
      - url
      - updated_at
      - stale_after
    Indicator:
      type: object
      properties:
        indicator:
          type: string
          enum:
          - none
          - minor
          - major
          - critical
          - maintenance
        description: &id001
          type: object
          description: The same text in every language of the page; Italian and English.
          properties:
            it:
              type: string
              maxLength: 4000
            en:
              type: string
              maxLength: 4000
          required:
          - it
          - en
      required:
      - indicator
      - description
    PublicComponent:
      type: object
      properties:
        component_id:
          type: string
        group:
          type: string
          description: Stable id of the group.
        group_name: *id001
        name: *id001
        status: &id002
          type: string
          enum:
          - operational
          - degraded_performance
          - partial_outage
          - major_outage
          - under_maintenance
          description: What a person using the component sees now.
        position:
          type: integer
        uptime_90d:
          type: number
          description: Percentage, two decimals.
        days:
          type: array
          maxItems: 90
          items:
            type: object
            properties:
              date:
                type: string
                format: date
              downtime_minutes:
                type: number
                description: Major outage minutes plus 0.3 x partial.
              worst: *id002
              incident_ids:
                type: array
                items:
                  type: string
            required:
            - date
            - downtime_minutes
      required:
      - component_id
      - group
      - group_name
      - name
      - status
      - position
    PublicIncident:
      type: object
      properties:
        incident_id:
          type: string
        title: *id001
        status: &id003
          type: string
          enum:
          - investigating
          - identified
          - monitoring
          - resolved
        impact:
          type: string
          enum:
          - none
          - minor
          - major
          - critical
          description: How bad it is for customers; drives the colour of the page's banner.
        components:
          type: array
          items:
            type: string
        updates:
          type: array
          items:
            type: object
            properties:
              status: *id003
              body: *id001
              posted_at: *id004
            required:
            - status
            - body
            - posted_at
        postmortem_url:
          type: string
          format: uri
        started_at: *id004
        resolved_at: *id004
      required:
      - incident_id
      - title
      - status
      - impact
      - components
      - updates
      - started_at
    PublicMaintenance:
      type: object
      properties:
        maintenance_id:
          type: string
        title: *id001
        body: *id001
        status:
          type: string
          enum:
          - scheduled
          - in_progress
          - verifying
          - completed
          - cancelled
        components:
          type: array
          items:
            type: string
        scheduled_for: *id004
        scheduled_until: *id004
      required:
      - maintenance_id
      - title
      - status
      - scheduled_for
      - scheduled_until
    Summary:
      type: object
      properties:
        page:
          $ref: '#/components/schemas/Page'
        status:
          $ref: '#/components/schemas/Indicator'
        components:
          type: array
          items:
            $ref: '#/components/schemas/PublicComponent'
        incidents:
          type: array
          items:
            $ref: '#/components/schemas/PublicIncident'
          description: Unresolved only.
        maintenances:
          type: array
          items:
            $ref: '#/components/schemas/PublicMaintenance'
          description: In progress, and scheduled within seven days.
      required:
      - page
      - status
      - components
      - incidents
      - maintenances
