openapi: 3.0.0
info:
  version: 'v.0.2.3'
  title: 'Luna Builder'
  description: |
     'VisionLabs Luna Builder. Service allows to build OCI Images using various build tools. 
      To get more information about service requirements - see development manual'

components:
  headers:
    application_json:
      schema:
        type: string
        enum:
        - application/json
      required: true
      description: The content type of the response body.

    luna_request_id:
      schema:
        type: string
        format: timestamp,uuid
        example: 1536751345,8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a
        pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
      description: request id. Helps to uniquely identify messages that correspond to particular requests, in system logs.
      required: true

    docs_content_type:
      schema:
        type: string
        enum:
          - application/x-yaml
          - text/html
      required: true
      description: The content type of the response body.

    text_html:
      schema:
        type: string
        enum:
          - text/html
      required: true
      description: The content type of the response body.

    config_accept_content_type:
      schema:
        type: string
        enum:
          - application/json
          - text/plain
      required: false
      description: The content type of the response body.

    text_plain:
      schema:
        type: string
        enum:
          - text/plain
      required: true
      description: The content type of the response body.
  parameters:
    luna_request_id:
      in: header
      schema:
        type: string
        format: timestamp,uuid
        example: 1536751345,8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a
        pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
      description: |
        external request id. Helps to uniquely identify messages that correspond to particular requests, in system logs.
        If it was not set, system will set it in default format ("timestamp,UUID"). It will be returned with response.
      name: Luna-Request-Id

    accept_docs_handler:
      in: header
      name: Accept
      schema:
        $ref: '#/components/schemas/accept_docs_handler'
      required: true
      description: acceptable type of receiving data

    Accept:
      in: header
      name: Accept
      schema:
        type: string
        enum:
          - application/json
      description: Preferred response content type

    accept_config_handler:
      in: header
      name: Accept
      schema:
        type: string
        enum:
          - application/json
          - text/plain
        description: One of application/json, text/plain
      required: false
      description: acceptable type of receiving data

    include_luna_services:
      in: query
      name: include_luna_services
      schema:
        type: integer
        enum: [0, 1]
        default: 0
      description: Whether to perform healthchecks for dependent luna services.

    page:
      in: query
      name: page
      schema:
        type: integer
        minimum: 1
        default: 1
      description: Page number.

    page_size:
      in: query
      name: page_size
      schema:
        type: integer
        minimum: 1
        maximum: 1000
        default: 10
      description: Number of items on page.

    path_build_id:
      in: path
      name: build_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the image build (`build_id` received in the ["build image"](#operation/createImageBuild) request).

    applicationJsonContent:
      in: header
      name: Content-Type
      schema:
        type: string
        enum:
          - application/json
      description: Content type is `application/json`.

    tail_lines:
      in: query
      name: tail_lines
      default: 100
      schema:
        type: integer
        minimum: 0
        maximum: 4294967296
      description: number of strings what will be return.

    image_name:
      in: query
      name: image_name
      schema:
        $ref: '#/components/schemas/image_name'

    tag:
      in: query
      name: tag
      schema:
        type: string
      description: image tag
  schemas:
    error:
      type: object
      properties:
        error_code:
          type: integer
          description: Error code.
        desc:
          type: string
          description: Short error description.
        detail:
          type: string
          description: Error details.
        link:
          type: string
          description: Link to the documentation website with the error description.
      required: [error_code, detail, desc, link]
      example:
        error_code: 1
        detail: internal server error
        desc: internal server error
        link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-1"

    int_version:
      type: integer
      minimum: 0

    accept_docs_handler:
      type: string
      enum:
        - application/x-yaml
        - text/html
      description: One of application/x-yaml, text/html.

    version:
      type: object
      properties:
        Version:
          type: object
          properties:
            api:
              allOf:
                - $ref: '#/components/schemas/int_version'
              description: An api version of service.
            major:
              allOf:
                - $ref: '#/components/schemas/int_version'
              description: A major version of service.
            minor:
              allOf:
                - $ref: '#/components/schemas/int_version'
              description: A minor version of service.
            patch:
              allOf:
                - $ref: '#/components/schemas/int_version'
              description: A patch version of service.
          required: [ api, major, minor, patch ]
      required: [ Version ]

      example:
        Version:
          api: 1
          major: 0
          minor: 0
          patch: 0

    plugin_status:
      type: object
      properties:
        name:
          type: string
          description: Plugin name
        running:
          allOf:
            - $ref: '#/components/schemas/int01'
            - description: Whether plugin is running or not.
      required: [name, running]

    plugins:
      type: object
      properties:
        plugins:
          description: List of imported plugins.
          type: array
          items:
            $ref: '#/components/schemas/plugin_status'
      required: [plugins]
      example:
        plugins:
          - name: foo
            running: 1

    health_ok:
      description: Successful healthcheck execution info.
      type: object
      properties:
        execution_time:
          type: number
          example: 0.123
          description: Request execution time in seconds.
      required: [ execution_time ]

    health_errors:
      type: object
      properties:
        errors:
          description: Failed healthcheck execution info.
          type: array
          items:
            type: object
            properties:
              component:
                description: Component name.
                type: string
              error:
                allOf:
                  - description: Healthcheck error.
                  - $ref: '#/components/schemas/error'
              status:
                description: Component health status.
                type: integer
                enum: [ 0, 1 ]
            required: [ component, error, status ]
      required: [ errors ]
      example:
        errors:
          - component: licenses
            error:
              error_code: 38001
              desc: Health check error
              detail: License error
              link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-38001
            status: 0

    int01:
      type: integer
      enum: [0,1]

    number01:
      type: number
      minimum: 0
      maximum: 1

    uuid:
      type: string
      format: uuid
      pattern: '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$'
      example: "557d54ec-29ad-4f3c-93b4-c9092ef12515"

    build_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: Build task ID.

    image_name:
      type: string
      description: |
        image name
        - Contain between 1 and 42 characters.
        - Contain only lowercase alphanumeric characters or '-'.
        - End with an alphanumeric character.

    tag:
      type: string
      default: latest
      description: image tag

    namespace:
      type: string
      pattern: ^[a-z0-9][a-z0-9-]*[a-z0-9]$
      description: |
        By default, the `luna-builder` service namespace will be used.

        Builder provides a kubernetes mechanism for isolating groups of resources within a single cluster.
        
        There are several rules for `namespace` usage:
        
          - Avoid creating namespaces with the prefix `kube-`, since it is reserved for Kubernetes system namespaces.
          - Contain between 2 and 63 characters.
          - Contain only lowercase alphanumeric characters or '-'.
          - Start and end with an alphanumeric character.
      example: default


    build_parameters_base:
      type: object
      required: [ image_name ]
      properties:
        image_name:
          $ref: '#/components/schemas/image_name'
        tag:
          $ref: '#/components/schemas/tag'

    build_parameters_k8s_base:
      allOf:
        - $ref: '#/components/schemas/build_parameters_base'
        - type: object
          properties:
            selector:
              $ref: '#/components/schemas/selector'
            namespace:
              $ref: '#/components/schemas/namespace'

    build_parameters_kaniko:
      allOf:
        - $ref: '#/components/schemas/build_parameters_k8s_base'
        - type: object
          properties:
            image_builder:
              type: string
              enum: [ kaniko ]
              description: |
                Image builder type.

                Kaniko builds container images inside Kubernetes. For more information see development documentation.

                **Note that if 'USE_KUBERNETES=0' image builder will fallback to 'local_kaniko'**

    build_parameters_buildah:
      allOf:
        - $ref: '#/components/schemas/build_parameters_k8s_base'
        - type: object
          properties:
            image_builder:
              type: string
              enum: [ buildah ]
              description: |
                Image builder type.
    
                Buildah builds container images inside Kubernetes. Additional permissions and storage driver configurations (such as vfs) may be required for Kubernetes. For more information see development documentation.

                **Note that if 'USE_KUBERNETES=0' image builder will fallback to 'local_kaniko'**

    build_parameters_local:
      allOf:
        - $ref: '#/components/schemas/build_parameters_base'
        - type: object
          properties:
            image_builder:
              type: string
              enum: [ local_kaniko ]
              example: local_kaniko
              description: |
                Image builder type.

                local_kaniko — build locally without using kubernetes. For more information see development documentation.

    selector:
      type: object
      description: Kuberenetes pod node selector.
      additionalProperties:
        x-additionalPropertiesName: selector fields
        description: |
          Kubernetes `key=value` node labels.
          
          Label key may have two segments an optional prefix and required name, separated by a slash `/`:
          
          - the name segment is required and must be 63 characters or less
          - the name segment must beginning and ending with an alphanumeric character `[a-z0-9A-Z]`
          - the name segment may contains dashes `-`, underscores `_`, dots `.`
          - the prefix is optional must be a DNS subdomain: a series of DNS labels separated by dots `.`
          - the prefix can't be longer than 253 characters and ends with a slash `/`
          - the prefix can't be `kubernetes.io/` or `k8s.io/`, because these prefixes are reserved for Kubernetes core components
          
          Label value constraints:
          
          - the value must be 63 characters or less
          - the value can be empty
          - if the value isn't empty then must begin and end with an alphanumeric character `[a-z0-9A-Z]`
          - the value could contain dashes `-`, underscores `_`, dots `.`, and alphanumerics between.
      example:
        app: node-name

    build_create:
      type: object
      required: [ archive, parameters ]
      properties:
        archive:
          type: string
          format: url
          minLength: 3
          maxLength: 2083
          description: link to to image arcvhive
        parameters:
          description: image build parameters
          oneOf:
            - $ref: '#/components/schemas/build_parameters_kaniko'
            - $ref: '#/components/schemas/build_parameters_buildah'
            - $ref: '#/components/schemas/build_parameters_local'
          discriminator:
            propertyName: image_builder
            mapping:
              kaniko: '#/components/schemas/build_parameters_kaniko'
              buildah: '#/components/schemas/build_parameters_buildah'
              local_kaniko: '#/components/schemas/build_parameters_local'

    build_create_response:
      type: object
      properties:
        build_id:
          allOf:
            - $ref: '#/components/schemas/build_id'
          description: |
            ID of the created image building task.
            The ID can be used as the `build_id` parameter in [GET](#operation/getImageBuild) `/images/build/{build_id}`.
      required: [ build_id ]

    build_tasks_list:
      type: object
      properties:
        count:
          type: integer
          description: Total amount of tasks
        build_tasks:
          type: array
          items:
            $ref: '#/components/schemas/build_task'
          minItems: 0
      required: [ build_tasks, count ]

    build_task:
      type: object
      properties:
        build_id:
          $ref: '#/components/schemas/build_id'
        image_name:
          type: string
          description: image name
        tag:
          type: string
          description: image tag
        status:
          $ref: '#/components/schemas/build_task_status'
        image_url:
          type: string
          description: image url
      required: [ build_id, image_name, tag, status ]

    build_task_status:
      type: string
      description: Build task status
      enum: [ pending, in_progress, complete, failed, canceled, not_found]

    build_tasks_response:
      $ref: '#/components/schemas/build_tasks_list'
  responses:
    internal_server_error:
      description: internal server error.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'

    timeout_error:
      description: Timeout error.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'
          examples:
            request_timeout:
              value:
                error_code: 43009
                desc: Timeout error
                detail: "Failed to open video by url http://127.0.0.1:64434/vide3245o.mkv, status code: 504, Request timeout"
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-43009"
            connect_timeout:
              value:
                error_code: 43009
                desc: Timeout error
                detail: "Failed to open video by url http://127.0.0.1:64434/vide3245o.mkv, status code: 504, Connect timeout"
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-43009"
            sock_connect_timeout:
              value:
                error_code: 43009
                desc: Timeout error
                detail: "Failed to open video by url http://127.0.0.1:64434/vide3245o.mkv, status code: 504, Socket connect timeout"
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-43009"
            sock_read_timeout:
              value:
                error_code: 43009
                desc: Timeout error
                detail: "Failed to open video by url http://127.0.0.1:64434/vide3245o.mkv, status code: 504, Socket read timeout"
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-43009"

    forbidden_resource_error:
      description: Forbidden.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'
          examples:
            resource_is_disabled:
              value:
                error_code: 12049
                desc: Forbidden
                detail: Resource is disabled.
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12049"
paths:
  /version:
    get:
      tags:
      - version

      summary: get version
      description: get service version
      operationId: getVersion

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/version'
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/docs/spec:
    get:
      tags:
        - documents
      summary: get openapi documentation
      description: |
        Get service OpenApi documentation. If *Accept* request header is of type `application/x-yaml`,
        returns documentation in `yaml` format or returns `html` documentation, if *Accept-Type* is `text/html`
      operationId: getSpec

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/accept_docs_handler'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/docs_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/x-yaml:
              schema:
                type: string
                description: yaml format documentation
            text/html:
              schema:
                type: string
                description: html format documentation
        415:
          description: Unsupported Media Type
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                unsupported_media_type:
                  value:
                    error_code: 12024
                    detail: 'Bad/incomplete input data'
                    desc: "Unsupported media type"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/docs/dev:
    parameters:
      - $ref: '#/components/parameters/Accept'
    get:
      tags:
        - documents
      summary: get development manual
      description: |
        Get sphinx documentation - *Development Manual*. After the request you will be redirected to the page `/docs/dev/index.html`
      operationId: getDevManual

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/text_html'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            text/html:
              schema:
                type: string
                description: html format documentation
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/config:
    get:
      tags:
        - config
      summary: get service configuration
      description: Get service configuration. Passwords and tokens will be hidden in the response.
      operationId: getConfig

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/accept_config_handler'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/config_accept_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                description: json format configuration
              example:
                INFLUX_MONITORING:
                  SEND_DATA_FOR_MONITORING: 0
                  ORGANIZATION: ORGANIZATION_NAME
                  TOKEN: '********'
                  BUCKET: luna_monitoring
                  HOST: 127.0.0.1
                  PORT: 8086
                  USE_SSL: 0
                  FLUSHING_PERIOD: 1.0
            text/plain:
              schema:
                type: string
                description: text format configuration
              example: |
                [INFLUX_MONITORING]
                SEND_DATA_FOR_MONITORING = 0
                ORGANIZATION = ORGANIZATION_NAME
                TOKEN = ********
                BUCKET = luna_monitoring
                HOST = 127.0.0.1
                PORT = 8086
                USE_SSL = 0
                FLUSHING_PERIOD = 1.0
        415:
          description: Unsupported Media Type
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                unsupported_media_type:
                  value:
                    error_code: 12024
                    detail: 'Bad/incomplete input data'
                    desc: "Unsupported media type"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/images/build:
    post:
      tags:
        - builds
      summary: build image
      description: |
        Create image build task. After the build task is finished, 
        its result will be available for 5 minutes, afterwards it will be deleted (the created image still will be available).
      operationId: createImageBuild
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/build_create'
            examples:
              k8s:
                summary: Build using Kubernetes
                value:
                  archive: "s3://example/archive.tar.gz"
                  parameters:
                    image_name: "string"
                    tag: "latest"
                    image_builder: "kaniko"
                    selector:
                      app: node-name
                    namespace: "default"
              local:
                summary: Build locally
                value:
                  archive: "s3://example/archive.tar.gz"
                  parameters:
                    image_name: "string"
                    tag: "latest"
                    image_builder: "local_kaniko"
      responses:
        202:
          description: Image build task created.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/build_create_response'
              example:
                build_id: a1f3e5d2-1234-4b6a-9f1d-0a1b2c3d4e5f
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                      Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        409:
          description: Builder type is disabled.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                resource_is_disabled:
                  value:
                    error_code: 51004
                    desc: Builder type is disabled
                    detail: kaniko is not available when USE_KUBERNETES = 0.
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-51004"
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
        - builds
      summary: get build tasks
      description: | 
        Get image build tasks info. After the build task is finished,
        its result will be available for 5 minutes, afterwards it's deleted (the created image still will be available).
      operationId: getImagesBuild
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/page_size'
        - $ref: '#/components/parameters/image_name'
        - $ref: '#/components/parameters/tag'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/build_tasks_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'image_name'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        500:
          $ref: '#/components/responses/internal_server_error'

  /1/images/build/{build_id}:
    parameters:
      - $ref: '#/components/parameters/path_build_id'

    get:
      tags:
        - builds
      summary: get build task
      description: | 
        Get build task by build ID. After the build task is finished,
        its result will be available for 5 minutes, afterwards it's deleted (the created image still will be available).
      operationId: getImageBuild
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/build_task'
        404:
          description: Build not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 51001
                desc: Object not found
                detail: Build task with id '88e0045a-6141-43fa-8ca5-1e69b9717d0a' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-51001"
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - builds
      summary: cancel build task
      description: Cancels build task by build ID.
      operationId: deleteImageBuild
      responses:
        204:
          description: Build stopped.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        404:
          description: Build not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 51001
                desc: Object not found
                detail: Build task with id '88e0045a-6141-43fa-8ca5-1e69b9717d0a' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-51001"
        409:
          description: Failed to stop build.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 51002
                desc: Failed to stop build
                detail: Failed to stop build '46fc016d-1b2a-46ff-8443-51b515428c72', its status is not `pending`, `in_progress` or `failed`
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-51002"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/images/build/{build_id}/logs:
    parameters:
      - $ref: '#/components/parameters/path_build_id'

    get:
      tags:
        - build logs
      summary: get build logs
      description: | 
        Get build logs as plain text

        Build logs are available only for builds that are in progress or failed. Failed logs preserved for the same time as build results (5 min).
      operationId: getImageBuildLogs
      parameters:
        - $ref: '#/components/parameters/tail_lines'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/text_plain'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            text/plain:
              schema:
                type: string
              examples:
                logs:
                  value: |
                    [2025-10-17T12:00:00Z] Pulling base image...
                    [2025-10-17T12:00:05Z] Building layers...
        404:
          description: Build not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 51001
                desc: Object not found
                detail: Build task with id '88e0045a-6141-43fa-8ca5-1e69b9717d0a' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-51001"
        409:
          description: Failed to collect build logs.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 51003
                desc: Cannot collect build logs
                detail: Build 46fc016d-1b2a-46ff-8443-51b515428c72 is not 'in_progress' or 'failed'
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-51003"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/plugins:
    get:
      tags:
        - plugins
      summary: get list of plugins
      description: |
        Get list of service plugins
      operationId: getPlugins
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/plugins'
        500:
          $ref: '#/components/responses/internal_server_error'
  /healthcheck:
    get:
      tags:
      - health
      summary: get health
      description: get health of service
      operationId: healthcheck
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/include_luna_services'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/health_ok'
        500:
          $ref: '#/components/responses/internal_server_error'
        502:
          description: Unhealthy
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/health_errors'
  /metrics:

    get:
      tags:
        - metrics
      summary: get service requests statistics
      description: Get statistics of success and failed requests to the service in prometheus format.
      operationId: metrics
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              schema:
                type: string
                enum:
                  - text/plain; charset=UTF-8
              required: true
              description: Content type is `text/plain`.
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            text/plain:
              schema:
                type: string
                description: Prometheus plain text format.
              example: |
                # HELP request_count_total Counter of requests
                # TYPE request_count_total counter
                request_count_total{path="GET:/healthcheck",status_code="200"} 1.0
        403:
          $ref: '#/components/responses/forbidden_resource_error'
        500:
          $ref: '#/components/responses/internal_server_error'
