openapi: 3.0.1
info:
  title: Incidents service
  contact:
    name: Cobrick
    url: https://cobrick.com
    email: aiops@cobrick.com
  license:
    name: Commercial
    url: https://cobrick.com
  version: v1
servers:
  - url: https://app.observe.digital/api/v1
    description: Production environment
  - url: https://stage.observe.digital/api/v1
    description: Staging environment
  - url: http://localhost:8080
    description: Local environment
paths:
  /incidents:
    get:
      tags:
        - CRUD
      summary: Get anomalies and incidents
      operationId: getPage
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: startTimestamp
          in: query
          description: Start time in epoch seconds
          schema:
            type: integer
            format: int64
        - name: endTimestamp
          in: query
          description: End time in epoch seconds
          schema:
            type: integer
            format: int64
        - name: type
          in: query
          description: Type filter
          schema:
            type: array
            items:
              $ref: '#/components/schemas/IncidentType'
        - name: status
          in: query
          description: Status filter
          schema:
            type: array
            items:
              $ref: '#/components/schemas/IncidentStatus'
        - name: resolution
          in: query
          description: Resolution filter
          schema:
            type: string
        - name: category
          in: query
          description: Category filter
          schema:
            type: array
            items:
              $ref: '#/components/schemas/IncidentCategory'
        - name: service
          in: query
          description: Service filter
          schema:
            type: array
            items:
              type: string
        - name: namespace
          in: query
          description: Namespace filter
          schema:
            type: array
            items:
              type: string
        - name: metric
          in: query
          description: Metric filter
          schema:
            type: array
            items:
              type: string
        - name: source
          in: query
          description: Source filter
          schema:
            type: array
            items:
              type: string
        - name: acknowledged
          in: query
          description: Acknowledged filter
          schema:
            type: boolean
        - name: cursor
          in: query
          description: Paging cursor
          schema:
            type: string
        - name: direction
          in: query
          description: Paging direction
          schema:
            $ref: '#/components/schemas/PagingCommand.Direction'
        - name: pageSize
          in: query
          description: Page size
          schema:
            maximum: 100
            minimum: 1
            type: integer
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned page of incidents
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page_Object_'
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
    post:
      tags:
        - CRUD
      summary: Create or update an incident
      operationId: createOrUpdate
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      requestBody:
        description: JSON representation of the incident
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Incident'
        required: true
      responses:
        '200':
          description: Successfully created or updated an incident
          content:
            text/plain:
              schema:
                description: An id of the incident
              examples:
                example:
                  value: '1'
        '208':
          description: Trying to close an already closed incident
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '400':
          description: Incorrect payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/count:
    get:
      tags:
        - Statistics
      summary: >-
        Get the number of incidents grouped by type in buckets in the time
        frame.

        When status filter is set to RESOLVED it will count only resolved
        incidents at the given time range,

        otherwise counts OPEN incidents in the given time range
      operationId: bucketedCountByTypeInTime
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: timestampFrom
          in: query
          description: Timestamp from in epoch seconds
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: timestampTo
          in: query
          description: Timestamp to in epoch seconds
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: type
          in: query
          description: Type filter
          schema:
            $ref: '#/components/schemas/IncidentType'
        - name: status
          in: query
          description: Status filter
          schema:
            $ref: '#/components/schemas/IncidentStatus'
        - name: resolution
          in: query
          description: Resolution filter
          schema:
            type: string
        - name: buckets
          in: query
          description: Number of buckets to returns
          schema:
            minimum: 1
            type: integer
            format: int32
            default: 1
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned buckets with incidents counts
          content:
            application/json:
              schema:
                minItems: 0
                type: array
                items:
                  $ref: '#/components/schemas/GrouppedIncidentsCountBucket'
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/countCurrent:
    get:
      tags:
        - Statistics
      summary: Get the number of current incidents
      operationId: count
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: status
          in: query
          description: Status filter
          required: true
          schema:
            $ref: '#/components/schemas/IncidentStatus'
        - name: type
          in: query
          description: Type filter
          schema:
            $ref: '#/components/schemas/IncidentType'
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned counts
          content:
            text/plain: {}
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/countCurrentByPriority:
    get:
      tags:
        - Statistics
      summary: Get the number of current incidents split by priority
      operationId: countPriorities
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: status
          in: query
          description: Status filter
          required: true
          schema:
            $ref: '#/components/schemas/IncidentStatus'
        - name: type
          in: query
          description: Type filter
          schema:
            $ref: '#/components/schemas/IncidentType'
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned counts
          content:
            application/json: {}
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/countOpened:
    get:
      tags:
        - Statistics
      summary: >-
        Get the number of opened incidents grouped by severity in buckets in the
        time frame.
      operationId: bucketedCountOpenedBySeverityInTime
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: timestampFrom
          in: query
          description: Timestamp from in epoch seconds
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: timestampTo
          in: query
          description: Timestamp to in epoch seconds
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: buckets
          in: query
          description: Number of buckets to return
          schema:
            minimum: 1
            type: integer
            format: int32
            default: 1
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned buckets with incidents counts
          content:
            application/json:
              schema:
                minItems: 0
                type: array
                items:
                  $ref: '#/components/schemas/GrouppedIncidentsCountBucket'
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/facets:
    get:
      tags:
        - CRUD
      summary: Get anomalies and incidents with facets
      operationId: getFacetedPage
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: startTimestamp
          in: query
          description: Start time in epoch seconds
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: endTimestamp
          in: query
          description: End time in epoch seconds
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: type
          in: query
          description: Type filter
          schema:
            type: array
            items:
              $ref: '#/components/schemas/IncidentType'
        - name: status
          in: query
          description: Status filter
          schema:
            type: array
            items:
              $ref: '#/components/schemas/IncidentStatus'
        - name: resolution
          in: query
          description: Resolution filter
          schema:
            type: string
        - name: category
          in: query
          description: Category filter
          schema:
            type: array
            items:
              $ref: '#/components/schemas/IncidentCategory'
        - name: service
          in: query
          description: Service filter
          schema:
            type: array
            items:
              type: string
        - name: namespace
          in: query
          description: Namespace filter
          schema:
            type: array
            items:
              type: string
        - name: metric
          in: query
          description: Metric filter
          schema:
            type: array
            items:
              type: string
        - name: source
          in: query
          description: Source filter
          schema:
            type: array
            items:
              type: string
        - name: acknowledged
          in: query
          description: Acknowledged filter
          schema:
            type: boolean
        - name: cursor
          in: query
          description: Paging cursor
          schema:
            type: string
        - name: direction
          in: query
          description: Paging direction
          schema:
            $ref: '#/components/schemas/PagingCommand.Direction'
        - name: limit
          in: query
          description: Maximum page size
          schema:
            maximum: 100
            minimum: 1
            type: integer
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned incidents
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FacetedIncidents'
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/notes/{noteId}:
    get:
      tags:
        - Notes
      summary: Get incident note
      operationId: getNoteById
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: noteId
          in: path
          description: Note id
          required: true
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned incident note
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IncidentNote'
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '404':
          description: Note with given id does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
    put:
      tags:
        - Notes
      summary: Update note
      operationId: updateNote
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: noteId
          in: path
          description: Note id
          required: true
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      requestBody:
        description: JSON representation of the incident note
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IncidentNote'
        required: true
      responses:
        '204':
          description: Successfully updated incident note
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpStatus'
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '404':
          description: Note with given id does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
    delete:
      tags:
        - Notes
      summary: Delete note
      operationId: deleteNote
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: noteId
          in: path
          description: Note id
          required: true
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '204':
          description: Successfully deleted incidents note
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HttpStatus'
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '404':
          description: Note with given id does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/reports:
    get:
      tags:
        - Scan reports
      summary: Get scan report from a 3rd party tool
      operationId: getScanReport
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: source
          in: query
          required: true
          schema:
            maxLength: 255
            minLength: 1
            type: string
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned scan report
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScanReport'
        '400':
          description: Invalid source parameter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '404':
          description: Scan report not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
    post:
      tags:
        - Scan reports
      summary: Store a scan report from a 3rd party tool
      operationId: storeScanReport
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      requestBody:
        description: JSON representation of the report
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScanReport'
        required: true
      responses:
        '201':
          description: Successfully stored the report
        '400':
          description: Incorrect payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/reports/score:
    get:
      tags:
        - Scan reports
      summary: Get cluster score as reported by the scanners
      operationId: getClusterScore
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned cluster score
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClusterScore'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '404':
          description: Cluster score not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/types:
    get:
      tags:
        - Metadata
      summary: Get incident types
      operationId: getTypes
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned incident types
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IncidentType'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/{id}:
    get:
      tags:
        - CRUD
      summary: Get anomaly or incident
      operationId: getById
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: id
          in: path
          required: true
          schema:
            type: integer
            format: int64
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned incident
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Incident'
        '400':
          description: Invalid id value
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '404':
          description: Incident not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
    patch:
      tags:
        - CRUD
      summary: Partially update an incident
      operationId: update
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: id
          in: path
          required: true
          schema:
            type: integer
            format: int64
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      requestBody:
        description: JSON representation of the incident
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IncidentPatch'
        required: true
      responses:
        '200':
          description: Successfully updated an incident
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Incident'
        '208':
          description: Trying to close an already closed incident
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '400':
          description: Incorrect payload
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/{id}/acknowledge:
    post:
      tags:
        - Operations
      summary: Acknowledge an incident
      operationId: acknowledge
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: User-ID
          in: header
          description: Current user identifier
          schema:
            type: string
        - name: id
          in: path
          required: true
          schema:
            type: integer
            format: int64
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '204':
          description: Successfully acknowledged an incident
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '404':
          description: Incident not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '409':
          description: Incident already acknowledged
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/{incidentId}/notes:
    get:
      tags:
        - Notes
      summary: Get incident notes
      operationId: getNotesForIncident
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: incidentId
          in: path
          description: Incident id
          required: true
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned incidents notes
          content:
            application/json:
              schema:
                minItems: 0
                type: array
                items:
                  $ref: '#/components/schemas/IncidentNote'
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '404':
          description: Incident with given id does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
    post:
      tags:
        - Notes
      summary: Create note for incident
      operationId: createNote
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: incidentId
          in: path
          description: Incident id
          required: true
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      requestBody:
        description: JSON representation of the incident note
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IncidentNote'
        required: true
      responses:
        '200':
          description: Successfully created note
          content:
            text/plain:
              schema:
                minimum: 0
                type: integer
                description: An id of the note
                format: int64
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '404':
          description: Incident with given id does not exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/{type}/count:
    get:
      tags:
        - Statistics
      summary: Get the number of incidents in the time frame
      operationId: countStatusesInTime
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: timestampFrom
          in: query
          description: Start timestamp in epoch seconds
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: timestampTo
          in: query
          description: End timestamp in epoch seconds
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: type
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/IncidentType'
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned incidents number
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                example:
                  OPEN: 12
                  RESOLVED: 5
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /incidents/{type}/top:
    get:
      tags:
        - Statistics
      summary: Get services with the most number of incidents
      operationId: getTopServices
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: startTimestampFrom
          in: query
          description: Start time from timestamp in epoch seconds
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: startTimestampTo
          in: query
          description: Start time to timestamp in epoch seconds
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: type
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/IncidentType'
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned top services
          content:
            application/json:
              schema:
                minItems: 0
                type: array
                items:
                  $ref: '#/components/schemas/ServiceWithCounter'
        '400':
          description: One of the query parameters is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '401':
          description: Authorization information is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
