openapi: 3.0.1
info:
  title: StoneRed.StatusExposed.Api
  version: "1.0"
servers:
  - url: https://api.status.exposed
paths:
  /{serviceTypeSlug}/{address}/{port}/feed.rss:
    get:
      tags:
        - Services
      description: Get service RSS feed by domain
      parameters:
        - name: serviceTypeSlug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/ServiceTypeSlug"
        - name: address
          in: path
          required: true
          schema:
            type: string
        - name: port
          in: path
          required: true
          schema:
            type: integer
            format: int32
      responses:
        "200":
          description: OK
        "400":
          description: Bad Request
          content:
            application/rss+xml:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "404":
          description: Not Found
          content:
            application/rss+xml:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
  /{serviceTypeSlug}/{address}/{port}/feed.atom:
    get:
      tags:
        - Services
      description: Get service RSS feed by domain
      parameters:
        - name: serviceTypeSlug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/ServiceTypeSlug"
        - name: address
          in: path
          required: true
          schema:
            type: string
        - name: port
          in: path
          required: true
          schema:
            type: integer
            format: int32
      responses:
        "200":
          description: OK
        "400":
          description: Bad Request
          content:
            application/rss+xml:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "404":
          description: Not Found
          content:
            application/rss+xml:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
  /{serviceTypeSlug}/{address}/{port}:
    get:
      tags:
        - Services
      description: Get general service information
      parameters:
        - name: serviceTypeSlug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/ServiceTypeSlug"
        - name: address
          in: path
          required: true
          schema:
            type: string
        - name: port
          in: path
          required: true
          schema:
            type: integer
            format: int32
        - name: statusHistoryLimit
          in: query
          schema:
            type: integer
            format: int32
            default: 1
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IServiceData"
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "404":
          description: Not Found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
  /{serviceTypeSlug}/{address}/{port}/statuses:
    get:
      tags:
        - Services
      description: Get 100 most recent service statuses
      parameters:
        - name: serviceTypeSlug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/ServiceTypeSlug"
        - name: address
          in: path
          required: true
          schema:
            type: string
        - name: port
          in: path
          required: true
          schema:
            type: integer
            format: int32
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/IServiceStatusData"
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "404":
          description: Not Found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
  /{serviceTypeSlug}/{address}/{port}/statuses/current:
    get:
      tags:
        - Services
      description: Get current service status
      parameters:
        - name: serviceTypeSlug
          in: path
          required: true
          schema:
            $ref: "#/components/schemas/ServiceTypeSlug"
        - name: address
          in: path
          required: true
          schema:
            type: string
        - name: port
          in: path
          required: true
          schema:
            type: integer
            format: int32
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IServiceStatusData"
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
        "404":
          description: Not Found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProblemDetails"
components:
  schemas:
    IServiceData:
      type: object
      properties:
        address:
          type: string
          nullable: true
        port:
          type: integer
          format: int32
        statusPageUrl:
          type: string
          nullable: true
        createdAt:
          type: string
          format: date-time
        subscriberCount:
          type: integer
          format: int64
        degradedThreshold:
          type: integer
          format: int32
        updateInterval:
          type: string
          format: date-span
        nextUpdate:
          type: string
          format: date-time
        hasBeenClaimed:
          type: boolean
          readOnly: true
        statusHistory:
          type: array
          items:
            $ref: "#/components/schemas/IServiceStatusData"
          nullable: true
          readOnly: true
        serviceType:
          $ref: "#/components/schemas/ServiceType"
        currentStatus:
          $ref: "#/components/schemas/IServiceStatusData"
      additionalProperties: false
    IServiceStatusData:
      type: object
      properties:
        id:
          type: string
          format: uuid
        createdAt:
          type: string
          format: date-time
        status:
          $ref: "#/components/schemas/ServiceStatus"
        ping:
          type: integer
          format: int32
        extraData:
          type: string
          nullable: true
          readOnly: true
      additionalProperties: false
    ProblemDetails:
      type: object
      properties:
        type:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        status:
          type: integer
          format: int32
          nullable: true
        detail:
          type: string
          nullable: true
        instance:
          type: string
          nullable: true
      additionalProperties: {}
    ServiceStatus:
      enum:
        - UNKNOWN
        - UP
        - DOWN
        - DEGRADED
        - PARTIALLY_DOWN
        - PARTIALLY_DEGRADED
      type: string
    ServiceType:
      enum:
        - WEBSITE
        - MINECRAFT_SERVER
        - WEB_SOCKET_SERVER
        - TCP_SERVER
        - SOURCE_SERVER
      type: string
    ServiceTypeSlug:
      enum:
        - WEBSITE
        - WEBSOCKET
        - TCP
        - UDP
        - MINECRAFT
        - SOURCE
      type: string
