openapi: 3.0.0
info:
  version: 'v.0.18.0'
  title: 'luna-lambda API'
  description: |
    'VisionLabs luna-lambda' is service intended for manage luna user lambdas.

    Luna-user-lambda represents separate service which can process user requests using code created by user.
    
    For information about lambda representation and 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.
  parameters:
    application_json_content:
      in: header
      name: Content-Type
      schema:
        type: string
        enum:
          - application/json
      description: The request content type header.

    application_multipart_content:
      in: header
      name: Content-Type
      schema:
        type: string
        enum:
          - multipart/form-data
      description: The request content type header.
      required: true

    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

    account_id:
      in: query
      name: account_id
      schema:
        $ref: '#/components/schemas/account_id'
      description: luna account id
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    header_account_id:
      in: header
      name: Luna-Account-Id
      schema:
        $ref: '#/components/schemas/account_id'
      description: luna account id
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'
      required: true

    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.

    create_time__lt:
      in: query
      name: create_time__lt
      schema:
        $ref: '#/components/schemas/time'
      description: upper bound for object create_time.
      example: "2018-08-11T09:11:41.674Z"

    create_time__gte:
      in: query
      name: create_time__gte
      schema:
        $ref: '#/components/schemas/time'
      description: lower included bound for object create_time.
      example: "2018-08-11T09:11:41.674Z"

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

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

    page_size:
      in: query
      name: page_size
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 10
      description: the number of items on page.

    lambda_type:
      in: query
      name: lambda_type
      schema:
        type: string
        enum: [ standalone, handlers, tasks ]
      description: Lambda type.

    lambda_name:
      in: query
      name: lambda_name
      schema:
        type: string
      description: Find all objects with `lambda_name` similar to this parameter. You can specify only part of the `lambda_name` value for this filter.

    namespace:
      in: query
      name: namespace
      description: | 
        Comma-separated list of lambda namespaces.
        Each namespace must match the pattern `^[a-z0-9][a-z0-9-]*[a-z0-9]$`
      schema:
        type: array
        items:
           $ref: "#/components/schemas/namespace"
      example: "default,no-default-namespace"
  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

    time:
      type: string
      format: date-time
      example: "2018-08-11T09:11:41.674Z"
      description: time in format RFC 3339

    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"

    account_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - example: 0468ca85-f6ca-4841-b30c-5ccc26b6f397
      description: id of the luna account.

    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: lambda_db
            error:
              error_code: 10017
              desc: Database error
              detail: Database connection timeout error
              link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-10017"
            status: 0

    lambda_id_response:
      type: object
      properties:
        lambda_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - example: 0468ca85-f6ca-4841-b30c-5ccc26b6f397
            - description: lambda id.
      description: response with lambda id.
      required: [lambda_id]

    lambda_version:
      type: integer
      description: |
        lambda version

        The lambda version incremented after each lambda recreation ([put request](#tag/lambdas-creation/operation/putLambda))
      minimum: 0
      example: 5

    lambda_version_response:
      type: object
      properties:
        version:
          $ref: '#/components/schemas/lambda_version'
      description: response with lambda version.
      required: [ version ]

    lambda_name:
      type: string
      description: Lambda name. Each user can create only lambdas with unique names.
      example: first-lambda

    lambda_type_agent:
      type: string
      enum: [agent]
      description: Lambda type.
      example: agent

    lambda_type_default_params:
      type: string
      enum: [standalone, handlers, tasks]
      description: Lambda type.
      example: standalone
      default: "standalone"

    lambda_type:
      type: string
      enum: [standalone, handlers, tasks, agent]
      description: Lambda type.
      example: standalone
      default: "standalone"

    image_builder:
      type: string
      enum: [kaniko, buildah]
      description: |
        Image builder type.
        
        When choosing the Buildah image builder, additional permissions and storage driver configurations (such as vfs) may be required for Kubernetes.
      example: kaniko
      default: "kaniko"

    lambda_status:
      type: string
      enum: [running, waiting, terminated, not_found, pending]
      description: |
        lambda status

        | status     | description                                             |
        |------------|---------------------------------------------------------|
        | running    | lambda running and ready to process requests            |
        | waiting    | waiting for lambda start or lambda creation in progress |
        | terminated | lambda stopped and will be removed in the near future   |
        | not_found  | lambda not found                                        |
        | pending    | lambda waiting for suitable conditions                  |

        The `running` status is returned when at least one pod in lambda's replicas pods is running or when there is only one lambda pod and it's running.

        The `waiting` status is also returned when all pods in the lambda's replicas have been created but are still starting up.

        * If lambda status is pending it means that there is no suitable conditions for such lambda, for example lambda requires
        GPU and kubernetes cluster cannot provides GPU for lambda.

      example: running

    lambda_status_response:
      type: object
      properties:
        status:
          allOf:
            - $ref: '#/components/schemas/lambda_status'
        pod_statuses:
          type: object
          additionalProperties: true
          example:
            0: running
            1: waiting
          description: |
            Map of pod numbers and their statuses.

            This object is present if at least one of lambda's pod is in `running` status.
      description: |
        response with lambda status.
      required: [status]

    description:
      type: string
      description: lambda description
      example: very useful lambda
      maxLength: 256
      default: ""

    description_no_default:
      type: string
      description: lambda description
      example: very useful lambda
      maxLength: 256

    lambda_patch:
      type: object
      description: lambda patch data
      properties:
        lambda_name:
          $ref: '#/components/schemas/lambda_name'
        description:
          type: string
          description: lambda description
          example: very useful lambda
          maxLength: 256
      minProperties: 1

    user_docker_commands:
      type: array
      default: []
      items:
        type: string
      description: |
        list of additional user docker commands for lambda container building (see development manual for details)
        
        For example to use python library with libjpeg dependency in lambda add the following list of command to `user_docker_commands`
        ```json
        ["RUN dnf install -y epel-release", "RUN dnf install -y libjpeg-turbo-devel"]
        ```

    archive_ttl:
      type: integer
      enum: [ 1, 2, 3, 4, 5, 6, 7, 14, 30, 60, 90, 180, 365, -1 ]
      nullable: true
      example: 7
      description: Lifetime for lambda archive, in days. By default, parent bucket lifetime configuration applied. For archive to be retained indefinitely, setup `ttl=-1`.

    archive_ttl_reply:
      allOf:
        - $ref: '#/components/schemas/archive_ttl'
      description: Lifetime for lambda archive, in days. By default, parent bucket lifetime configuration applied. `ttl=-1` means infinite storage.

    external_agent:
      type: integer
      enum: [0, 1]
      default: 0
      description: Whether to run agent as external service or not.

    base_image_name:
      type: string
      maxLength: 128
      description: |
        Base image name for lambda docker container building (see development manual for details).
        
        The *standalone*, *handlers* and *tasks* lambdas use `lpa-lambda-base` image by default.
        This image provides basic functionality for lambdas.
        
        The *agent* lambdas using `lpa-lambda-agent-base` image by default.
        This image provides extended functionality for video-agent and includes FSDK.
        
        The `lpa-lambda-base-fsdk` provides basic functionality and functionality for FSDK usage by lambda.
        
        Other images must be inherited from one of above and require image tag specified.

    base_image_tag:
      type: string
      description: Base lambda image tag. See development manual for details.
      maxLength: 36

    base_image_default:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/base_image_name'
          enum: [lpa-lambda-base]
          default: lpa-lambda-base
        tag:
          allOf:
            - $ref: '#/components/schemas/base_image_tag'
          description: | 
            Base lambda image tag. See development manual for details.

            The default value is latest available tag of base lambda image.
      required: [name]

    base_image_fsdk:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/base_image_name'
          enum: [lpa-lambda-base-fsdk]
          default: lpa-lambda-base-fsdk
        tag:
          allOf:
            - $ref: '#/components/schemas/base_image_name'
          description: | 
            Base lambda image tag. See development manual for details.

            The default value is latest available tag of base lambda image.
      required: [name]

    base_image_agent:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/base_image_name'
          enum: [lpa-lambda-agent-base]
          default: lpa-lambda-agent-base
        tag:
          allOf:
            - $ref: '#/components/schemas/base_image_name'
          description: | 
            Base lambda agent image tag. See development manual for details.

            The default value is latest available tag of base lambda agent image.
      required: [name]

    base_image_custom:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/base_image_name'
        tag:
          $ref: '#/components/schemas/base_image_tag'
      required: [name, tag]

    base_image_custom_nullable:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/base_image_name'
            - nullable: true
        tag:
          allOf:
            - $ref: '#/components/schemas/base_image_tag'
            - nullable: true
      required: [name, tag]

    pod_count:
      type: integer
      minimum: 1
      maximum: 32
      default: 1
      example: 2
      description: Count of lambda pods

    enable_gpu:
      type: integer
      enum: [0, 1]
      default: 0
      description: |
        Whether to enable GPU usage for lambda.
        
        See development manual for lambda GPU usage details.

    resources:
      type: object
      properties:
        cpu_limit:
          $ref: '#/components/schemas/cpu_limit'
        ram_limit:
          $ref: '#/components/schemas/ram_limit'
        cpu_request:
          $ref: '#/components/schemas/cpu_request'
        ram_request:
          $ref: '#/components/schemas/ram_request'
      description: Lambda's resources requests and limits

    resources_required:
      allOf:
        - $ref: '#/components/schemas/resources'
      required: [cpu_limit, ram_limit, cpu_request, ram_request]

    cpu_limit:
      type: integer
      default: 1000
      description: CPU resource units limit for each of lambda's pods. 1 unit means 1/1000 of CPU core.

    ram_limit:
      type: integer
      default: 1
      description: Maximum RAM usage limit in GB for each of lambda's pods.

    cpu_request:
      type: integer
      default: 1000
      description: CPU resource units request for each of lambda's pods. Same as limit if not specified. 1 unit means 1/1000 of CPU core.

    ram_request:
      type: integer
      default: 1
      description: RAM usage request in GB for each of lambda's pods. Same as limit if not specified.

    gpu_enabled:
      type: integer
      enum: [0, 1]
      description: |
        Whether GPU is enabled for lambda.
        
        See development manual for lambda GPU usage details.

    base_image:
      description: |
        Base image for lambda.
        
        Example:
        
        ```json
        "base_image": {"name": "my-custom-image", "tag": "my-custom-tag_latest"}
        ```

        In this case the base image full name will be: `my-custom-image:my-custom-tag_latest`.
      oneOf:
      - $ref: '#/components/schemas/base_image_default'
      - $ref: '#/components/schemas/base_image_fsdk'
      - $ref: '#/components/schemas/base_image_agent'
      - $ref: '#/components/schemas/base_image_custom'
      discriminator:
        propertyName: name
        mapping:
          lpa-lambda-base: '#/components/schemas/base_image_default'
          lpa-lambda-base-fsdk: '#/components/schemas/base_image_fsdk'
          lpa-lambda-agent-base: '#/components/schemas/base_image_agent'
          custom: '#/components/schemas/base_image_custom'

    base_image_reply:
      allOf:
        - $ref: '#/components/schemas/base_image_custom_nullable'
      description: Base image for lambda.

    deploy_parameters:
      type: object
      description: Deploy parameters for lambda.
      properties:
        enable_gpu:
          $ref: '#/components/schemas/enable_gpu'
        pod_count:
          $ref: '#/components/schemas/pod_count'
        resources:
          $ref: '#/components/schemas/resources'
        namespace:
          $ref: '#/components/schemas/namespace'
        selector:
          $ref: '#/components/schemas/selector'

    deploy_parameters_reply:
      type: object
      description: Deploy parameters for lambda.
      properties:
        gpu_enabled:
          $ref: '#/components/schemas/gpu_enabled'
        pod_count:
          $ref: '#/components/schemas/pod_count'
        resources:
          $ref: '#/components/schemas/resources_required'
        namespace:
          $ref: '#/components/schemas/namespace'
        selector:
          $ref: '#/components/schemas/selector'
      required: [gpu_enabled, pod_count, resources, namespace, selector]

    lambda_name_credentials:
      type: string
      minLength: 3
      maxLength: 36
      description: Lambda name

    credentials:
      type: object
      description: Lambda credentials.
      properties:
        lambda_name:
          $ref: '#/components/schemas/lambda_name_credentials'
        description:
          $ref: '#/components/schemas/description'
      required: [lambda_name]


    lambda_common_parameters:
      type: object
      description: | 
        Parameters for lambda.
        Content-Type must be "application/json".
      properties:
        image_builder:
          $ref: '#/components/schemas/image_builder'
        additional_user_docker_commands:
          $ref: '#/components/schemas/user_docker_commands'
        base_image:
          $ref: '#/components/schemas/base_image'
        workers:
          $ref: '#/components/schemas/workers'
        archive_ttl:
          $ref: '#/components/schemas/archive_ttl'
        user_config:
          allOf:
            - $ref: '#/components/schemas/user_config'
            - default: null
            - nullable: true

    agent_credentials:
      type: object
      description: Agent credentials. External agent requires token or login with password to be set.
      properties:
        token:
          type: string
          description: External agent authorization token.
        login:
          type: string
          minLength: 3
          maxLength: 128
          description: External agent login
        password:
          type: string
          minLength: 3
          maxLength: 128
          description: External agent password

    lambda_agent_parameters:
      allOf:
        - properties:
            lambda_type:
              $ref: '#/components/schemas/lambda_type_agent'
            external_agent:
              $ref: '#/components/schemas/external_agent'
            agent_credentials:
              $ref: '#/components/schemas/agent_credentials'
        - $ref: '#/components/schemas/lambda_common_parameters'

    lambda_standard_params:
      allOf:
        - properties:
            lambda_type:
              $ref: '#/components/schemas/lambda_type_default_params'
        - $ref: '#/components/schemas/lambda_common_parameters'

    lambda_parameters:
      oneOf:
        - $ref: '#/components/schemas/lambda_standard_params'
        - $ref: '#/components/schemas/lambda_agent_parameters'

    import_credentials:
      type: object
      description: | 
        Lambda credentials.
        
        **Note: this field will overwrite credentials from archive**
      properties:
        lambda_name:
          $ref: '#/components/schemas/lambda_name_credentials'
        description:
          $ref: '#/components/schemas/description_no_default'

    lambda_multipart_content-archive_file:
      type: object
      properties:
        archive:
          type: string
          format: binary
          description: |
              Archive file with zip extension.
              Content-Type must be "application/zip".
        credentials:
          allOf:
            - $ref: '#/components/schemas/credentials'
            - description: |
                Lambda credentials.
                Content-Type must be "application/json".
        parameters:
          $ref: '#/components/schemas/lambda_parameters'
        deploy_parameters:
          allOf:
           - $ref: '#/components/schemas/deploy_parameters'
           - description: Deploy parameters for lambda. Content-Type must be "application/json".
      description: lambda multipart content with archive file.
      required: [ archive, credentials ]

    lambda_multipart_import:
      type: object
      properties:
        archive:
          type: string
          format: binary
          description: |
              Archive file with zip extension.
              Content-Type must be "application/zip".
        credentials:
          $ref: '#/components/schemas/import_credentials'
        parameters:
          type: object
          description: | 
            Parameters for lambda.
            Content-Type must be "application/json".
            
            **Note: this field will overwrite parameters from archive**
          properties:
            workers:
              $ref: '#/components/schemas/workers_no_default'
            archive_ttl:
              $ref: '#/components/schemas/archive_ttl'
            user_config:
              $ref: '#/components/schemas/user_config'
        deploy_parameters:
          allOf:
            - $ref: '#/components/schemas/deploy_parameters'
          description: | 
            Deploy parameters for lambda. Content-Type must be "application/json".
            
            **Note: this field will overwrite deploy parameters from archive**
      description: lambda multipart content with archive file for import.
      required: [archive]

    lambda_import_json:
      type: object
      properties:
        import_image:
          type: object
          properties:
            name:
              type: string
              maxLength: 128
              description: Image name
              example: lpa-lambda
            tag:
              type: string
              maxLength: 128
              default: latest
              description: Image tag.
              example: v1-lambda-c52079ba-43db-4484-90f3-d349f9518a73
          description: Lambda image
          required: [name]
        credentials:
          type: object
          description: Lambda credentials.
          properties:
            lambda_name:
              type: string
              minLength: 3
              maxLength: 36
              description: Lambda name
            description:
              $ref: '#/components/schemas/description'
          required: [lambda_name]
        parameters:
          type: object
          description: Parameters for lambda.
          properties:
            lambda_type:
              $ref: '#/components/schemas/lambda_type'
            workers:
              $ref: '#/components/schemas/workers'
        deploy_parameters:
          $ref: '#/components/schemas/deploy_parameters'
      required: [ import_image, credentials ]

    exported_archive:
      type: string
      format: binary
      description: |
            Exported archive. Archive contains:
            1) docker image of the lambda
            2) source archive provided during lambda creation
            3) json with lambda parameters
                **Json structure**
                ```
                {
                  "credentials": {...},
                  "parameters": {...},
                  "deploy_parameters": {...}
                }
                ```

    common_lambda:
      type: object
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'
        lambda_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - description: lambda id.
        lambda_name:
          allOf:
            - $ref: '#/components/schemas/lambda_name'
        description:
          $ref: '#/components/schemas/description'
        version:
          $ref: '#/components/schemas/lambda_version'
        info:
          allOf:
            - $ref: '#/components/schemas/lambda_status_response'
          type: object
          description: lambda info
          required: [status]
        create_time:
          allOf:
            - $ref: "#/components/schemas/time"
            - format: date-time
          description: time of the lambda creation.
        last_update_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: date and time with timezone of last action with lambda.
        additional_user_docker_commands:
          $ref: '#/components/schemas/user_docker_commands'
        base_image:
          $ref: '#/components/schemas/base_image_reply'
        imported_image:
          type: object
          description: Image that lambda was created from
          properties:
            name:
              type: string
              nullable: true
              description: Image name
            tag:
              type: string
              nullable: true
              description: Image tag
          required: [name, tag]
        workers:
          $ref: '#/components/schemas/workers'
        archive_ttl:
          $ref: '#/components/schemas/archive_ttl_reply'
        deploy_parameters:
          $ref: '#/components/schemas/deploy_parameters_reply'

    lambda_default:
      allOf:
        - properties:
            lambda_type:
              $ref: '#/components/schemas/lambda_type_default_params'
        - $ref: '#/components/schemas/common_lambda'
      required: [lambda_id, lambda_name, imported_image, version, info, create_time, last_update_time, account_id, description, lambda_type, additional_user_docker_commands, base_image, workers, archive_ttl, deploy_parameters]

    config_with_version:
      type: object
      properties:
        config:
          allOf:
            - $ref: '#/components/schemas/user_config'
            - nullable: true
        version:
          type: integer
          description: user config version
          nullable: true
      required: [ config, version ]

    config_version_response:
      type: object
      properties:
        version:
          type: integer
          description: user config version
          nullable: true
      required: [ version ]

    lambda_agent:
      allOf:
        - properties:
            lambda_type:
              $ref: '#/components/schemas/lambda_type_agent'
            external_agent:
              allOf:
                - $ref: '#/components/schemas/external_agent'
                - nullable: true
        - $ref: '#/components/schemas/common_lambda'
      required: [lambda_id, lambda_name, imported_image, version, info, create_time, last_update_time, account_id, description, lambda_type, additional_user_docker_commands, base_image, workers, archive_ttl, deploy_parameters, external_agent]

    lambda:
      oneOf:
        - $ref: '#/components/schemas/lambda_default'
        - $ref: '#/components/schemas/lambda_agent'

    image_creation_status:
      type: object
      properties:
        status:
          type: string
          enum: [not_found, in_progress, error, pending, completed]
          description: |
            lambda image creation status

            | status      | description                                                               |
            |-------------|---------------------------------------------------------------------------|
            | in_progress | image creation in progress, lambda creation will start in the near future |
            | error       | an error occurred during image creation                                   |
            | completed   | image creation completed but not cleaned up yet                           |
            | not_found   | image creation complete and cleaned up or it never was                    |
            | pending     | image creation waiting for suitable conditions                            |

      required: [status]

    lambda_logs:
      type: object
      properties:
        logs:
          type: object
          additionalProperties: true
          description: map of pod numbers and their logs in array of strings.
      description: lambda logs.
      required: [logs]

    lambda_image_logs:
      type: object
      properties:
        logs:
          type: array
          items:
            type: string
          description: lambda log strings.
      description: lambda logs.
      required: [logs]

    lambda_validation_error_response:
      type: object
      properties:
        errors:
          type: array
          items:
            type: string
          description: lambda validate errors.
          example: [ validation_error_one, validation_error_two ]
      description: response of lambda validation.
      required: [ errors ]

    plugin_status:
      type: object
      properties:
        name:
          type: string
          description: Plugin name
        running:
          type: integer
          enum: [0, 1]
          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


    workers_no_default:
      type: integer
      minimum: 1
      maximum: 32
      description: Count of lambda workers

    workers:
      allOf:
        - $ref: '#/components/schemas/workers_no_default'
        - default: 1

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

        Lambda 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.

    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: lambda-name

    user_config:
      type: object
      description: Lambda user config
      additionalProperties:
        x-additionalPropertiesName: lambda unit service configuration
        description: |
          Json containing service settings in format. Only string keys are allowed
          ```json
          {
            "SETTING_1": "value",
            "SETTING_2": {"key": "value"},
          }
          ```

    user_config_request:
      type: object
      properties:
        user_config:
          $ref: '#/components/schemas/user_config'
      required: [user_config]
  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'

    method_not_allowed:
      description: method not allowed.
      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: 12021
            desc: Method not allowed
            detail: Method not allowed
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12021"

    lambda_already_exists_by_name:
      description: lambda with specified name already exists.
      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: 42003
            desc: Unique constraint error
            detail: 'Lambda with name good_lambda already exists'
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42003"

    lambda_not_found:
      description: lambda 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: 42001
            desc: Object not found
            detail: Lambda with id 'e63e2a1f-f505-441c-8e11-b2dcd0385329' not found
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12013"

    lambda_not_running:
      description: lambda not running.
      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: 42016
            desc: Lambda isn't running
            detail: Lambda with id 'e63e2a1f-f505-441c-8e11-b2dcd0385329' isn't running and cannot be exported
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12013"

    lambda_failed_import_multipart:
      description: failed to parse multipart payload of lambda import.
      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: 42017
            desc: Bad/incomplete input data
            detail: Failed to parse multipart payload for lambda import
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12013"

    lambda_or_page_not_found:
      description: lambda not found or page 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'
          examples:
            lambda_not_found:
              value:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id 'e63e2a1f-f505-441c-8e11-b2dcd0385329' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12013"
            lambda_page_not_found:
              value:
                error_code: 12013
                desc: Resource not found
                detail: Page not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12013"

    lambda_no_archive:
      description: archive for lambda 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'
          examples:
            lambda_not_found:
              value:
                error_code: 42001
                desc: Object not found
                detail: Archive for lambda 'e63e2a1f-f505-441c-8e11-b2dcd0385329' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12013"

    license_problem:
      description: license problem.
      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: 11055
            desc: Forbidden
            detail: "License problem: 'License expired'"
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11055"

    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/lambdas:
    post:
      tags:
      - lambdas creation
      summary: create lambda
      description: |
        Start new lambda creation process.
        
        Lambda creation comprises in two parts:

          - docker image creation | process can be seen by [image monitoring](#tag/lambda-image-monitoring)
          
          - lambda creation and launching | process can be seen by [lambda monitoring](#tag/lambda-monitoring)
        
        Lambda can be created from imported image. In this case image creation stage will be skipped.
        See more about image import in developer manual.
        
        After lambda creation process will be completed lambda status will be changed to `running` and it will be
        ready to process requests. For more details see development manual.

      operationId: createLambda
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/application_multipart_content'
      - $ref: '#/components/parameters/header_account_id'
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/lambda_multipart_content-archive_file'
          application/json:
            schema:
              $ref: '#/components/schemas/lambda_import_json'
        required: true
      responses:
        202:
          description: Lambda creation executed successfully.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /1/lambdas/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the lambda.
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/lambda_id_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:
                archive_not_contains_file:
                  value:
                    error_code: 12048
                    desc: Bad/incomplete input data
                    detail: 'Archive file does not contain lambda.py'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12048"
                unknown_multipart_name:
                  value:
                    error_code: 12039
                    desc: Bad/incomplete input data
                    detail: 'Unknown multipart name ''account'''
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12039"
                duplicate_multipart_name:
                  value:
                    error_code: 12040
                    desc: Bad/incomplete input data
                    detail: 'Duplicate multipart name ''lambda_name'''
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12040"
                bad_multipart_content_type:
                  value:
                    error_code: 12041
                    desc: Bad/incomplete input data
                    detail: 'Multipart with name ''lambda_name'' has bad Content-Type'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12041"
                account_id_not_found:
                  value:
                    error_code: 11066
                    desc: Bad/incomplete input data
                    detail: Luna-Account-Id header not found
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11066"
                bad_account_id:
                  value:
                    error_code: 11037
                    desc: Bad/incomplete input data
                    detail: "Luna-Account-Id header is not UUID, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11037"
        403:
          $ref: '#/components/responses/license_problem'
        409:
          $ref: '#/components/responses/lambda_already_exists_by_name'
        422:
          description: Unprocessable Content.
          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:
                archive_not_contains_file:
                  value:
                    error_code: 42009
                    desc: Unprocessable Content
                    detail: "Fail to access provided image: 'http://registry/image:tag'"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42009"
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
      - lambda monitoring
      summary: get lambdas
      description: Get lambdas according to filters.
      operationId: getLambdas
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/create_time__lt'
      - $ref: '#/components/parameters/create_time__gte'
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/page_size'
      - $ref: '#/components/parameters/lambda_type'
      - $ref: '#/components/parameters/lambda_name'
      - $ref: '#/components/parameters/namespace'
      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:
                type: object
                properties:
                  lambdas:
                    description: lambdas
                    type: array
                    items:
                      $ref: '#/components/schemas/lambda'
                    minItems: 0
                required: [lambdas]
        400:
          description: Bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'create_time__lt'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/validator:
    post:
      tags:
      - lambdas validator
      summary: validation lambda
      description: |
        Lambda validation.
        
        Lambda validation not guarantees hassle-free lambda creation and execution, but is an integral part of lambda
        creation process and allows you to make sure that the archive and its contents meet the requirements.
      operationId: validationLambda
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/application_multipart_content'
      requestBody:
        content:
          application/zip:
            schema:
              type: object
              properties:
                archive:
                  type: string
                  format: binary
                  description: |
                    Archive file with zip extension.
                    Content-Type must be "application/zip".
                parameters:
                  type: object
                  description: Parameters for lambda.
                  properties:
                    lambda_type:
                      $ref: '#/components/schemas/lambda_type'
                  required: [lambda_type]
              required: [ archive, parameters ]
        required: true
      responses:
        204:
          description: Lambda validation success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Validate lambda 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/lambda_validation_error_response'
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/{lambda_id}:
    parameters:
    - in: path
      name: lambda_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the lambda.

    put:
      tags:
      - lambdas creation
      summary: put lambda
      description: |
        Execute lambda recreation. 
        
        The lambda version will be incremented after recreation finish.
        
        Lambda recreation comprises in three parts:

          - old lambda removing

          - docker image creation | process can be seen by [image monitoring](#tag/lambda-image-monitoring)
          
          - lambda creation and launching | process can be seen by [lambda monitoring](#tag/lambda-monitoring)
        
        After lambda creation process will be completed lambda status will be changed to `running` and it will be
        ready to process requests. For more details see development manual.

      operationId: putLambda
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/application_multipart_content'
        - $ref: '#/components/parameters/header_account_id'
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/lambda_multipart_content-archive_file'
          application/json:
            schema:
              $ref: '#/components/schemas/lambda_import_json'
        required: true
      responses:
        200:
          description: Lambda recreation executed successfully.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /1/lambdas/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the lambda.
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/lambda_version_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:
                archive_not_contains_file:
                  value:
                    error_code: 12048
                    desc: Bad/incomplete input data
                    detail: 'Archive file does not contain lambda.py'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12048"
                unknown_multipart_name:
                  value:
                    error_code: 12039
                    desc: Bad/incomplete input data
                    detail: 'Unknown multipart name ''account'''
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12039"
                duplicate_multipart_name:
                  value:
                    error_code: 12040
                    desc: Bad/incomplete input data
                    detail: 'Duplicate multipart name ''lambda_name'''
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12040"
                bad_multipart_content_type:
                  value:
                    error_code: 12041
                    desc: Bad/incomplete input data
                    detail: 'Multipart with name ''lambda_name'' has bad Content-Type'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12041"
                account_id_not_found:
                  value:
                    error_code: 11066
                    desc: Bad/incomplete input data
                    detail: Luna-Account-Id header not found
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11066"
                bad_account_id:
                  value:
                    error_code: 11037
                    desc: Bad/incomplete input data
                    detail: "Luna-Account-Id header is not UUID, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11037"
        403:
          $ref: '#/components/responses/license_problem'
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
        409:
          $ref: '#/components/responses/lambda_already_exists_by_name'
        500:
          $ref: '#/components/responses/internal_server_error'

    patch:
      tags:
      - lambdas creation
      summary: patch lambda
      description: patch lambda.
      operationId: patchLambda
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/application_json_content'
        - $ref: '#/components/parameters/header_account_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/lambda_patch'
        required: true
      responses:
        204:
          description: Lambda patched successfully.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        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:
                account_id_not_found:
                  value:
                    error_code: 11066
                    desc: Bad/incomplete input data
                    detail: Luna-Account-Id header not found
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11066"
                bad_account_id:
                  value:
                    error_code: 11037
                    desc: Bad/incomplete input data
                    detail: "Luna-Account-Id header is not UUID, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11037"
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
      - lambda monitoring
      summary: get lambda
      description: Get lambda by ID.
      operationId: getLambda
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/lambda'
        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_content_type:
                  value:
                    error_code: 12017
                    desc: Bad/incomplete input data
                    detail: Bad content type
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12017"
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
        500:
          $ref: '#/components/responses/internal_server_error'

    head:
      tags:
      - lambda monitoring
      summary: check lambda existence
      description:  Check existence of the lambda by ID.
      operationId: checkLambda
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: lambda exists
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
        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_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
      - lambdas deletion
      summary: delete lambda
      description: Remove lambda by ID.
      operationId: deleteLambda
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        204:
          description: Delete success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        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_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/{lambda_id}/image:
    parameters:
      - in: path
        name: lambda_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: ID of the lambda.

    get:
      tags:
        - lambda image
      summary: get lambda image
      description: Get lambda image.
      operationId: getLambdaImage
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                type: object
                properties:
                  exported_image:
                    type: object
                    properties:
                      image:
                        type: string
                        description: Lambda image
                    description: Image data
                    required: [ image ]
                required: [exported_image]
        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_content_type:
                  value:
                    error_code: 12017
                    desc: Bad/incomplete input data
                    detail: Bad content type
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12017"
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/{lambda_id}/update:
    parameters:
    - in: path
      name: lambda_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the lambda.

    post:
      tags:
        - lambda update
      summary: update lambda
      description: |
        update lambda using latest base image.
        
        The luna-platform update may cause incompatibility with old lambdas. To make the old lambdas compatible with 
        actual luna-platform it needs to update lambda. For more details see development manual.
      operationId: updateLambda
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/header_account_id'
      responses:
        200:
          description: Lambda update executed successfully.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /1/lambdas/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the lambda.
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/lambda_version_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:
                account_id_not_found:
                  value:
                    error_code: 11066
                    desc: Bad/incomplete input data
                    detail: Luna-Account-Id header not found
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11066"
                bad_account_id:
                  value:
                    error_code: 11037
                    desc: Bad/incomplete input data
                    detail: "Luna-Account-Id header is not UUID, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11037"
        403:
          $ref: '#/components/responses/license_problem'
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                lambda_not_found:
                  value:
                    error_code: 42001
                    desc: Object not found
                    detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
                archive_not_found:
                  value:
                    error_code: 42005
                    desc: Lambda archive not found
                    detail: Archive of lambda '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found in S3. Read developer guide for more information
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42005"
        409:
          description: Lambda update conflict.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                lambda_not_found:
                  value:
                    error_code: 42011
                    desc: Lambda update conflict
                    detail: Lambda '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' cannot be updated, since it uses imported image
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42011"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/{lambda_id}/image/status:
    parameters:
    - in: path
      name: lambda_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the lambda.

    get:
      tags:
      - lambda image monitoring
      summary: get lambda image creation status
      description: |
        Get lambda image creation status by lambda ID.

        If lambda image creation is in progress, lambda status will be `waiting`.

        After lambda image creation will end, the lambda image creation job will be removed and status will be `not_found`.

        For more information about lambda and lambda images statuses see development manual.

      operationId: getLambdaImageStatus
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/image_creation_status'
        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_content_type:
                  value:
                    error_code: 12017
                    desc: Bad/incomplete input data
                    detail: Bad content type
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12017"
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/{lambda_id}/image/logs:
    parameters:
    - in: path
      name: lambda_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the lambda.

    get:
      tags:
      - lambda image monitoring
      summary: get lambda image creation logs
      description: |
        Get lambda image creation logs by lambda ID.
        
        During the creation of the lambda image, it is possible to get logs to monitor the progress.
        
        For more information about lambda and lambda images logs see development manual.

      operationId: getLambdaImageCreationLogs
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/tail_lines'
      responses:
        200:
          description: OK
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/lambda_image_logs'
        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_content_type:
                  value:
                    error_code: 12017
                    desc: Bad/incomplete input data
                    detail: Bad content type
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12017"
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/{lambda_id}/status:
    parameters:
    - in: path
      name: lambda_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the lambda.

    get:
      tags:
      - lambda monitoring
      summary: get lambda status
      description: |
        Get lambda status by ID.

        If lambda image creation is in progress, lambda status will be `waiting`.

        For more information about lambda and lambda images statuses see development manual.

      operationId: getLambdaStatus
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/lambda_status_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_content_type:
                  value:
                    error_code: 12017
                    desc: Bad/incomplete input data
                    detail: Bad content type
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12017"
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/{lambda_id}/logs:
    parameters:
    - in: path
      name: lambda_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the lambda.

    get:
      tags:
      - lambda monitoring
      summary: get lambda logs
      description: |
        Get lambda logs by ID.
        
        After lambda creation has been executed, there is possibility to get lambda logs.
        
        For more information about lambda and lambda images logs see development manual.

      operationId: getLambdaLogs
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/tail_lines'
      responses:
        200:
          description: OK
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/lambda_logs'
        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_content_type:
                  value:
                    error_code: 12017
                    desc: Bad/incomplete input data
                    detail: Bad content type
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12017"
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        404:
          description: Lambda not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 42001
                desc: Object not found
                detail: Lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42001"
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/{lambda_id}/docs/spec:
    parameters:
    - in: path
      name: lambda_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the lambda.

    get:
      tags:
      - lambda documentation
      summary: get lambda openapi documentation
      description: |
        Get lambda 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: getLambdaSpec

      parameters:
        - $ref: '#/components/parameters/account_id'
        - $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
        404:
          $ref: '#/components/responses/lambda_not_found'
        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/lambdas/{lambda_id}/proxy:
    parameters:
    - in: path
      name: lambda_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the lambda.
    - in: path
      name: path_parameters
      schema:
        type: string
        description: additional path parameters
        example: /main
      required: false
      description: any additional path parameter will be use as path parameter to lambda

    post:
      tags:
      - lambda proxy
      summary: proxy post request to lambda
      description: |
        Proxy POST request to lambda.

        Request and response headers, query parameters and body description 
        [must be provided](#operation/getLambdaSpec) by lambda documentation.

        Described headers will be processed and received independently of lambda behavior.

        Note: proxy request
      operationId: proxyLambdaPost
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/header_account_id'
      responses:
        200:
          description: Success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        403:
          $ref: '#/components/responses/license_problem'
        404:
          $ref: '#/components/responses/lambda_or_page_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
      - lambda proxy
      summary: proxy get request to lambda
      description: |
        Proxy GET request to lambda.

        Request and response headers, query parameters and body description 
        [must be provided](#operation/getLambdaSpec) by lambda documentation.

        Described headers will be processed and received independently of lambda behavior.
      operationId: proxyLambdaGet
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: Success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        403:
          $ref: '#/components/responses/license_problem'
        404:
          $ref: '#/components/responses/lambda_or_page_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

    head:
      tags:
      - lambda proxy
      summary: proxy head request to lambda
      description: |
        Proxy HEAD request to lambda.

        Request and response headers, query parameters and body description 
        [must be provided](#operation/getLambdaSpec) by lambda documentation.

        Described headers will be processed and received independently of lambda behavior.
      operationId: proxyLambdaHead
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: Success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        403:
          $ref: '#/components/responses/license_problem'
        404:
          $ref: '#/components/responses/lambda_or_page_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

    put:
      tags:
      - lambda proxy
      summary: proxy put request to lambda
      description: |
        Proxy PUT request to lambda.

        Request and response headers, query parameters and body description 
        [must be provided](#operation/getLambdaSpec) by lambda documentation.

        Described headers will be processed and received independently of lambda behavior.
      operationId: proxyLambdaPut
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/header_account_id'
      responses:
        200:
          description: Success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        403:
          $ref: '#/components/responses/license_problem'
        404:
          $ref: '#/components/responses/lambda_or_page_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

    patch:
      tags:
      - lambda proxy
      summary: proxy patch request to lambda
      description: |
        Proxy PATCH request to lambda.

        Request and response headers, query parameters and body description 
        [must be provided](#operation/getLambdaSpec) by lambda documentation.

        Described headers will be processed and received independently of lambda behavior.
      operationId: proxyLambdaPatch
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: Success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        403:
          $ref: '#/components/responses/license_problem'
        404:
          $ref: '#/components/responses/lambda_or_page_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
      - lambda proxy
      summary: proxy delete request to lambda
      description: |
        Proxy DELETE request to lambda.

        Request and response headers, query parameters and body description 
        [must be provided](#operation/getLambdaSpec) by lambda documentation.

        Described headers will be processed and received independently of lambda behavior.
      operationId: proxyLambdaDelete
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: Success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        403:
          $ref: '#/components/responses/license_problem'
        404:
          $ref: '#/components/responses/lambda_or_page_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

    options:
      tags:
      - lambda proxy
      summary: proxy options request to lambda
      description: |
        Proxy OPTIONS request to lambda.

        Request and response headers, query parameters and body description 
        [must be provided](#operation/getLambdaSpec) by lambda documentation.

        Described headers will be processed and received independently of lambda behavior.
      operationId: proxyLambdaOptions
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: Success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        404:
          $ref: '#/components/responses/lambda_or_page_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/{lambda_id}/export:
    parameters:
    - in: path
      name: lambda_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the lambda.

    get:
      tags:
      - lambda import/export
      summary: export lambda archive
      description: Export archive with lambda and parameters.
      operationId: exportLambda
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: Export success
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/zip:
              schema:
                $ref: '#/components/schemas/exported_archive'
        410:
          $ref: '#/components/responses/lambda_no_archive'
        404:
          $ref: '#/components/responses/lambda_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        422:
          $ref: '#/components/responses/lambda_not_running'
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/lambdas/import:
    post:
      tags:
      - lambda import/export
      summary: import lambda archive
      description: import archive with lambda and parameters.
      operationId: importLambda
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/header_account_id'
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/lambda_multipart_import'
      responses:
        202:
          description: Success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /1/lambdas/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the lambda.
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/lambda_id_response'
        400:
          $ref: '#/components/responses/lambda_failed_import_multipart'
        404:
          $ref: '#/components/responses/lambda_not_found'
        409:
          $ref: '#/components/responses/lambda_already_exists_by_name'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'  
  /1/lambdas/{lambda_id}/config:
    parameters:
      - in: path
        name: lambda_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: ID of the lambda.

    get:
      tags:
        - lambda config
      summary: get lambda config
      description: Get lambda user configuration
      operationId: getLambdaConfig
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: Export success
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/config_with_version'
        404:
          $ref: '#/components/responses/lambda_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        422:
          $ref: '#/components/responses/lambda_not_running'
        500:
          $ref: '#/components/responses/internal_server_error'

    put:
      tags:
        - lambda config
      summary: update lambda config
      description: Update lambda user configuration
      operationId: putLambdaConfig
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/header_account_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/user_config_request'
        required: true
      responses:
        200:
          description: Export success
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/config_version_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:
                account_id_not_found:
                  value:
                    error_code: 11066
                    desc: Bad/incomplete input data
                    detail: Luna-Account-Id header not found
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11066"
                bad_account_id:
                  value:
                    error_code: 11037
                    desc: Bad/incomplete input data
                    detail: "Luna-Account-Id header is not UUID, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11037"
        404:
          $ref: '#/components/responses/lambda_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        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
                  VERSION: 2
                  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
                VERSION = 2
                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/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'
  /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'
  /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'
