{
  "openapi": "3.0.3",
  "info": {
    "title": "Vamper U-space service status",
    "version": "1.0.0",
    "description": "The status of each Vamper U-space service (2021/664 AMC4, GM5 Art. 7(2)), served by service-status without authentication, for UAS operators, other USSPs and ATS units. service-status sets it from its monitoring of every service (each service's measurements read every 5 s; a level that holds 15 s changes the status; what a service needs, the database, its sources, the DSS, the notifications service, makes it unavailable while not there) and Vamper staff set it by hand. Every change is pushed to each subscription (/status/v1/subscriptions; body a StatusPush), apart from ussp's notices. ussp sets its F3548-21 DSS USS availability from it: Down while flight authorisation is unavailable, and while the statuses cannot be read as current."
  },
  "servers": [
    {
      "url": "https://service-status.uspace.vamper.ee"
    }
  ],
  "security": [],
  "paths": {
    "/status/v1/services": {
      "get": {
        "operationId": "getServiceStatus",
        "summary": "Every service's current status and the planned changes",
        "responses": {
          "200": {
            "description": "Status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Report"
                }
              }
            }
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/status/v1/subscriptions": {
      "post": {
        "operationId": "subscribe",
        "summary": "Have every status change pushed to a URL (scope uspace.operator, uspace.atc, uspace.atsp or uspace.staff)",
        "description": "An operator, ATC unit or ATSP subscribes itself (the token's subject is the owner); staff name the owner, such as another USSP, which holds no token of ours. One per owner: a new one replaces the one it had, and the pushes still due to it. Each change is a POST of a StatusPush with X-Signature-Timestamp, Unix seconds when the attempt was made, and X-Signature-SHA256, hex HMAC-SHA256 with this secret of \"<timestamp>.<body>\"; any 2xx is delivery, no acknowledgement. A push that fails, or is redirected, is retried for 10 min with backoff up to 30 s, signed anew each time and with the same id, so drop an id already had. Each subscription receives the changes in the order announced. URLs must be https and reach a public address. Each subscription and deletion is logged, without the secret.",
        "security": [
          {
            "bearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Subscribed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subscription"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "operationId": "listSubscriptions",
        "summary": "The caller's subscriptions; staff: every one (scope uspace.operator, uspace.atc, uspace.atsp or uspace.staff)",
        "security": [
          {
            "bearer": []
          }
        ],
        "responses": {
          "200": {
            "description": "Oldest first, without their secrets",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubscriptionList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/status/v1/subscriptions/{uuid}": {
      "delete": {
        "operationId": "unsubscribe",
        "summary": "Delete one of the caller's subscriptions and the pushes still due to it; staff: any (scope uspace.operator, uspace.atc, uspace.atsp or uspace.staff)",
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "description": "No subscription of the caller's with this uuid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "RS256 JWT from Vamper's token issuer, aud = service-status's host; each operation names the scopes it takes. 401: missing or invalid token; 403: scope missing, or no subject."
      }
    },
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "SubscriptionRequest": {
        "type": "object",
        "required": [
          "url",
          "secret"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "https, a public address, at most 2048 characters, without user info, query or fragment: the secret authenticates each push"
          },
          "secret": {
            "type": "string",
            "minLength": 16,
            "maxLength": 256,
            "description": "Signs each push; never shown again"
          },
          "owner": {
            "type": "string",
            "maxLength": 256,
            "description": "Staff only, and required of them: whom they subscribe"
          }
        }
      },
      "Subscription": {
        "type": "object",
        "required": [
          "uuid",
          "owner",
          "url",
          "created_at"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid"
          },
          "owner": {
            "type": "string",
            "description": "The subscriber's token subject, or whom staff subscribed"
          },
          "url": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SubscriptionList": {
        "type": "object",
        "required": [
          "subscriptions"
        ],
        "properties": {
          "subscriptions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Subscription"
            }
          }
        }
      },
      "StatusPush": {
        "type": "object",
        "description": "The body of each push: a ServiceStatus with the push's id, the same in every attempt.",
        "required": [
          "id",
          "service",
          "state",
          "since",
          "manual"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "service": {
            "type": "string",
            "enum": [
              "network_identification",
              "flight_authorisation",
              "conformance_monitoring",
              "traffic_information",
              "geo_awareness"
            ]
          },
          "uspace_service": {
            "type": "string",
            "enum": [
              "network_identification",
              "flight_authorisation",
              "geo_awareness",
              "traffic_information",
              "conformance_monitoring"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "normal",
              "degraded",
              "unavailable"
            ]
          },
          "reason": {
            "type": "string"
          },
          "since": {
            "type": "string",
            "format": "date-time"
          },
          "expected_end": {
            "type": "string",
            "format": "date-time"
          },
          "manual": {
            "type": "boolean"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "message"
        ],
        "properties": {
          "message": {
            "type": "string"
          }
        }
      },
      "Report": {
        "type": "object",
        "required": [
          "as_of",
          "services",
          "planned"
        ],
        "properties": {
          "as_of": {
            "type": "string",
            "format": "date-time",
            "description": "When the statuses were last evaluated. Served only while at most 10 s ago and no status change has waited more than 10 s to be pushed to its subscribers; otherwise 503: the statuses are not current."
          },
          "services": {
            "type": "array",
            "description": "Every service whose status is set, by monitoring or by hand, from its first evaluation; one not yet evaluated is absent, never shown normal.",
            "items": {
              "$ref": "#/components/schemas/ServiceStatus"
            }
          },
          "planned": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlannedStatus"
            }
          }
        }
      },
      "ServiceStatus": {
        "type": "object",
        "description": "One of our services as announced.",
        "required": [
          "service",
          "state",
          "since",
          "manual"
        ],
        "properties": {
          "service": {
            "type": "string",
            "enum": [
              "network_identification",
              "flight_authorisation",
              "conformance_monitoring",
              "traffic_information",
              "geo_awareness"
            ]
          },
          "uspace_service": {
            "type": "string",
            "enum": [
              "network_identification",
              "flight_authorisation",
              "geo_awareness",
              "traffic_information",
              "conformance_monitoring"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "normal",
              "degraded",
              "unavailable"
            ],
            "description": "degraded: provided, not to its specification; unavailable: not provided"
          },
          "reason": {
            "type": "string",
            "description": "Causes, '; '-separated; absent when normal"
          },
          "since": {
            "type": "string",
            "format": "date-time",
            "description": "When the status began; for a detected change, the last observation before it, so no later than the onset"
          },
          "expected_end": {
            "type": "string",
            "format": "date-time",
            "description": "Only when every cause has an expected end"
          },
          "manual": {
            "type": "boolean",
            "description": "Vamper staff set a cause by hand"
          }
        }
      },
      "PlannedStatus": {
        "type": "object",
        "description": "A status Vamper staff set to begin later, such as planned maintenance; it holds from from until cleared, expected to end at until.",
        "required": [
          "id",
          "service",
          "state",
          "reason",
          "from"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "service": {
            "type": "string",
            "enum": [
              "network_identification",
              "flight_authorisation",
              "conformance_monitoring",
              "traffic_information",
              "geo_awareness"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "normal",
              "degraded",
              "unavailable"
            ],
            "description": "degraded or unavailable: a manual state is never normal"
          },
          "reason": {
            "type": "string"
          },
          "from": {
            "type": "string",
            "format": "date-time"
          },
          "until": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}