components:
  schemas:
    AbstractResource_JsonError_:
      type: object
      properties:
        _links:
          type: object
          additionalProperties: true
        _embedded:
          type: object
          additionalProperties:
            type: array
            items:
              $ref: '#/components/schemas/Resource'
    Charset:
      type: object
      properties:
        registered:
          type: boolean
    ClusterScore:
      required:
        - grade
        - score
      type: object
      properties:
        score:
          type: integer
          format: int32
        grade:
          type: string
      description: >-
        A DTO class representing a cluster score as reported by a third party
        scanners.
    Facet:
      required:
        - id
        - name
        - values
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        values:
          type: array
          items:
            $ref: '#/components/schemas/FacetValue'
      description: A DTO class representing a facet.
    FacetValue:
      required:
        - count
        - id
        - name
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        count:
          type: integer
          format: int64
      description: A DTO class representing a facet value entry.
    FacetedIncidents:
      required:
        - data
        - facets
        - paging
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Incident'
        paging:
          $ref: '#/components/schemas/PagingResponse'
        facets:
          type: array
          description: The facets map
          items:
            $ref: '#/components/schemas/Facet'
      description: DTO class represents incidents with facets
    GrouppedIncidentsCountBucket:
      required:
        - bucket
        - count
        - groups
        - max
        - min
      type: object
      properties:
        bucket:
          type: integer
          format: int32
        min:
          type: integer
          format: int64
        max:
          type: integer
          format: int64
        count:
          type: integer
          format: int64
        groups:
          type: object
          additionalProperties:
            type: integer
            format: int32
      description: >-
        DTO class representing a bucket with incidents counts groupped by a
        field.
    HttpStatus:
      type: string
      enum:
        - CONTINUE
        - SWITCHING_PROTOCOLS
        - PROCESSING
        - EARLY_HINTS
        - OK
        - CREATED
        - ACCEPTED
        - NON_AUTHORITATIVE_INFORMATION
        - NO_CONTENT
        - RESET_CONTENT
        - PARTIAL_CONTENT
        - MULTI_STATUS
        - ALREADY_IMPORTED
        - IM_USED
        - MULTIPLE_CHOICES
        - MOVED_PERMANENTLY
        - FOUND
        - SEE_OTHER
        - NOT_MODIFIED
        - USE_PROXY
        - SWITCH_PROXY
        - TEMPORARY_REDIRECT
        - PERMANENT_REDIRECT
        - BAD_REQUEST
        - UNAUTHORIZED
        - PAYMENT_REQUIRED
        - FORBIDDEN
        - NOT_FOUND
        - METHOD_NOT_ALLOWED
        - NOT_ACCEPTABLE
        - PROXY_AUTHENTICATION_REQUIRED
        - REQUEST_TIMEOUT
        - CONFLICT
        - GONE
        - LENGTH_REQUIRED
        - PRECONDITION_FAILED
        - REQUEST_ENTITY_TOO_LARGE
        - REQUEST_URI_TOO_LONG
        - UNSUPPORTED_MEDIA_TYPE
        - REQUESTED_RANGE_NOT_SATISFIABLE
        - EXPECTATION_FAILED
        - I_AM_A_TEAPOT
        - ENHANCE_YOUR_CALM
        - MISDIRECTED_REQUEST
        - UNPROCESSABLE_ENTITY
        - LOCKED
        - FAILED_DEPENDENCY
        - TOO_EARLY
        - UPGRADE_REQUIRED
        - PRECONDITION_REQUIRED
        - TOO_MANY_REQUESTS
        - REQUEST_HEADER_FIELDS_TOO_LARGE
        - NO_RESPONSE
        - BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS
        - UNAVAILABLE_FOR_LEGAL_REASONS
        - REQUEST_HEADER_TOO_LARGE
        - INTERNAL_SERVER_ERROR
        - NOT_IMPLEMENTED
        - BAD_GATEWAY
        - SERVICE_UNAVAILABLE
        - GATEWAY_TIMEOUT
        - HTTP_VERSION_NOT_SUPPORTED
        - VARIANT_ALSO_NEGOTIATES
        - INSUFFICIENT_STORAGE
        - LOOP_DETECTED
        - BANDWIDTH_LIMIT_EXCEEDED
        - NOT_EXTENDED
        - NETWORK_AUTHENTICATION_REQUIRED
        - CONNECTION_TIMED_OUT
    Incident:
      required:
        - category
        - description
        - incidentId
        - metadata
        - metricNames
        - priority
        - recommendation
        - resolution
        - services
        - severity
        - source
        - sourceSite
        - status
        - title
        - type
      type: object
      properties:
        id:
          type: integer
          format: int64
          readOnly: true
        type:
          $ref: '#/components/schemas/IncidentType'
        incidentId:
          maxLength: 16
          type: string
        title:
          maxLength: 255
          type: string
        category:
          $ref: '#/components/schemas/IncidentCategory'
        description:
          maxLength: 2000
          type: string
        recommendation:
          maxLength: 2000
          type: string
        source:
          maxLength: 255
          type: string
        status:
          $ref: '#/components/schemas/IncidentStatus'
        resolution:
          maxLength: 20
          type: string
        services:
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/Incident.Service'
        metricNames:
          type: array
          items:
            type: string
        startTime:
          type: string
          description: Either an ISO 8601 or second timestamp format
          format: date-time
        endTime:
          type: string
          description: Either an ISO 8601 or second timestamp format
          format: date-time
        sourceSite:
          maxLength: 50
          type: string
        severity:
          maxLength: 10
          type: string
        priority:
          maxLength: 10
          type: string
        metadata:
          type: object
          additionalProperties: true
        ackTime:
          type: string
          format: date-time
          readOnly: true
        ackUserId:
          maxLength: 50
          type: string
          readOnly: true
        ackUserEmail:
          maxLength: 320
          type: string
          readOnly: true
      description: >-
        A model class representing domain data from a row in a `incidents`
        database table.
    Incident.Service:
      required:
        - name
        - namespace
      type: object
      properties:
        namespace:
          maxLength: 255
          minLength: 1
          type: string
        name:
          maxLength: 255
          minLength: 1
          type: string
    IncidentCategory:
      type: string
      enum:
        - PERFORMANCE
        - RELIABILITY
        - SECURITY
        - CONFIGURATION
    IncidentNote:
      required:
        - body
      type: object
      properties:
        id:
          type: integer
          format: int64
          readOnly: true
        incidentId:
          type: integer
          format: int64
          readOnly: true
        body:
          minLength: 1
          type: string
        createdAt:
          type: string
          format: date-time
          readOnly: true
      description: >-
        A model class representing domain data from a row in a `notes` database
        table.
    IncidentPatch:
      required:
        - description
        - priority
        - recommendation
        - resolution
        - severity
        - status
        - title
      type: object
      properties:
        title:
          maxLength: 255
          type: string
        description:
          maxLength: 2000
          type: string
        recommendation:
          maxLength: 2000
          type: string
        status:
          $ref: '#/components/schemas/IncidentStatus'
        resolution:
          maxLength: 20
          type: string
        severity:
          maxLength: 10
          type: string
        priority:
          maxLength: 10
          type: string
      description: A DTO class representing incident patch payload.
    IncidentStatus:
      type: string
      enum:
        - OPEN
        - RESOLVED
    IncidentType:
      type: string
      enum:
        - INCIDENT
        - ANOMALY
        - ALERT
    JsonError:
      type: object
      allOf:
        - $ref: '#/components/schemas/AbstractResource_JsonError_'
        - required:
            - message
          properties:
            _links:
              type: object
              additionalProperties: true
            _embedded:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: '#/components/schemas/Resource'
            message:
              type: string
            logref:
              type: string
              nullable: true
            path:
              type: string
              nullable: true
    MediaType:
      required:
        - name
      type: object
      properties:
        name:
          type: string
        type:
          type: string
        subtype:
          type: string
        extension:
          type: string
        parameters:
          $ref: '#/components/schemas/OptionalValues_String_'
        quality:
          type: string
        qualityAsNumber:
          type: number
        version:
          type: string
        charset:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/Charset'
        textBased:
          type: boolean
    OptionalMultiValues_Link_:
      $ref: '#/components/schemas/OptionalValues_List_Link__'
    OptionalMultiValues_Resource_:
      $ref: '#/components/schemas/OptionalValues_List_Resource__'
    OptionalValues_List_Link__:
      type: object
      properties:
        empty:
          type: boolean
    OptionalValues_List_Resource__:
      type: object
      properties:
        empty:
          type: boolean
    OptionalValues_String_:
      type: object
      properties:
        empty:
          type: boolean
    Page_Object_:
      required:
        - data
        - paging
      type: object
      properties:
        data:
          type: array
          items:
            type: object
        paging:
          $ref: '#/components/schemas/PagingResponse'
      description: DTO class representing a page of data with paging information.
    PagingCommand.Direction:
      type: string
      enum:
        - NEXT
        - PREVIOUS
    PagingCursor:
      required:
        - firstId
        - lastId
      type: object
      properties:
        firstId:
          type: integer
          format: int64
        lastId:
          type: integer
          format: int64
      description: DTO class representing paging cursor
    PagingResponse:
      required:
        - cursor
        - hasNext
        - hasPrevious
      type: object
      properties:
        cursor:
          $ref: '#/components/schemas/PagingCursor'
        hasNext:
          type: boolean
        hasPrevious:
          type: boolean
      description: DTO class representing paging information for the response
    Resource:
      type: object
      properties:
        _links:
          $ref: '#/components/schemas/OptionalMultiValues_Link_'
        _embedded:
          $ref: '#/components/schemas/OptionalMultiValues_Resource_'
    ScanReport:
      required:
        - createdAt
        - payload
        - source
      type: object
      properties:
        source:
          maxLength: 255
          minLength: 1
          type: string
        createdAt:
          type: string
          format: date-time
        payload:
          type: string
      description: A model class representing a scan report.
    ServiceWithCounter:
      required:
        - counter
        - name
        - namespace
      type: object
      properties:
        namespace:
          type: string
        name:
          type: string
        counter:
          type: integer
          format: int32
      description: >-
        A DTO class representing a service with some counter (e.g. a number of
        incidents).
