openapi: 3.0.1
info:
  title: Logs 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:
  /logs:
    get:
      tags:
        - logs
      summary: Get logs for given parameters
      description: >-
        If no parameters are set, last N logs from all the services will be
        returned.

        The N value is configurable on the server, defaults to 1000
      operationId: getLogs
      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: serviceName
          in: query
          description: Service name
          schema:
            type: string
        - name: podName
          in: query
          description: Pod name
          schema:
            type: string
        - name: logTemplateId
          in: query
          description: Log template ID
          schema:
            type: integer
            format: int64
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned logs
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LokiQueryResponse'
        '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 occured
          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
    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
    LokiEntry:
      required:
        - timestamp
        - value
      type: object
      properties:
        timestamp:
          type: integer
          format: int64
        value:
          type: string
    LokiQueryData:
      required:
        - result
        - resultType
        - stats
      type: object
      properties:
        resultType:
          type: string
        result:
          type: array
          items:
            $ref: '#/components/schemas/LokiQueryEntry'
        stats:
          type: object
      description: >-
        DTO class for representing data which is returned by Loki. It is wrapped
        by LokiQueryResponse
    LokiQueryEntry:
      required:
        - stream
        - values
      type: object
      properties:
        stream:
          type: object
        values:
          type: array
          items:
            $ref: '#/components/schemas/LokiEntry'
      description: >-
        DTO class Represents single entry value returned from Loki. Entry = log
        Stream represents json object which contains labels Values are json
        fields which contains the values of the log (timestamps \& messages)
    LokiQueryResponse:
      required:
        - data
        - status
      type: object
      properties:
        status:
          type: string
        data:
          $ref: '#/components/schemas/LokiQueryData'
      description: DTO class which represents Loki response.
    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
    Resource:
      type: object
      properties:
        _links:
          $ref: '#/components/schemas/OptionalMultiValues_Link_'
        _embedded:
          $ref: '#/components/schemas/OptionalMultiValues_Resource_'
