OpenApi

View spec in html.

openapi: 3.0.0
info:
  version: 'v.2.2.5'
  title: 'luna-lambda API'
  description: |
    '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, agent ]
      description: Lambda type.

    job_type:
      in: query
      name: job_type
      schema:
        type: string
        enum: [ standalone, agent ]
      description: Job type.

    workflow_type:
      in: query
      name: workflow_type
      schema:
        type: string
        enum: [ standalone, agent ]
      description: Workflow type.

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

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

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

    namespace:
      in: query
      name: namespace
      description: | 
        Comma-separated list of 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"

    metrics:
      in: query
      name: metrics
      description: | 
        Comma separated metrics names. 
        
        Metrics available by default:
          - `requests_bucket`
          - `requests_sum`
          - `request_count_total`
          - `request_errors_total`
      schema:
        type: string
        pattern: "[a-zA-Z_:][a-zA-Z0-9_:]*"
        minLength: 1
      required: true

    resources:
      in: query
      name: resources
      description: |
        Comma separated resources path filter.
      schema:
        type: string
        pattern: "^(GET|POST|PUT|DELETE|PATCH):\/(?:[a-zA-Z0-9_-]+|{[a-zA-Z0-9_-]+})(?:\/(?:[a-zA-Z0-9_-]+|{[a-zA-Z0-9_-]+}))*$"
      example: "GET:/additional/{parameter},POST:/main"
  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
        desc: Internal server error
        detail: Unknown 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]

    job_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - example: 0468ca85-f6ca-4841-b30c-5ccc26b6f397
        - description: Job ID.

    workflow_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - example: 0468ca85-f6ca-4841-b30c-5ccc26b6f397
        - description: Workflow ID.

    job_id_response:
      type: object
      properties:
        job_id:
          $ref: '#/components/schemas/job_id'
      description: Response with job ID.
      required: [job_id]

    workflow_id_response:
      type: object
      properties:
        workflow_id:
          $ref: '#/components/schemas/workflow_id'
        job_id:
          $ref: '#/components/schemas/job_id'
      description: Response with workflow ID and job ID if job creation was not disabled.
      required: [workflow_id]

    _version:
      type: integer
      minimum: 0
      example: 5

    lambda_version:
      allOf:
      - $ref: '#/components/schemas/_version'
      - description: |
          Lambda version.

          The lambda version is incremented after each lambda recreation ([PUT request](#tag/lambdas-creation/operation/putLambda)).

    workflow_version:
      allOf:
      - $ref: '#/components/schemas/_version'
      - description: |
          Workflow version.

          The workflow version is incremented after each workflow recreation ([PUT request](#tag/workflows-creation/operation/putWorkflow)).

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

    workflow_version_response:
      type: object
      properties:
        version:
          $ref: '#/components/schemas/workflow_version'
      description: Response with workflow version.
      required: [ version ]

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

    job_name:
      type: string
      description: Job name.
      example: first-job

    workflow_name:
      type: string
      description: Workflow name. Each user can create only workflows with unique names.
      example: first-workflow

    _type_agent:
      type: string
      enum: [agent]
      example: agent

    lambda_type_agent:
      allOf:
      - $ref: '#/components/schemas/_type_agent'
      description: Lambda type.

    job_type_agent:
      allOf:
      - $ref: '#/components/schemas/_type_agent'
      - description: Job type.

    workflow_type_agent:
      allOf:
      - $ref: '#/components/schemas/_type_agent'
      - description: Workflow type.

    _type_default_params:
      type: string
      example: standalone
      default: "standalone"

    lambda_type_default_params:
      allOf:
      - enum: [standalone, handlers, tasks]
      - $ref: '#/components/schemas/_type_default_params'
      - description: Lambda type.

    job_type_default_params:
      allOf:
      - enum: [standalone]
      - $ref: '#/components/schemas/_type_default_params'
      - description: Job type.

    workflow_type_default_params:
      allOf:
      - enum: [standalone]
      - $ref: '#/components/schemas/_type_default_params'
      - description: Workflow type.

    _type:
      type: string
      example: standalone
      default: "standalone"

    lambda_type:
      allOf:
      - $ref: '#/components/schemas/_type'
      - enum: [standalone, handlers, tasks, agent]
      - description: Lambda type.

    job_type:
      allOf:
      - $ref: '#/components/schemas/_type'
      - enum: [standalone, agent]
      - description: Job type.

    workflow_type:
      allOf:
      - $ref: '#/components/schemas/_type'
      - enum: [standalone, agent]
      - description: Workflow type.

    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"

    _service_launch:
      type: integer
      enum: [0, 1]
      default: 0

    service_launch:
      allOf:
      - $ref: '#/components/schemas/_service_launch'
      - description: |
          Whether to execute a service job that will be terminated and permanently disabled upon successful completion. 
          This job is intended to verify baseline system functionality and/or confirm the successful registration 
          of the video analytics by agent.

          **WARNING**: This parameter will be excluded from inheritance during following [job creation](#tag/jobs-creation/operation/createJob)

          **WARNING**: Will be ignored during *workflow* creation if workflow *disabled* is set for *deploy_parameters*. 

    service_launch_for_job:
      allOf:
      - $ref: '#/components/schemas/_service_launch'
      - description: |
          Whether to execute a service job that will be terminated and permanently disabled upon successful completion. 
          This job is intended to verify baseline system functionality and/or confirm the successful registration 
          of the video analytics by agent.

    _status:
      type: string
      enum: [running, waiting, terminated, not_found, pending]
      example: running

    lambda_status:
      allOf:
      - $ref: '#/components/schemas/_status'
      - description: |
          Lambda status.
  
          | Status     | Description                                             |
          |------------|---------------------------------------------------------|
          | running    | Lambda is 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 is 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 are no suitable conditions for such lambda. For example, lambda requires GPU and Kubernetes cluster cannot provide GPU for lambda.

    job_status:
      allOf:
      - $ref: '#/components/schemas/_status'
      - description: |
          Job status.
  
          | Status     | Description                                        |
          |------------|----------------------------------------------------|
          | running    | Job is running and ready to process requests.      |
          | waiting    | Waiting for job start or job creation in progress. |
          | terminated | Job stopped and will be removed in the near future.|
          | not_found  | Job not found.                                     |
          | pending    | Job waiting for suitable conditions.               |
  
          The `running` status is returned when at least one pod in job replicas pods is running or when there is only one job pod and it is running.
  
          The `waiting` status is also returned when all pods in the job replicas have been created but are still starting up.
  
          * If job status is pending, it means that there are no suitable conditions for such job. For example, job requires GPU and Kubernetes cluster cannot provide GPU for job.

    _status_response:
      type: object
      properties:
        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 pods is in `running` status.

    lambda_status_response:
      allOf:
      - $ref: '#/components/schemas/_status_response'
      - properties:
          status:
            allOf:
              - $ref: '#/components/schemas/lambda_status'
        description: |
          Response with lambda status.
      required: [status]

    _description:
      type: string
      example: very useful service
      maxLength: 256
      default: ""

    lambda_description:
      allOf:
      - $ref: '#/components/schemas/_description'
      - description: Lambda description.

    job_description:
      allOf:
      - $ref: '#/components/schemas/_description'
      - description: Job description.

    workflow_description:
      allOf:
      - $ref: '#/components/schemas/_description'
      - description: Workflow description.

    _description_no_default:
      type: string
      example: very useful service
      maxLength: 256

    lambda_description_no_default:
      allOf:
      - $ref: '#/components/schemas/_description_no_default'
      - description: Lambda description.

    workflow_description_no_default:
      allOf:
      - $ref: '#/components/schemas/_description_no_default'
      - description: Workflow description.

    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
        pod_count:
          allOf:
            - $ref: '#/components/schemas/lambda_non_default_pod_count'
            - type: integer
              minimum: 0
          description: |
            Count of lambda pods.
            
            > **WARNING**: If pod_count = 0, lambda will not work.
      minProperties: 1

    workflow_patch:
      type: object
      description: Workflow patch data.
      properties:
        workflow_name:
          $ref: '#/components/schemas/workflow_name'
        description:
          $ref: '#/components/schemas/workflow_description'
      minProperties: 1

    user_docker_commands:
      type: array
      default: []
      items:
        type: string
      description: |
        List of additional user docker commands for container building (see development manual for details).
        
        For example, to use python library with libjpeg dependency, add the following list of commands 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 archive, in days. By default, parent bucket lifetime configuration is applied. For archive to be retained indefinitely, set `ttl=-1`.

    archive_ttl_reply:
      allOf:
        - $ref: '#/components/schemas/archive_ttl'
      description: Lifetime for archive, in days. By default, parent bucket lifetime configuration is 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

    lambda_base_image_name:
      allOf:
      - $ref: '#/components/schemas/_base_image_name'
      - 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 use `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.

    workflow_base_image_name:
      allOf:
      - $ref: '#/components/schemas/_base_image_name'
      - description: |
          Base image name for workflow docker container building (see development manual for details).
          
          The *standalone* workflows use `lpa-lambda-base` image by default.
          This image provides basic functionality for workflows.
          
          The *agent* workflows use `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 workflow.
          
          Other images must be inherited from one of above and require image tag specified.

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

    lambda_base_image_default:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/lambda_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 the latest available tag of the base lambda image.
      required: [name]

    workflow_base_image_default:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/workflow_base_image_name'
          enum: [lpa-lambda-base]
          default: lpa-lambda-base
        tag:
          allOf:
            - $ref: '#/components/schemas/base_image_tag'
          description: | 
            Base workflow image tag. See development manual for details.
            The default value is the latest available tag of the base workflow image.
      required: [name]

    lambda_base_image_fsdk:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/lambda_base_image_name'
          enum: [lpa-lambda-base-fsdk]
          default: lpa-lambda-base-fsdk
        tag:
          allOf:
            - $ref: '#/components/schemas/lambda_base_image_name'
          description: | 
            Base lambda image tag. See development manual for details.
            The default value is the latest available tag of the base lambda image.
      required: [name]

    workflow_base_image_fsdk:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/workflow_base_image_name'
          enum: [lpa-lambda-base-fsdk]
          default: lpa-lambda-base-fsdk
        tag:
          allOf:
            - $ref: '#/components/schemas/workflow_base_image_name'
          description: | 
            Base workflow image tag. See development manual for details.
            The default value is the latest available tag of the base workflow image.
      required: [name]

    lambda_base_image_agent:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/lambda_base_image_name'
          enum: [lpa-lambda-agent-base]
          default: lpa-lambda-agent-base
        tag:
          allOf:
            - $ref: '#/components/schemas/lambda_base_image_name'
          description: | 
            Base lambda agent image tag. See development manual for details.
            The default value is the latest available tag of the base lambda agent image.
      required: [name]

    workflow_base_image_agent:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/workflow_base_image_name'
          enum: [lpa-lambda-agent-base]
          default: lpa-lambda-agent-base
        tag:
          allOf:
            - $ref: '#/components/schemas/workflow_base_image_name'
          description: | 
            Base workflow agent image tag. See development manual for details.
            The default value is the latest available tag of the base workflow agent image.
      required: [name]

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

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

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

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

    _non_default_pod_count:
      type: integer
      minimum: 1
      maximum: 32
      example: 2

    lambda_non_default_pod_count:
      allOf:
      - $ref: '#/components/schemas/_non_default_pod_count'
      - description: Count of lambda pods.

    lambda_pod_count:
      allOf:
        - $ref: '#/components/schemas/lambda_non_default_pod_count'
        - type: integer
          default: 1

    _enable_gpu:
      type: integer
      enum: [0, 1]
      default: 0

    lambda_enable_gpu:
      allOf:
      - $ref: '#/components/schemas/_enable_gpu'
      - description: |
          Whether to enable GPU usage for lambda.
          See development manual for lambda GPU usage details.

    job_enable_gpu:
      allOf:
      - $ref: '#/components/schemas/_enable_gpu'
      - description: |
          Whether to enable GPU usage for job.
          See development manual for job GPU usage details.

    workflow_enable_gpu:
      allOf:
      - $ref: '#/components/schemas/_enable_gpu'
      - description: |
          Whether to enable GPU usage for workflow and jobs created within it.
          See development manual for workflow GPU usage details.

    resources:
      type: object
      properties:
        cpu_limit:
          $ref: '#/components/schemas/cpu_limit'
        gpu_limit:
          $ref: '#/components/schemas/gpu_limit_request'
        ram_limit:
          $ref: '#/components/schemas/ram_limit'
        cpu_request:
          $ref: '#/components/schemas/cpu_request'
        ram_request:
          $ref: '#/components/schemas/ram_request'
      description: Resource requests and limits.

    resources_required:
      type: object
      properties:
        cpu_limit:
          $ref: '#/components/schemas/cpu_limit'
        gpu_limit:
          $ref: '#/components/schemas/gpu_limit_response'
        ram_limit:
          $ref: '#/components/schemas/ram_limit'
        cpu_request:
          $ref: '#/components/schemas/cpu_request'
        ram_request:
          $ref: '#/components/schemas/ram_request'
      description: Resource requests and limits.
      required: [cpu_limit, gpu_limit, ram_limit, cpu_request, ram_request]

    cpu_limit:
      type: integer
      default: 1000
      description: CPU resource units limit for each pod. 1 unit means 1/1000 of a CPU core.

    gpu_limit_request:
      type: integer
      minimum: 0
      description: |
        Maximum number of GPUs used by each pod.
        If `enable_gpu=1`, the value should be >=1, default is 1.
        Otherwise the value should be 0, default is 0.

    gpu_limit_response:
      type: integer
      minimum: 0
      description: Maximum number of GPUs used by each pod.

    ram_limit:
      type: integer
      default: 1
      description: Maximum RAM usage limit in GB by each pod.

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

    ram_request:
      type: integer
      default: 1
      description: RAM usage request in GB by each pod. Same as limit if not specified.

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

    lambda_gpu_enabled:
      allOf:
      - $ref: '#/components/schemas/_gpu_enabled'
      - description: |
          Whether GPU is enabled for lambda.
          See development manual for lambda GPU usage details.

    job_gpu_enabled:
      allOf:
      - $ref: '#/components/schemas/_gpu_enabled'
      - description: |
          Whether GPU is enabled for job.
          See development manual for job GPU usage details.

    workflow_gpu_enabled:
      allOf:
      - $ref: '#/components/schemas/_gpu_enabled'
      - description: |
          Whether GPU is enabled for jobs created within the framework of workflow.
          See development manual for workflow GPU usage details.

    lambda_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/lambda_base_image_default'
      - $ref: '#/components/schemas/lambda_base_image_fsdk'
      - $ref: '#/components/schemas/lambda_base_image_agent'
      - $ref: '#/components/schemas/lambda_base_image_custom'
      discriminator:
        propertyName: name
        mapping:
          lpa-lambda-base: '#/components/schemas/lambda_base_image_default'
          lpa-lambda-base-fsdk: '#/components/schemas/lambda_base_image_fsdk'
          lpa-lambda-agent-base: '#/components/schemas/lambda_base_image_agent'
          custom: '#/components/schemas/lambda_base_image_custom'

    workflow_base_image:
      description: |
        Base image for workflow.
        
        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/workflow_base_image_default'
      - $ref: '#/components/schemas/workflow_base_image_fsdk'
      - $ref: '#/components/schemas/workflow_base_image_agent'
      - $ref: '#/components/schemas/workflow_base_image_custom'
      discriminator:
        propertyName: name
        mapping:
          lpa-lambda-base: '#/components/schemas/workflow_base_image_default'
          lpa-lambda-base-fsdk: '#/components/schemas/workflow_base_image_fsdk'
          lpa-lambda-agent-base: '#/components/schemas/workflow_base_image_agent'
          custom: '#/components/schemas/workflow_base_image_custom'

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

    workflow_base_image_reply:
      allOf:
        - $ref: '#/components/schemas/workflow_base_image_custom_nullable'
      description: Base image for jobs within the framework of workflow.

    lambda_deploy_parameters:
      type: object
      description: Deploy parameters for lambda.
      properties:
        enable_gpu:
          $ref: '#/components/schemas/lambda_enable_gpu'
        pod_count:
          $ref: '#/components/schemas/lambda_pod_count'
        resources:
          $ref: '#/components/schemas/resources'
        namespace:
          $ref: '#/components/schemas/namespace'
        selector:
          $ref: '#/components/schemas/selector'
        disabled:
          $ref: '#/components/schemas/lambda_disabled'
        check_resources:
          $ref: '#/components/schemas/check_resources'

    job_deploy_parameters:
      type: object
      description: Deploy parameters for job.
      properties:
        enable_gpu:
          $ref: '#/components/schemas/job_enable_gpu'
        resources:
          $ref: '#/components/schemas/resources'
        namespace:
          $ref: '#/components/schemas/namespace'
        selector:
          $ref: '#/components/schemas/selector'
        allow_insufficient_resources:
          $ref: '#/components/schemas/allow_insufficient_resources'
        service_launch:
          $ref: '#/components/schemas/service_launch_for_job'

    workflow_deploy_parameters:
      type: object
      description: Deploy parameters for workflow.
      properties:
        enable_gpu:
          $ref: '#/components/schemas/workflow_enable_gpu'
        resources:
          $ref: '#/components/schemas/resources'
        namespace:
          $ref: '#/components/schemas/namespace'
        selector:
          $ref: '#/components/schemas/selector'
        disabled:
          $ref: '#/components/schemas/workflow_disabled'
        service_launch:
          $ref: '#/components/schemas/service_launch'
        allow_insufficient_resources:
          $ref: '#/components/schemas/allow_insufficient_resources'

    lambda_deploy_parameters_reply:
      type: object
      description: Deploy parameters for lambda.
      properties:
        gpu_enabled:
          $ref: '#/components/schemas/lambda_gpu_enabled'
        pod_count:
          $ref: '#/components/schemas/lambda_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]

    job_deploy_parameters_reply:
      type: object
      description: Deploy parameters for job.
      properties:
        gpu_enabled:
          $ref: '#/components/schemas/job_gpu_enabled'
        resources:
          $ref: '#/components/schemas/resources_required'
        namespace:
          $ref: '#/components/schemas/namespace'
        selector:
          $ref: '#/components/schemas/selector'
        allow_insufficient_resources:
          $ref: '#/components/schemas/allow_insufficient_resources'
      required: [gpu_enabled, resources, namespace, selector, allow_insufficient_resources]

    workflow_deploy_parameters_reply:
      type: object
      description: Deploy parameters for workflow.
      properties:
        gpu_enabled:
          $ref: '#/components/schemas/workflow_gpu_enabled'
        resources:
          $ref: '#/components/schemas/resources_required'
        namespace:
          $ref: '#/components/schemas/namespace'
        selector:
          $ref: '#/components/schemas/selector'
        allow_insufficient_resources:
          $ref: '#/components/schemas/allow_insufficient_resources'
      required: [gpu_enabled, resources, namespace, selector, allow_insufficient_resources]

    _name_credentials:
      type: string
      minLength: 3
      maxLength: 36

    lambda_name_credentials:
      allOf:
      - $ref: '#/components/schemas/_name_credentials'
      - description: Lambda name.

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

    job_name_credentials:
      allOf:
      - $ref: '#/components/schemas/_name_credentials'
      - description: Job name.

    workflow_name_credentials:
      allOf:
      - $ref: '#/components/schemas/_name_credentials'
      - description: Workflow name.

    job_credentials:
      type: object
      description: Job credentials.
      properties:
        job_name:
          $ref: '#/components/schemas/job_name_credentials'
        description:
          $ref: '#/components/schemas/job_description'
      required: [job_name]

    workflow_credentials:
      type: object
      description: Workflow credentials.
      properties:
        workflow_name:
          $ref: '#/components/schemas/workflow_name_credentials'
        description:
          $ref: '#/components/schemas/workflow_description'
      required: [workflow_name]

    _common_parameters:
      type: object
      properties:
        image_builder:
          $ref: '#/components/schemas/image_builder'
        additional_user_docker_commands:
          $ref: '#/components/schemas/user_docker_commands'
        workers:
          $ref: '#/components/schemas/workers'
        archive_ttl:
          $ref: '#/components/schemas/archive_ttl'
        user_config:
          allOf:
            - $ref: '#/components/schemas/user_config'
            - default: null
            - nullable: true

    lambda_common_parameters:
      allOf:
        - $ref: '#/components/schemas/_common_parameters'
        - properties:
            base_image:
              $ref: '#/components/schemas/lambda_base_image'
            shared:
              $ref: '#/components/schemas/lambda_shared'
            eternal:
              $ref: '#/components/schemas/lambda_eternal'
        - description: | 
            Parameters for lambda.
            Content-Type must be "application/json".

    job_common_parameters:
      type: object
      properties:
        workers:
          $ref: '#/components/schemas/workers'
        user_config:
          allOf:
            - $ref: '#/components/schemas/user_config'
            - default: null
            - nullable: true
        shared:
          $ref: '#/components/schemas/job_shared'
        eternal:
          $ref: '#/components/schemas/job_eternal'
      description: | 
        Parameters for job.
        Content-Type must be "application/json".

    workflow_common_parameters:
      allOf:
      - $ref: '#/components/schemas/_common_parameters'
      - properties:
          base_image:
            $ref: '#/components/schemas/workflow_base_image'
          shared:
            $ref: '#/components/schemas/workflow_shared'
          eternal:
            $ref: '#/components/schemas/workflow_eternal'
      - description: | 
          Parameters for workflow.
          Content-Type must be "application/json".

    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:
        - title: lambda agent parameters
        - 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'

    job_agent_parameters:
      allOf:
        - title: job agent parameters
        - properties:
            job_type:
              $ref: '#/components/schemas/job_type_agent'
            external_agent:
              $ref: '#/components/schemas/external_agent'
            agent_credentials:
              $ref: '#/components/schemas/agent_credentials'
        - $ref: '#/components/schemas/job_common_parameters'

    workflow_agent_parameters:
      allOf:
        - title: workflow agent parameters
        - properties:
            workflow_type:
              $ref: '#/components/schemas/workflow_type_agent'
            external_agent:
              $ref: '#/components/schemas/external_agent'
            agent_credentials:
              $ref: '#/components/schemas/agent_credentials'
        - $ref: '#/components/schemas/workflow_common_parameters'

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

    job_standard_params:
      allOf:
        - title: job parameters
        - properties:
            job_type:
              $ref: '#/components/schemas/job_type_default_params'
        - $ref: '#/components/schemas/job_common_parameters'

    workflow_standard_params:
      allOf:
        - title: workflow parameters
        - properties:
            workflow_type:
              $ref: '#/components/schemas/workflow_type_default_params'
        - $ref: '#/components/schemas/workflow_common_parameters'

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

    job_parameters:
      oneOf:
        - $ref: '#/components/schemas/job_standard_params'
        - $ref: '#/components/schemas/job_agent_parameters'

    workflow_parameters:
      oneOf:
        - $ref: '#/components/schemas/workflow_standard_params'
        - $ref: '#/components/schemas/workflow_agent_parameters'

    lambda_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/lambda_description_no_default'

    workflow_import_credentials:
      type: object
      description: | 
        Workflow credentials.
        
        **Note: this field will overwrite credentials from archive.**
      properties:
        workflow_name:
          $ref: '#/components/schemas/workflow_name_credentials'
        description:
          $ref: '#/components/schemas/workflow_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/lambda_credentials'
            - description: |
                Lambda credentials.
                Content-Type must be "application/json".
        parameters:
          $ref: '#/components/schemas/lambda_parameters'
        deploy_parameters:
          allOf:
           - $ref: '#/components/schemas/lambda_deploy_parameters'
           - description: Deploy parameters for lambda. Content-Type must be "application/json".
      description: Lambda multipart content with archive file.
      required: [ archive, credentials ]

    job_multipart_content-archive_file:
      type: object
      properties:
        credentials:
          allOf:
            - $ref: '#/components/schemas/job_credentials'
            - description: |
                Job credentials.
                Content-Type must be "application/json".
        parameters:
          $ref: '#/components/schemas/job_parameters'
        deploy_parameters:
          allOf:
           - $ref: '#/components/schemas/job_deploy_parameters'
           - description: Deploy parameters for job. Content-Type must be "application/json".
      description: Job multipart content.
      required: [credentials]

    workflow_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/workflow_credentials'
            - description: |
                Workflow credentials.
                Content-Type must be "application/json".
        parameters:
          $ref: '#/components/schemas/workflow_parameters'
        deploy_parameters:
          allOf:
           - $ref: '#/components/schemas/workflow_deploy_parameters'
           - description: Deploy parameters for workflow jobs. Content-Type must be "application/json".
      description: Workflow multipart content with archive file.
      required: [ archive, credentials ]

    _parameters:
      type: object
      properties:
        workers:
          $ref: '#/components/schemas/workers_no_default'
        archive_ttl:
          $ref: '#/components/schemas/archive_ttl'
        user_config:
          $ref: '#/components/schemas/user_config'
        shared:
          $ref: '#/components/schemas/lambda_shared'
        eternal:
          $ref: '#/components/schemas/lambda_eternal'

    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/lambda_import_credentials'
        parameters:
          allOf:
          - $ref: '#/components/schemas/_parameters'
          - description: | 
              Parameters for lambda.
              Content-Type must be "application/json".
              
              **Note: this field will overwrite parameters from archive.**
        deploy_parameters:
          allOf:
            - $ref: '#/components/schemas/lambda_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]

    workflow_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/workflow_import_credentials'
        parameters:
          allOf:
          - $ref: '#/components/schemas/_parameters'
          - description: | 
              Parameters for workflow.
              Content-Type must be "application/json".
              
              **Note: this field will overwrite parameters from archive.**
        deploy_parameters:
          allOf:
            - $ref: '#/components/schemas/workflow_deploy_parameters'
          description: | 
            Deploy parameters for workflow. Content-Type must be "application/json".
            
            **Note: this field will overwrite deploy parameters from archive.**
      description: Workflow 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/lambda_description'
          required: [lambda_name]
        parameters:
          type: object
          description: Parameters for lambda.
          properties:
            lambda_type:
              $ref: '#/components/schemas/lambda_type'
            workers:
              $ref: '#/components/schemas/workers'
            shared:
              $ref: '#/components/schemas/lambda_shared'
            eternal:
              $ref: '#/components/schemas/lambda_eternal'
        deploy_parameters:
          $ref: '#/components/schemas/lambda_deploy_parameters'
      required: [ import_image, credentials ]

    job_import_json:
      type: object
      properties:
        credentials:
          type: object
          description: Job credentials.
          properties:
            job_name:
              type: string
              minLength: 3
              maxLength: 36
              description: Job name.
            description:
              $ref: '#/components/schemas/job_description'
          required: [job_name]
        parameters:
          type: object
          description: Parameters for job.
          properties:
            job_type:
              $ref: '#/components/schemas/job_type'
            workers:
              $ref: '#/components/schemas/workers'
            shared:
              $ref: '#/components/schemas/job_shared'
            eternal:
              $ref: '#/components/schemas/job_eternal'
        deploy_parameters:
          $ref: '#/components/schemas/job_deploy_parameters'
      required: [credentials]

    workflow_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-job-c52079ba-43db-4484-90f3-d349f9518a73
          description: Workflow image.
          required: [name]
        credentials:
          type: object
          description: Workflow credentials.
          properties:
            workflow_name:
              type: string
              minLength: 3
              maxLength: 36
              description: Workflow name.
            description:
              $ref: '#/components/schemas/workflow_description'
          required: [workflow_name]
        parameters:
          type: object
          description: Parameters for workflow.
          properties:
            workflow_type:
              $ref: '#/components/schemas/workflow_type'
            workers:
              $ref: '#/components/schemas/workers'
            shared:
              $ref: '#/components/schemas/workflow_shared'
            eternal:
              $ref: '#/components/schemas/workflow_eternal'
        deploy_parameters:
          $ref: '#/components/schemas/workflow_deploy_parameters'
      required: [ import_image, credentials ]

    common_lambda:
      type: object
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'
        lambda_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - description: Lambda ID.
        lambda_name:
          $ref: '#/components/schemas/lambda_name'
        description:
          $ref: '#/components/schemas/lambda_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/lambda_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/lambda_deploy_parameters_reply'
        shared:
          $ref: '#/components/schemas/lambda_shared'
        eternal:
          $ref: '#/components/schemas/lambda_eternal'
        last_usage:
          allOf:
            - $ref: "#/components/schemas/time"
            - format: date-time
            - nullable: true
          description: |
            The time of last lambda activity.
            Non-eternal lambdas which are not used for some time (according to `LUNA_LAMBDA_INACTIVE_LAMBDA_CLEAR_INTERVAL` setting)
            will be disabled.
            For more information about inactive lambdas disabling, see developers documentation.
        alive:
          $ref: '#/components/schemas/lambda_alive'

    _job_data_current:
      type: object
      description: Current job data.

    _job_data_overall:
      type: object
      description: Overall job data from all job executions.

    standalone_data:
      type: object
      properties:
        requests_count:
          type: object
          description: Requests data
          properties:
            all:
              type: integer
              description: total number of requests made to `/main` route.
              min: 0
            success:
              type: integer
              description: number of successful requests to `/main` route.
              min: 0
            failed:
              type: integer
              description: number of failed requests to `/main` route.
              min: 0
            in_progress:
              type: integer
              description: number of in progress requests to `/main` route.
              min: 0
          required: [all, success, failed, in_progress]
      required: [requests_count]

    agent_data:
      type: object
      properties:
        stream_count:
          type: object
          description: Streams data.
          properties:
            count:
              type: integer
              description: total number of accepted streams.
              min: 0
            success:
              type: integer
              description: number of successfully processed streams.
              min: 0
            failed:
              type: integer
              description: number of failed streams.
              min: 0
            in_progress:
              type: integer
              description: number of streams currently in progress.
              min: 0
          required: [count, success, failed, in_progress]
      required: [stream_count]

    standalone_data_current:
      allOf:
        - $ref: '#/components/schemas/standalone_data'
        - $ref: '#/components/schemas/_job_data_current'

    agent_data_current:
      allOf:
        - $ref: '#/components/schemas/agent_data'
        - $ref: '#/components/schemas/_job_data_current'

    standalone_data_overall:
      allOf:
        - $ref: '#/components/schemas/standalone_data'
        - $ref: '#/components/schemas/_job_data_overall'

    agent_data_overall:
      allOf:
        - $ref: '#/components/schemas/agent_data'
        - $ref: '#/components/schemas/_job_data_overall'

    workflow_info:
      type: object
      description: Workflow information.
      properties:
        status:
          $ref: '#/components/schemas/_image_creation_status'
      required: [status]

    common_workflow:
      type: object
      properties:
        workflow_id:
          $ref: '#/components/schemas/workflow_id'
        account_id:
          $ref: '#/components/schemas/account_id'
        workflow_name:
          $ref: '#/components/schemas/workflow_name'
        description:
          $ref: '#/components/schemas/workflow_description'
        version:
          $ref: '#/components/schemas/workflow_version'
        create_time:
          allOf:
            - $ref: "#/components/schemas/time"
            - format: date-time
          description: Time of the workflow creation.
        last_update_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: Date and time with timezone of last action with workflow.
        additional_user_docker_commands:
          $ref: '#/components/schemas/user_docker_commands'
        base_image:
          $ref: '#/components/schemas/workflow_base_image_reply'
        imported_image:
          type: object
          description: |
            Image that workflow was created from.
            
            It will appears after image will be created.
          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/workflow_deploy_parameters_reply'
        shared:
          $ref: '#/components/schemas/workflow_shared'
        eternal:
          $ref: '#/components/schemas/workflow_eternal'
        info:
          $ref: '#/components/schemas/workflow_info'

    execution_errors:
      type: array
      description: |
        Supplementary information about job execution errors.
      items:
        type: string

    job_last_execution_status:
      type: string
      enum: [pending, running_partial, completed, insufficient_resources, failed]
      description: |
        Last execution status of the job in the rotation queue.

        | status                 | description                                      |
        |------------------------|--------------------------------------------------|
        | pending                | job has not been executed yet                    |
        | running_partial        | job ran but did not complete; requeued           |
        | completed              | job completed successfully                       |
        | insufficient_resources | job failed due to insufficient cluster resources |
        | failed                 | job failed                                       |

    job_comprehensive_status_standalone:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/job_status'
        last_execution_status:
          $ref: '#/components/schemas/job_last_execution_status'
        current_data:
          allOf:
            - $ref: '#/components/schemas/standalone_data_current'
          description: Current job data.
        overall_data:
          allOf:
            - $ref: '#/components/schemas/standalone_data_overall'
          description: Overall job data.
        execution_errors:
          $ref: '#/components/schemas/execution_errors'
      description: Job status info.
      required: [ status, last_execution_status ]

    job_comprehensive_status_agent:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/job_status'
        last_execution_status:
          $ref: '#/components/schemas/job_last_execution_status'
        current_data:
          allOf:
            - $ref: '#/components/schemas/agent_data_current'
          description: Current job data.
        overall_data:
          allOf:
            - $ref: '#/components/schemas/agent_data_overall'
          description: Overall job data.
        execution_errors:
          $ref: '#/components/schemas/execution_errors'
      description: Job status info.
      required: [ status, last_execution_status ]

    common_job:
      type: object
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'
        job_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - description: Job ID.
        job_name:
          $ref: '#/components/schemas/job_name'
        description:
          $ref: '#/components/schemas/job_description'
        create_time:
          allOf:
            - $ref: "#/components/schemas/time"
            - format: date-time
          description: Time of the job creation.
        last_update_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: Date and time with timezone of last action with job.
        workers:
          $ref: '#/components/schemas/workers'
        deploy_parameters:
          $ref: '#/components/schemas/job_deploy_parameters_reply'
        shared:
          $ref: '#/components/schemas/job_shared'
        eternal:
          $ref: '#/components/schemas/job_eternal'
        last_usage:
          allOf:
            - $ref: "#/components/schemas/time"
            - format: date-time
            - nullable: true
          description: |
            The time of last job activity.
            Non-eternal jobs which are not used for some time (according to `LUNA_LAMBDA_INACTIVE_JOB_CLEAR_INTERVAL` setting)
            will be disabled.
            For more information about inactive jobs disabling, see developers documentation.
        alive:
          $ref: '#/components/schemas/job_alive'
        imported_image:
          $ref: '#/components/schemas/job_imported_image'

    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, deploy_parameters, shared, alive, eternal, last_usage]

    job_default:
      allOf:
        - properties:
            job_type:
              $ref: '#/components/schemas/job_type_default_params'
            info:
              $ref: '#/components/schemas/job_comprehensive_status_standalone'
        - $ref: '#/components/schemas/common_job'
      required: [job_id, job_name, imported_image, info, create_time, last_update_time, account_id, description, job_type, workers, deploy_parameters, shared, alive, eternal, last_usage]

    workflow_default:
      allOf:
        - properties:
            workflow_type:
              $ref: '#/components/schemas/workflow_type_default_params'
        - $ref: '#/components/schemas/common_workflow'
      required: [workflow_id, workflow_name, imported_image, version, info, create_time, last_update_time, account_id, description, workflow_type, additional_user_docker_commands, base_image, workers, archive_ttl, deploy_parameters, shared, eternal]

    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
        - workers
        - archive_ttl
        - deploy_parameters
        - external_agent
        - shared
        - alive

    job_imported_image:
      type: object
      description: Image that job was created from.
      properties:
        name:
          type: string
          nullable: true
          description: Image name.
        tag:
          type: string
          nullable: true
          description: Image tag.
      required: [ name, tag ]

    job_agent:
      allOf:
        - properties:
            job_type:
              $ref: '#/components/schemas/job_type_agent'
            external_agent:
              allOf:
                - $ref: '#/components/schemas/external_agent'
                - nullable: true
            info:
              $ref: '#/components/schemas/job_comprehensive_status_agent'
        - $ref: '#/components/schemas/common_job'
      required:
        - job_id
        - job_name
        - imported_image
        - info
        - create_time
        - last_update_time
        - account_id
        - description
        - job_type
        - workers
        - deploy_parameters
        - external_agent
        - shared
        - alive
        - eternal
        - last_usage

    workflow_agent:
      allOf:
        - properties:
            workflow_type:
              $ref: '#/components/schemas/workflow_type_agent'
            external_agent:
              allOf:
                - $ref: '#/components/schemas/external_agent'
                - nullable: true
        - $ref: '#/components/schemas/common_workflow'
      required:
        - workflow_id
        - workflow_name
        - external_agent
        - imported_image
        - version
        - info
        - create_time
        - last_update_time
        - account_id
        - description
        - workflow_type
        - additional_user_docker_commands
        - base_image
        - workers
        - archive_ttl
        - deploy_parameters
        - shared
        - eternal

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

    job:
      oneOf:
        - $ref: '#/components/schemas/job_default'
        - $ref: '#/components/schemas/job_agent'

    workflow:
      oneOf:
        - $ref: '#/components/schemas/workflow_default'
        - $ref: '#/components/schemas/workflow_agent'

    _image_creation_status:
      type: string
      enum: [ not_found, in_progress, error, pending, completed ]
      description: |
        Image creation status
        
        | Status      | Description                                                                   |
        |-------------|-------------------------------------------------------------------------------|
        | in_progress | Image creation in progress                                                    |
        | error       | An error occurred during image creation                                       |
        | completed   | Image creation completed                                                      |
        | not_found   | Image creation complete and luna-builder cleaned up or it never was           |
        | pending     | Image creation waiting for suitable conditions                                |

    image_creation_status:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/_image_creation_status'
      required: [status]

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

    lambda_logs:
      allOf:
      - $ref: '#/components/schemas/_logs'
      - description: Lambda logs.

    job_logs:
      allOf:
      - $ref: '#/components/schemas/_logs'
      - description: Job logs.

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

    workflow_image_logs:
      type: object
      properties:
        logs:
          type: array
          items:
            type: string
          description: Workflow log strings.
      description: Workflow logs.
      required: [logs]

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

    workflow_validation_error_response:
      type: object
      properties:
        errors:
          type: array
          items:
            type: string
          description: Workflow validation errors.
          example: [ validation_error_one, validation_error_two ]
      description: Response of workflow 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 workers.

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

    _shared:
      type: integer
      enum: [ 0, 1 ]
      default: 0

    lambda_shared:
      allOf:
      - $ref: '#/components/schemas/_shared'
      - description: |
          Any user can have access to lambda.
          
          > **WARNING**: Lambda with `lambda_type = agent` and `external_agent = 1`, can't be shared.

    job_shared:
      allOf:
      - $ref: '#/components/schemas/_shared'
      - description: |
          Any user can have access to job.
          
          > **WARNING**: Job with `job_type = agent` and `external_agent = 1`, can't be shared.

    workflow_shared:
      allOf:
      - $ref: '#/components/schemas/_shared'
      - description: |
          Whether any user can have access to workflow (jobs created within this workflow will also be shared).
          
          > **WARNING**: Workflow with `workflow_type = agent` and `external_agent = 1`, can't be shared.

    _eternal:
      type: integer
      enum: [ 0, 1 ]
      default: 0

    lambda_eternal:
      allOf:
      - $ref: '#/components/schemas/_eternal'
      - description: |
          If `enabled` (`1` is specified), lambda will run until it's manually stopped.
          Otherwise lambda may be disabled after some idling time according to `LUNA_LAMBDA_INACTIVE_LAMBDA_CLEAR_INTERVAL` setting.
          For more information about inactive lambdas disabling, see developers documentation.
  
          > **WARNING**: It is also required `LUNA_LAMBDA_METRICS_SETTINGS` to enable inactive lambdas clean disabling.

    job_eternal:
      allOf:
      - $ref: '#/components/schemas/_eternal'
      - description: |
          If `enabled` (`1` is specified), job will run until it's manually stopped.
          Otherwise job may be disabled after some idling time according to `LUNA_LAMBDA_INACTIVE_JOB_CLEAR_INTERVAL` setting.
          For more information about inactive jobs disabling, see developers documentation.
  
          > **WARNING**: It is also required `LUNA_LAMBDA_METRICS_SETTINGS` to enable inactive jobs clean disabling.

    workflow_eternal:
      allOf:
      - $ref: '#/components/schemas/_eternal'
      - description: |
          If `enabled` (`1` is specified), jobs created within the framework of workflow will run until they are manually stopped.
          Otherwise jobs may be disabled after some idling time according to `LUNA_LAMBDA_INACTIVE_JOB_CLEAR_INTERVAL` setting.
          For more information about inactive jobs disabling, see developers documentation.
  
          > **WARNING**: It is also required `LUNA_LAMBDA_METRICS_SETTINGS` to enable inactive jobs clean disabling.

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

    lambda_alive:
      allOf:
      - $ref: '#/components/schemas/_alive'
      - description: Sign of enabled/disabled lambda in Kubernetes.

    job_alive:
      allOf:
      - $ref: '#/components/schemas/_alive'
      - description: Sign of enabled/disabled job in Kubernetes.

    switch:
      type: string
      enum: [ disable, enable ]
      description: Action to choose.

    lambda_disabled:
      type: boolean
      default: false
      description: |
        Whether lambda must start in disabled state or not.
        
        If started in *disabled* state (*alive* field in [get lambda](#tag/lambda-monitoring/operation/getLambda)
        response) it is allowed to enable lambda using [lambda switch request](#tag/lambda-switch).

    workflow_disabled:
      type: boolean
      default: false
      description: |
        If disabled, no jobs will be created for this workflow automatically.

        If enabled, a new job will be created for this workflow automatically after image build.

    check_resources:
      type: boolean
      default: false
      description: |
        Whether to check available resources before creation.

    allow_insufficient_resources:
      type: integer
      enum: [0, 1]
      default: 0
      description: |
        Whether to allow job creation with insufficient resources.

    _switch:
      type: object
      properties:
        switch:
          $ref: '#/components/schemas/switch'
          example: disable
      required: [switch]

    lambda_switch:
      allOf:
      - $ref: '#/components/schemas/_switch'
      - description: Lambda switch data.

    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/job 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: Kubernetes 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 begin and end with an alphanumeric character `[a-z0-9A-Z]`
              - the name segment may contain dashes `-`, underscores `_`, dots `.`
              - the prefix is optional and 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/Job (inherited from workflow or manually specified) user config.
      additionalProperties:
        x-additionalPropertiesName: lambda/job unit service configuration
        description: |
          JSON containing service settings in format. Only string keys are allowed.
          ```json
          {
            "SETTING_1": "value",
            "SETTING_2": {"key": "value"},
          }
          ```
          
          > **WARNING**: For `agent` setting `max_stream_count` overwrites `max_active_streams` from configurator, configs or env if `max_stream_count` is positive integer.

    user_config_request:
      type: object
      properties:
        user_config:
          $ref: '#/components/schemas/user_config'
      required: [user_config]

    metrics_vector:
      type: object
      properties:
        resultType:
          type: string
          enum: [ "vector" ]
        result:
          type: array
          items:
            type: object
            properties:
              metric:
                type: object
                additionalProperties:
                  type: string
              value:
                type: array
                items:
                  - type: [ number, string ]
                  - type: string
                minItems: 2
                maxItems: 2
            description: Vector result.
            required: [ "metric", "value" ]
      required: [ "resultType", "result" ]

    metrics_matrix:
      type: object
      properties:
        resultType:
          type: string
          enum: [ "matrix" ]
        result:
          type: array
          items:
            type: object
            properties:
              metric:
                type: object
                additionalProperties:
                  type: string
              values:
                type: array
                items:
                  type: array
                  items:
                    - type: [ number, string ]
                    - type: string
                  minItems: 2
                  maxItems: 2
            description: Matrix result.
            required: [ "metric", "values" ]
      required: [ "resultType", "result" ]

    metrics_scalar:
      type: object
      properties:
        resultType:
          type: string
          enum: [ "scalar" ]
        result:
          type: array
          items:
            - type: [ number, string ]
            - type: string
          minItems: 2
          maxItems: 2
          description: Scalar result.
      required: [ "resultType", "result" ]


    metrics_string:
      type: object
      properties:
        resultType:
          type: string
          enum: [ "string" ]
        result:
          type: array
          items:
            - type: [ number, string ]
            - type: string
          minItems: 2
          maxItems: 2
          description: String result.
      required: [ "resultType", "result" ]

    metrics_success:
      type: object
      properties:
        data:
          description: Metrics from prometheus. Read more about format <a href="https://prometheus.io/docs/prometheus/latest/querying/api/#expression-query-result-formats">here</a>
          oneOf:
            - $ref: '#/components/schemas/metrics_matrix'
            - $ref: '#/components/schemas/metrics_vector'
            - $ref: '#/components/schemas/metrics_scalar'
            - $ref: '#/components/schemas/metrics_string'
          discriminator:
            propertyName: resultType
            mapping:
              matrix: '#/components/schemas/metrics_matrix'
              vector: '#/components/schemas/metrics_vector'
              scalar: '#/components/schemas/metrics_scalar'
              string: '#/components/schemas/metrics_string'
          required: [ "resultType", "result" ]
          additionalProperties: false
      required: [ "data" ]

    metrics_error:
      type: object
      description: Metrics request error.
      properties:
        error:
          type: string
          description: Metrics request error.
      required: [ "error" ]

    metrics:
      oneOf:
        - $ref: '#/components/schemas/metrics_success'
        - $ref: '#/components/schemas/metrics_error'

    default_namespace_limits:
      type: object
      description: Namespace resource limits.
      properties:
        cpu_limit:
          type: integer
          nullable: true
          description: CPU resource units limit for each pod. 1 unit means 1/1000 of CPU core.
        ram_limit:
          type: integer
          nullable: true
          description: Maximum RAM usage limit in GB by each pod.
        gpu_availability:
          type: boolean
          nullable: true
          description: Namespace GPU availability.
        labels:
          type: array
          items:
            type: string
          description: Namespace allowed labels.
      required: [ "labels", "gpu_availability", "ram_limit", "cpu_limit" ]

    namespace_limits:
      allOf:
        - $ref: '#/components/schemas/default_namespace_limits'
        - properties:
            namespace:
              type: string
              description: Namespace name.
      required: [ "namespace", "labels", "gpu_availability", "ram_limit", "cpu_limit" ]

    resources_response:
      type: object
      properties:
        default_namespace:
          $ref: '#/components/schemas/default_namespace_limits'
        allowed_namespaces:
          type: array
          description: Allowed namespace limits.
          items:
            $ref: '#/components/schemas/namespace_limits'
      required: [ "default_namespace", "allowed_namespaces" ]

    queue:
      type: object
      description: Job queue.
      properties:
        jobs:
          type: array
          items:
            type: object
            properties:
              job_id:
                $ref: '#/components/schemas/job_id'
              last_execution_status:
                $ref: '#/components/schemas/job_last_execution_status'
              queue_number:
                type: integer
                minimum: 0
                description: Number in queue.
                example: 1
            required: [job_id, last_execution_status]
      required: [jobs]
  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-42001"

    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-42016"

    workflow_not_ready:
      description: workflow not ready.
      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: 42041
            desc: Workflow is not ready
            detail: Workflow with id 'e63e2a1f-f505-441c-8e11-b2dcd0385329' image build didn't complete
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42041"

    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: error"
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42017"

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

    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"

    workflow_already_exists_by_name:
      description: workflow 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: 42026
            desc: Unique constraint error
            detail: 'Workflow with name good_workflow already exists'
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42026"

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

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

    job_not_running:
      description: job 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: 42034
            desc: Job isn't running
            detail: Job with id 'e63e2a1f-f505-441c-8e11-b2dcd0385329' isn't running
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42034"

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

    job_or_page_not_found:
      description: job 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:
            job_not_found:
              value:
                error_code: 42024
                desc: Object not found
                detail: Job with id 'e63e2a1f-f505-441c-8e11-b2dcd0385329' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42024"
            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"

    workflow_no_archive:
      description: archive for workflow 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: 42031
                desc: Object gone
                detail: Archive for workflow with id 'e63e2a1f-f505-441c-8e11-b2dcd0385329' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42031"
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'
  /2/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:
                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:
          description: Integrity error.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                lambda_already_exists_by_name:
                  value:
                    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"
                innuficient_resources:
                  value:
                    error_code: 42022
                    desc: Lambda resource allocation error
                    detail: 'Lambda deploy parameters in conflict with allowed resources. Low memory. Adjust configuration or deploy parameters to proceed'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42022"
        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'
  /2/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'
  /2/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:
                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. 
        
        Stops and removes lambda pod, deletes lambda archive from S3. There is also will be an attempt to remove lambda image from registry in background. 
        
        Note, that image can be deleted only if this feature enabled in registry.
        
        Failed or successful deletion attempt will be logged and saved to monitoring.

      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'
  /2/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'
  /2/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 product update may cause incompatibility with old lambdas. To make the old lambdas compatible with 
        actual product 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: 42012
                    desc: Object gone
                    detail: Archive for lambda with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42012"
        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'
  /2/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 `completed`. When the data disappears from luna-builder 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'
  /2/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'
  /2/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'
  /2/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"
        409:
          $ref: '#/components/responses/lambda_not_running'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/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'
        409:
          $ref: '#/components/responses/lambda_not_running'
        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: "Unsupported media type"
                    desc: "Bad/incomplete input data"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024"
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/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 used 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'
        409:
          $ref: '#/components/responses/lambda_not_running'
        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'
        409:
          $ref: '#/components/responses/lambda_not_running'
        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'
        409:
          $ref: '#/components/responses/lambda_not_running'
        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'
        409:
          $ref: '#/components/responses/lambda_not_running'
        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'
        409:
          $ref: '#/components/responses/lambda_not_running'
        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'
        409:
          $ref: '#/components/responses/lambda_not_running'
        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'
        409:
          $ref: '#/components/responses/lambda_not_running'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/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'
  /2/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'  
  /2/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'
        409:
          $ref: '#/components/responses/lambda_not_running'
        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'
        409:
          $ref: '#/components/responses/lambda_not_running'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/lambdas/{lambda_id}/metrics:
    parameters:
      - in: path
        name: lambda_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: ID of the lambda.

    get:
      tags:
        - lambda metrics
      summary: get lambda metrics
      description: Get lambda metrics
      operationId: getLambdaMetrics
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/metrics'
        - $ref: '#/components/parameters/resources'
      responses:
        200:
          description: Export success
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metrics'
              example:
                data:
                  resultType: vector
                  result:
                    - metric:
                        __name__: requests_count
                        lambda_id: 03261244-d9cd-4c06-a9a3-2f6bf77d03be
                        path: 'POST:/main'
                        service: luna-lambda-unit
                        status_code: '201'
                      value:
                        - 1758279288.092
                        - '1'
                    - metric:
                        __name__: requests_sum
                        lambda_id: 03261244-d9cd-4c06-a9a3-2f6bf77d03be
                        path: 'POST:/main'
                        service: luna-lambda-unit
                        status_code: '201'
                      value:
                        - 1758279288.092
                        - '0.0007713570012128912'
        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:
                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/forbidden_resource_error'
        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'
  /2/lambdas/{lambda_id}/switch:
    parameters:
    - in: path
      name: lambda_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the lambda.

    patch:
      tags:
        - lambda switch
      summary: switch lambda
      description: |
        Enable/disable lambda.
      operationId: switchLambda
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/header_account_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/lambda_switch'
      responses:
        200:
          description: Disable lambda success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        202:
          description: Enabled lambda success.
          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:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
        404:
          $ref: '#/components/responses/lambda_not_found'
        409:
          description: lambda is already disabled/enabled
          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:
                already_disabled:
                  value:
                    error_code: 42021
                    desc: Lambda alive error
                    detail: Lambda with id 'e63e2a1f-f505-441c-8e11-b2dcd0385329' is already disabled
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42021"
                already_enabled:
                  value:
                    error_code: 42021
                    desc: Lambda alive error
                    detail: Lambda with id 'e63e2a1f-f505-441c-8e11-b2dcd0385329' is already enabled
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42021"
        422:
          description: lambda status is incompatible
          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:
                not_running:
                  value:
                    error_code: 42009
                    desc: Unprocessable Content
                    detail: "Fail to access provided image: lambda-image-id"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42009"
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/lambdas/resources:
    get:
      tags:
        - lambda resources
      summary: lambda resource limits
      description: Lambda resource limits.
      operationId: getLambdaResources
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      responses:
        200:
          description: Get lambda resource limits.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/resources_response'
        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'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows:
    post:
      tags:
      - workflow creation
      summary: create workflow
      description: |
        Create new workflow. 
        
        Workflow creation assumes docker image creation | process can bee seen by 
        [workflow image monitoring](#tag/workflow-image-monitoring).

        Workflow creation optionally assumes job creation with default parameters after docker image creation.
        To enable job creation set *disabled* to *false* in *deploy_parameters* section.
        Job information will be avaiable using [job monitoring](#tag/job-monitoring) requests.
        
        Workflow can be created from imported image. In this case image creation stage will be skipped and workflow
        only will be registered (see *application/json* request body schema).
        See more about workflows and image import in developer manual.
        
        After workflow creation it is possible to create new jobs within created workflow using 
        [job creation](#tag/jobs-creation) request.
      operationId: createWorkflow
      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/workflow_multipart_content-archive_file'
          application/json:
            schema:
              $ref: '#/components/schemas/workflow_import_json'
        required: true
      responses:
        202:
          description: Workflow 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/workflows/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the workflow.
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/workflow_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:
                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 ''workflow_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 ''workflow_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/workflow_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:
      - workflow monitoring
      summary: get workflows
      description: Get workflows according to filters.
      operationId: getWorkflows
      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/workflow_type'
      - $ref: '#/components/parameters/workflow_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:
                  workflows:
                    description: workflows
                    type: array
                    items:
                      $ref: '#/components/schemas/workflow'
                    minItems: 0
                required: [workflows]
        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'
  /2/workflows/validator:
    post:
      tags:
      - workflow validator
      summary: workflow validation
      description: |
        Workflow validation.
        
        Workflow validation not guarantees hassle-free workflow's job creation and execution, but is an integral part of workflow
        creation process and allows you to make sure that the archive and its contents meet the requirements.
      operationId: validationWorkflow
      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 workflow.
                  properties:
                    workflow_type:
                      $ref: '#/components/schemas/workflow_type'
                  required: [workflow_type]
              required: [ archive, parameters ]
        required: true
      responses:
        204:
          description: Workflow validation success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Validate workflow 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/workflow_validation_error_response'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.

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

          - old workflow removing

          - stop all running and planned jobs within the framework of old workflow.

          - new workflow creation (the same process as described in the case of 
            [workflow creation](#tag/workflow-creation) request).

      operationId: putWorkflow
      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/workflow_multipart_content-archive_file'
          application/json:
            schema:
              $ref: '#/components/schemas/workflow_import_json'
        required: true
      responses:
        200:
          description: Workflow 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/workflows/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the workflow.
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/workflow_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:
                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 ''workflow_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 ''workflow_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:
          $ref: '#/components/responses/workflow_not_found'
        409:
          $ref: '#/components/responses/workflow_already_exists_by_name'
        500:
          $ref: '#/components/responses/internal_server_error'

    patch:
      tags:
      - workflow creation
      summary: patch workflow
      description: |
        Patch workflow. All existing job will not change
      operationId: patchWorkflow
      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/workflow_patch'
        required: true
      responses:
        204:
          description: Workflow 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:
          $ref: '#/components/responses/workflow_not_found'
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
      - workflow monitoring
      summary: get workflow
      description: Get workflow by ID.
      operationId: getWorkflow
      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/workflow'
        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:
          $ref: '#/components/responses/workflow_not_found'
        500:
          $ref: '#/components/responses/internal_server_error'

    head:
      tags:
      - workflow monitoring
      summary: check workflow existence
      description:  Check existence of the workflow by ID.
      operationId: checkWorkflow
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: Workflow 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:
          $ref: '#/components/responses/workflow_not_found'
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
      - workflow deletion
      summary: delete workflow
      description: Remove workflow by ID. 
        
        Stops and removes workflow and all its' jobs, deletes workflow archive from S3. 
        There is also will be an attempt to remove workflow image from registry in background.
        
        Note, that image can be deleted only if this feature enabled in registry.
        
        Failed or successful deletion attempt will be logged and saved to monitoring.

      operationId: deleteWorkflow
      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:
          $ref: '#/components/responses/workflow_not_found'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/image:
    parameters:
      - in: path
        name: workflow_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: ID of the workflow.

    get:
      tags:
        - workflow image
      summary: get workflow image
      description: Get workflow image.
      operationId: getWorkflowImage
      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: Workflow 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:
          $ref: '#/components/responses/workflow_not_found'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/image/status:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.

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

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

      operationId: getWorkflowImageStatus
      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:
          $ref: '#/components/responses/workflow_not_found'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/image/logs:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.

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

      operationId: getWorkflowImageCreationLogs
      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/workflow_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:
          $ref: '#/components/responses/workflow_not_found'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/export:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.

    get:
      tags:
      - workflow import/export
      summary: export workflow archive
      description: |
        Export archive with workflow and parameters.

        Exported archive may be used for workflow creation using 
        [workflow import](#tag/workflow-importexport/operation/importWorkflow) request.
      operationId: exportWorkflow
      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'
        404:
          $ref: '#/components/responses/workflow_not_found'
        410:
          $ref: '#/components/responses/workflow_no_archive'
        415:
          $ref: '#/components/responses/method_not_allowed'
        422:
          $ref: '#/components/responses/workflow_not_ready'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/import:
    post:
      tags:
      - workflow import/export
      summary: import workflow archive
      description: |
        Workflow creation using data from imported archive (Archive may be received by making 
        [workflow export](#tag/workflow-importexport/operation/exportWorkflow) request).

        After archive import it will execute the same process of workflow creation as described in the case of 
        [workflow creation](#tag/workflow-creation) request.
      operationId: importWorkflow
      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/workflow_multipart_import'
      responses:
        202:
          description: Success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /1/workflows/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the workflow.
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/workflow_id_response'
        400:
          $ref: '#/components/responses/workflow_failed_import_multipart'
        404:
          $ref: '#/components/responses/workflow_not_found'
        409:
          $ref: '#/components/responses/workflow_already_exists_by_name'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/jobs:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.

    post:
      tags:
      - jobs creation
      summary: create job
      description: |
        Create new job within a framework of specified workflow.
        
        It will use image created during workflow created as *imported_image*.

        All parameters (except for *service_launch* from *deploy_parameters*) which are not specified for job
        will be inherited from workflow.
        Parameters like `workflow_name`/`workflow_type` will be converted into `job_name`/`job_type` respectively.

        Workflow creation is available by using [workflow creation](#tag/workflow-creation) or 
        [workflow import](#tag/workflow-importexport/operation/importWorkflow) requests.

      operationId: createJob
      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/job_multipart_content-archive_file'
          application/json:
            schema:
              $ref: '#/components/schemas/job_import_json'
        required: false
      responses:
        202:
          description: Job 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/workflow/b5d6fd45-fcca-453d-ac05-3e594054b813/jobs/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the job.
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/job_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:
                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 ''job_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 ''job_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:
          $ref: '#/components/responses/workflow_not_found'
        409:
          $ref: '#/components/responses/workflow_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:
      - job monitoring
      summary: get jobs
      description: Get jobs according to filters.
      operationId: getJobs
      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/job_type'
      - $ref: '#/components/parameters/job_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
                description: Job list.
                properties:
                  jobs:
                    description: Job list.
                    type: array
                    items:
                      $ref: '#/components/schemas/job'
                    minItems: 0
                required: [jobs]
        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"
        404:
          $ref: '#/components/responses/workflow_not_found'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/jobs/{job_id}:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.
    - in: path
      name: job_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the job.

    get:
      tags:
      - job monitoring
      summary: get job
      description: Get job by ID.
      operationId: getJob
      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/job'
        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: Job 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: 42024
                desc: Object not found
                detail: Job with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42024"
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
      - jobs deletion
      summary: delete job
      description: Remove job by ID. 
      operationId: deleteJob
      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: Job 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: 42024
                desc: Object not found
                detail: Job with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42024"
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/jobs/{job_id}/logs:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.
    - in: path
      name: job_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the job.

    get:
      tags:
      - job monitoring
      summary: get job logs
      description: |
        Get job logs by ID.
        
        After job creation has been executed, there is possibility to get job logs.
        
        For more information about job and job images logs see development manual.
        
        Job logs will be available only while job is running, for more information about jobs see developers documentation.
      operationId: getJobLogs
      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/job_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: Job 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: 42024
                desc: Object not found
                detail: Job with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-42024"
        409:
          $ref: '#/components/responses/job_not_running'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/jobs/{job_id}/docs/spec:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.
    - in: path
      name: job_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the job.

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

        Job documentation will be available only while job is running, for more information about jobs see developers documentation.
      operationId: getJobSpec

      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/job_not_found'
        409:
          $ref: '#/components/responses/job_not_running'
        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: "Unsupported media type"
                    desc: "Bad/incomplete input data"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024"
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/jobs/{job_id}/proxy:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.
    - in: path
      name: job_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the job.
    - in: path
      name: path_parameters
      schema:
        type: string
        description: additional path parameters
        example: /main
      required: false
      description: any additional path parameter will be used as path parameter to job

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

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

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

        > **WARNING**: Job proxy requests will be avaiable only while job is running, 
        for more information about jobs see developers documentation.
      operationId: proxyJobPost
      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/job_or_page_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        409:
          $ref: '#/components/responses/job_not_running'
        500:
          $ref: '#/components/responses/internal_server_error'

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

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

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

        > **WARNING**: Job proxy requests will be avaiable only while job is running, 
        for more information about jobs see developers documentation.
      operationId: proxyJobGet
      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/job_or_page_not_found'
        409:
          $ref: '#/components/responses/job_not_running'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

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

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

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

        > **WARNING**: Job proxy requests will be avaiable only while job is running, 
        for more information about jobs see developers documentation.
      operationId: proxyJobHead
      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/job_or_page_not_found'
        409:
          $ref: '#/components/responses/job_not_running'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

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

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

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

        > **WARNING**: Job proxy requests will be avaiable only while job is running, 
        for more information about jobs see developers documentation.
      operationId: proxyJobPut
      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/job_or_page_not_found'
        409:
          $ref: '#/components/responses/job_not_running'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

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

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

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

        > **WARNING**: Job proxy requests will be avaiable only while job is running, 
        for more information about jobs see developers documentation.
      operationId: proxyJobPatch
      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/job_or_page_not_found'
        409:
          $ref: '#/components/responses/job_not_running'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

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

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

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

        > **WARNING**: Job proxy requests will be avaiable only while job is running, 
        for more information about jobs see developers documentation.
      operationId: proxyJobDelete
      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/job_or_page_not_found'
        409:
          $ref: '#/components/responses/job_not_running'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'

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

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

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

        > **WARNING**: Job proxy requests will be avaiable only while job is running, 
        for more information about jobs see developers documentation.
      operationId: proxyJobOptions
      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/job_or_page_not_found'
        409:
          $ref: '#/components/responses/job_not_running'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/jobs/{job_id}/config:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.
    - in: path
      name: job_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the job.

    get:
      tags:
        - job config
      summary: get job config
      description: |
        Get job user configuration

        > **WARNING**: Job configuration will be avaiable only while job is running, 
        for more information about jobs see developers documentation.
      operationId: getJobConfig
      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/job_not_found'
        409:
          $ref: '#/components/responses/job_not_running'
        415:
          $ref: '#/components/responses/method_not_allowed'
        422:
          $ref: '#/components/responses/job_not_running'
        500:
          $ref: '#/components/responses/internal_server_error'

    put:
      tags:
        - job config
      summary: update job config
      description: |
        Replace job user configuration

        > **WARNING**: Job configuration interaction will be avaiable only while job is running, 
        for more information about jobs see developers documentation.
      operationId: putJobConfig
      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/job_not_found'
        409:
          $ref: '#/components/responses/job_not_running'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/{workflow_id}/jobs/{job_id}/metrics:
    parameters:
    - in: path
      name: workflow_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the workflow.
    - in: path
      name: job_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the job.

    get:
      tags:
        - job metrics
      summary: get job metrics
      description: |
        Get job metrics

        > **WARNING**: Job metrics will be avaiable only while job is running, 
        for more information about jobs see developers documentation.
      operationId: getJobMetrics
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/metrics'
        - $ref: '#/components/parameters/resources'
      responses:
        200:
          description: Export success
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metrics'
              example:
                data:
                  resultType: vector
                  result:
                    - metric:
                        __name__: requests_count
                        job_id: 03261244-d9cd-4c06-a9a3-2f6bf77d03be
                        path: 'POST:/main'
                        service: luna-job-unit
                        status_code: '201'
                      value:
                        - 1758279288.092
                        - '1'
                    - metric:
                        __name__: requests_sum
                        job_id: 03261244-d9cd-4c06-a9a3-2f6bf77d03be
                        path: 'POST:/main'
                        service: luna-job-unit
                        status_code: '201'
                      value:
                        - 1758279288.092
                        - '0.0007713570012128912'
        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:
                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 ''job_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 ''job_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/forbidden_resource_error'
        404:
          $ref: '#/components/responses/job_not_found'
        415:
          $ref: '#/components/responses/method_not_allowed'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/workflows/queue:
    get:
      tags:
      - job queue
      summary: get job queue
      description: Get job queue according to filters.
      operationId: getJobQueue
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      - $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:
                $ref: '#/components/schemas/queue'
        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 'namespace'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/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
                    desc: 'Bad/incomplete input data'
                    detail: "Unsupported media type"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024"
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/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'
  /2/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: "Unsupported media type"
                    desc: "Bad/incomplete input data"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024"
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/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'
        - $ref: '#/components/parameters/account_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/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'