swagger: "2.0"
info:
  description: "Logs Streaming Service for PipeDream"
  version: "1.0.0"
  title: "pipedream_logs"
  contact:
    name: "Infra"
    email: "infrateam@zoox.com"
    url: "https://git.zooxlabs.com/zooxco/driving"

basePath: "/v0"

tags:
- name: "nfs"
  description: "Retrieving logs from NFS"

paths:
  /logs:
    get:
      tags:
        - "logs"
      summary: "Retrieve logs from the provided path. Only Flashblade or PCS supported."
      operationId: "getLogsFromPath"
      produces:
        - "application/json"
      parameters:
        - name: "path"
          in: "query"
          type: "string"
          description: "The path on flashblade or PCS to the log."
          required: true
        - name: "limit"
          in: "query"
          type: "integer"
          format: "int32"
          description: "Maximum number of bytes to return."
          required: false
        - name: "offset"
          in: "query"
          type: "integer"
          format: "int32"
          description: "Offset in bytes to return. Negative offset implies seeking from the end of the file"
          required: false
      responses:
        "200":
          description: "Operation successful."
          schema:
            $ref: "#/definitions/LogBytesResponse"
        "404":
          description: "Path not found."
          schema:
            $ref: "#/definitions/ErrorResponse"

  /flashblade:
    get:
      tags:
        - "nfs"
      summary: "Retrieve logs from flashblade"
      operationId: "getLogsFromFlashblade"
      produces:
        - "application/json"
      parameters:
        - name: "path"
          in: "query"
          type: "string"
          description: "The path on flashblade to the log, may be prefixed with '/mnt/flashblade'."
          required: true
        - name: "limit"
          in: "query"
          type: "integer"
          format: "int32"
          description: "Maximum number of lines to return."
          required: false
        - name: "offset"
          in: "query"
          type: "integer"
          format: "int32"
          description: "Offset into lines to return."
          required: false
      responses:
        "200":
          description: "Operation successful."
          schema:
            $ref: "#/definitions/LogResponse"
        "404":
          description: "Path not found."
          schema:
            $ref: "#/definitions/ErrorResponse"

  /metrics:
    get:
      tags:
        - "metrics"
      summary: "logs service metrics"
      description: "return prometheus flatten metrics."
      operationId: "getMetrics"
      produces:
      - "text/plain; charset=utf-8"
      responses:
        "200":
          description: OK
          schema:
            type: string


definitions:
  LogBytesResponse:
    type: "object"
    properties:
      bytes:
        description: "The retrieved lines."
        type: "string"
      eof:
        description: "True if the file end was reached"
        type: "boolean"

  LogResponse:
    type: "object"
    properties:
      lines:
        description: "The retrieved lines."
        type: "array"
        items:
          type: "string"
      eof:
        description: "True if the file end was reached"
        type: "boolean"

  ErrorResponse:
    type: "object"
    properties:
      message:
        type: "string"
