openapi: 3.0.1
info:
  title: Drain 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:
  /drain/push:
    post:
      tags:
        - push
      summary: Push new events to drain
      operationId: pushEvents
      parameters:
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
        - name: Content-Encoding
          in: header
          description: >-
            Content encoding: 'snappy' or empty for Promtail payload, 'cobrick'
            for DRAIN-based compressed payload
          schema:
            type: string
      requestBody:
        description: Binary representation of the events to be pushed
        content:
          application/x-protobuf:
            schema:
              oneOf:
                - type: string
                  format: byte
                - type: string
                  format: byte
            example: null
        required: true
      responses:
        '200':
          description: Successfully pushed the events
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                  - type: object
              example: null
        '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'
        '422':
          description: Payload is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '429':
          description: Loki pushed back
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /drain/regexes:
    get:
      tags:
        - regex
      summary: Get the preparser regular expressions list
      operationId: getPreparserRegexes
      parameters:
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
      responses:
        '200':
          description: Successfully returned regular expressions
          content:
            application/json:
              schema:
                oneOf:
                  - type: array
                    items:
                      $ref: '#/components/schemas/RegexEntry'
                  - type: array
                    items:
                      $ref: '#/components/schemas/RegexEntry'
              example: null
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
  /drain/services/{serviceName}/templates/merge:
    post:
      tags:
        - merge
      summary: Store and merge log templates
      operationId: mergeLogTemplates
      parameters:
        - name: serviceName
          in: path
          description: Service name
          required: true
          schema:
            oneOf:
              - type: string
              - type: string
        - name: Api-Version
          in: header
          description: API version
          schema:
            type: string
        - name: containerName
          in: query
          description: Container name
          schema:
            oneOf:
              - type: string
              - type: string
      requestBody:
        description: A JSON array with the log templates to be stored
        content:
          application/json:
            schema:
              oneOf:
                - type: array
                  items:
                    $ref: '#/components/schemas/LogTemplateDTO'
                - type: array
                  items:
                    $ref: '#/components/schemas/LogTemplateDTO'
            example: null
        required: true
      responses:
        '200':
          description: Successfully returned the merged log templates
          content:
            application/json:
              schema:
                oneOf:
                  - type: array
                    items:
                      $ref: '#/components/schemas/LogTemplateDTO'
                  - type: array
                    items:
                      $ref: '#/components/schemas/LogTemplateDTO'
              example: null
        '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: The merge endpoint is not available for given scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '408':
          description: The server didn't calculate the response on time
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonError'
        '429':
          description: Too many concurrent requests to the endpoint
          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
    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
    LogTemplateDTO:
      required:
        - container
        - hitCounter
        - identifier
        - name
        - namespace
        - service
        - tokens
      type: object
      properties:
        tokens:
          type: array
          items:
            type: string
        identifier:
          type: integer
          format: int64
        name:
          type: string
        hitCounter:
          type: integer
          format: int64
        container:
          type: string
        service:
          type: string
        namespace:
          type: string
      description: >-
        Class which represents LogTemplate. It is used for synchronization with
        topology service.
    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
    RegexEntry:
      required:
        - name
        - value
      type: object
      properties:
        name:
          type: string
        value:
          type: string
    Resource:
      type: object
      properties:
        _links:
          $ref: '#/components/schemas/OptionalMultiValues_Link_'
        _embedded:
          $ref: '#/components/schemas/OptionalMultiValues_Resource_'
