openapi: 3.0.1
info:
  title: Events service
  contact:
    name: co.brick
    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:
  /events:
    get:
      tags:
        - events
      summary: Get events for given parameters with facets
      operationId: getEvents
      parameters:
        - name: X-Scope-OrgID
          in: header
          description: Scope header
          schema:
            type: string
        - name: startTimestamp
          in: query
          description: From timestamp in seconds
          required: true
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: endTimestamp
          in: query
          description: To timestamp in seconds
          required: true
          schema:
            minimum: 0
            type: integer
            format: int64
        - name: namespace
          in: query
          description: Namespaces
          schema:
            type: array
            items:
              type: string
        - name: serviceName
          in: query
          description: Service names
          schema:
            type: array
            items:
              type: string
        - name: title
          in: query
          description: Titles
          schema:
            type: array
            items:
              type: string
        - name: eventType
          in: query
          description: Event types
          schema:
            type: array
            items:
              type: string
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned events
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FacetedEvents'
        '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'
        '502':
          description: Upstream service returned invalid response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '504':
          description: Upstream service read timeout occurred
          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
    Event:
      required:
        - details
        - eventType
        - namespace
        - service
        - startTime
        - title
      type: object
      properties:
        eventType:
          $ref: '#/components/schemas/NamedValue'
        title:
          $ref: '#/components/schemas/NamedValue'
        startTime:
          type: integer
          format: int64
        namespace:
          type: string
        service:
          type: string
        details:
          type: string
      description: A DTO class representing an event.
    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.
    FacetedEvents:
      required:
        - data
        - facets
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Event'
        facets:
          type: array
          items:
            $ref: '#/components/schemas/Facet'
      description: DTO class represents events with facets.
    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
    NamedValue:
      required:
        - id
        - name
      type: object
      properties:
        id:
          type: string
        name:
          type: string
      description: A DTO class representing a value with human-readable name.
    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
    Resource:
      type: object
      properties:
        _links:
          $ref: '#/components/schemas/OptionalMultiValues_Link_'
        _embedded:
          $ref: '#/components/schemas/OptionalMultiValues_Resource_'
