openapi: 3.1.0
info:
  version: v.0.4.0
  title: Luna Vinder Projector API
  description: Managing projections and their data.
paths:
  /1/projections:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
    post:
      tags:
        - projections
      summary: new projection
      description: Register a new projection
      operationId: addProjection
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/input_projection'
      responses:
        '201':
          description: OK
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  projection_id:
                    type: string
                required:
                  - projection_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:
                object_type:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: ''origin'',  message: ''origin should be one of [''events'']'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        '500':
          $ref: '#/components/responses/internal_server_error'
        '504':
          $ref: '#/components/responses/server_timeout_error'
    get:
      tags:
        - projections
      summary: get projections
      description: Get projections
      operationId: getProjections
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/page_size'
      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:
                  projections:
                    type: array
                    items:
                      $ref: '#/components/schemas/output_projection'
                required:
                  - projections
        '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:
                object_type:
                  value:
                    error_code: 12031
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate query parameters. Path: ''page'',  message: ''page should be a valid integer'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12031
        '500':
          $ref: '#/components/responses/internal_server_error'
        '504':
          $ref: '#/components/responses/server_timeout_error'
  /1/projections/{projection_id}:
    parameters:
      - in: path
        name: projection_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: projection ID (`projection_id` received in the "create projection" request).
      - $ref: '#/components/parameters/luna_request_id'
    get:
      tags:
        - projections
      summary: get projection
      description: Get projection by ID
      operationId: getProjection
      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:
                  projection:
                    $ref: '#/components/schemas/output_projection'
                required:
                  - projection
        '404':
          description: Projection not registered.
          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: 48001
                desc: Object not found
                detail: Projection with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not registered
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-48001
        '500':
          $ref: '#/components/responses/internal_server_error'
        '504':
          $ref: '#/components/responses/server_timeout_error'
    patch:
      tags:
        - projections
      summary: patch projection
      description: Update projection
      operationId: patchProjection
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/projection_patch'
      responses:
        '204':
          description: OK
          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:
                object_type:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: ''description'',  message: ''description should be a valid string'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        '404':
          description: Projection not registered.
          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: 48001
                desc: Object not found
                detail: Projection with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not registered
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-48001
        '500':
          $ref: '#/components/responses/internal_server_error'
        '504':
          $ref: '#/components/responses/server_timeout_error'
    delete:
      tags:
        - projections
      summary: remove projection
      description: Unregister projection
      operationId: removeProjection
      responses:
        '204':
          description: OK
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        '404':
          description: Projection not registered.
          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: 48001
                desc: Object not found
                detail: Projection with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not registered
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-48001
        '500':
          $ref: '#/components/responses/internal_server_error'
        '504':
          $ref: '#/components/responses/server_timeout_error'
  /version:
    get:
      tags:
        - version
      summary: get version
      description: get service version
      operationId: getVersion
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/version'
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/docs/spec:
    get:
      tags:
        - documents
      summary: get openapi documentation
      description: |
        Get service OpenApi documentation. If *Accept* request header is of type `application/x-yaml`,
        returns documentation in `yaml` format or returns `html` documentation, if *Accept-Type* is `text/html`
      operationId: getSpec
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - name: Accept
          in: header
          schema:
            type: string
            enum:
              - application/x-yaml
              - text/html
            description: One of application/x-yaml, text/html
          required: true
          description: acceptable type of receiving data
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              schema:
                type: string
                enum:
                  - application/x-yaml
                  - text/html
              required: true
              description: The content type of the response body.
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/x-yaml:
              schema:
                type: string
                description: yaml format documentation
            text/html:
              schema:
                type: string
                description: html format documentation
        '415':
          description: Unsupported Media Type
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                unsupported_media_type:
                  value:
                    error_code: 12024
                    detail: Bad/incomplete input data
                    desc: Unsupported media type
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/docs/dev:
    get:
      tags:
        - documents
      summary: get development manual
      description: |
        Get sphinx documentation - *Development Manual*. After the request you will be redirected to the page `/docs/dev/index.html`
      operationId: getDevManual
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/text_html'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            text/html:
              schema:
                type: string
                description: html format documentation
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/config:
    get:
      tags:
        - config
      summary: get service configuration
      description: Get service configuration. Passwords and tokens will be hidden in the response.
      operationId: getConfig
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - name: Accept
          in: header
          schema:
            type: string
            enum:
              - application/json
              - text/plain
            description: One of application/json, text/plain
          required: false
          description: acceptable type of receiving data
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              description: The content type of the response body.
              schema:
                type: string
                enum:
                  - application/json
                  - text/plain
              required: true
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                description: json format configuration
                additionalProperties: true
              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
            text/plain:
              schema:
                type: string
                description: text format configuration
              example: |
                [INFLUX_MONITORING]
                SEND_DATA_FOR_MONITORING = 0
                VERSION = 2
                ORGANIZATION = ORGANIZATION_NAME
                TOKEN = ********
                BUCKET = luna_monitoring
                HOST = 127.0.0.1
                PORT = 8086
                USE_SSL = 0
                FLUSHING_PERIOD = 1.0
        '415':
          description: Unsupported Media Type
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                unsupported_media_type:
                  value:
                    error_code: 12024
                    detail: Bad/incomplete input data
                    desc: Unsupported media type
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024
        '500':
          $ref: '#/components/responses/internal_server_error'
  /healthcheck:
    get:
      tags:
        - health
      summary: get health
      description: get health of service
      operationId: healthcheck
      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:
                description: Successful healthcheck execution info.
                type: object
                properties:
                  execution_time:
                    type: number
                    example: 0.123
                    description: Request execution time in seconds.
                required:
                  - execution_time
        '500':
          $ref: '#/components/responses/internal_server_error'
        '502':
          '504':
            $ref: ../../common/responses.yml#/server_timeout_error
          description: Unhealthy
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                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: db
                      error:
                        error_code: 38001
                        desc: Health check error
                        detail: Database connection timeout error
                        link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0
                      status: 0
  /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/parameters_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'
components:
  parameters:
    luna_request_id:
      in: header
      schema:
        type: string
        format: timestamp,uuid
        example: 1536751345,8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a
        pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
      description: request identifier.
      name: Luna-Request-Id
    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
        default: 1000
      description: the number of items on page.
  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
    text_html:
      schema:
        type: string
        enum:
          - text/html
      required: true
      description: The content type of the response body.
    parameters_luna_request_id:
      in: header
      schema:
        type: string
        format: timestamp,uuid
        example: 1536751345,8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a
        pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
      description: request identifier.
      name: Luna-Request-Id
  schemas:
    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
    face_descriptor_config:
      type: object
      properties:
        descriptor_type:
          enum:
            - face
          description: Descriptor type.
        descriptor_version:
          type: integer
          nullable: true
          default: null
          example: 65
          description: Platform-known face descriptor version. If the value is set to `null`, the Luna Platform's configured default will be used.
      required:
        - descriptor_type
    body_descriptor_config:
      type: object
      properties:
        descriptor_type:
          enum:
            - body
          description: Descriptor type.
        descriptor_version:
          type: integer
          nullable: true
          default: null
          example: 116
          description: Platform-known body descriptor version. If the value is set to `null`, the Luna Platform's configured default will be used.
      required:
        - descriptor_type
    event_input_projection:
      type: object
      properties:
        origin:
          enum:
            - events
          description: Projection origin.
        descriptors:
          oneOf:
            - $ref: '#/components/schemas/face_descriptor_config'
            - $ref: '#/components/schemas/body_descriptor_config'
          discriminator:
            propertyName: descriptor_type
            mapping:
              face: '#/components/schemas/face_descriptor_config'
              body: '#/components/schemas/body_descriptor_config'
          description: Projection descriptor config.
        params:
          type: object
          description: Projection parameters.
          properties:
            projection_type:
              enum:
                - view
            targets:
              type: array
              items:
                type: string
                enum:
                  - event_id
                  - account_id
                  - create_time
                  - end_time
                  - handler_id
                  - external_id
                  - stream_id
                  - source
                  - top_match
                  - match_result
                  - face_detections
                  - face_id
                  - attach_result
                  - gender
                  - age
                  - emotion
                  - ethnic_group
                  - liveness
                  - deepfake
                  - body_detections
                  - body_basic_attributes
                  - upper_body
                  - lower_body
                  - accessories
                  - tags
                  - user_data
                  - location
                  - mask
                  - track_id
                  - meta
              default:
                - event_id
            filters:
              type: object
              properties:
                account_id:
                  type: string
                  example: b668c4a5-2191-476e-a261-3b4f9ce2e25e
                  description: platform account ID
                event_ids:
                  type: array
                  items:
                    type: string
                  example:
                    - b668c4a5-2191-476e-a261-3b4f9ce2e25e
                  description: list of event IDs associated with face
                event_id__gte:
                  type: string
                  example: b668c4a5-2191-476e-a261-3b4f9ce2e25e
                  description: event ID lower included boundary
                event_id__lt:
                  type: string
                  example: b668c4a5-2191-476e-a261-3b4f9ce2e25e
                  description: event ID upper excluded boundary
                create_time__gte:
                  type: string
                  example: '2018-08-11T09:11:41.674Z'
                  description: event create time lower included boundary
                create_time__lt:
                  type: string
                  example: '2018-08-11T09:11:41.674Z'
                  description: event create time upper excluded boundary
                end_time__gte:
                  type: string
                  example: '2018-08-11T09:11:41.674Z'
                  description: event end time lower included boundary
                end_time__lt:
                  type: string
                  example: '2018-08-11T09:11:41.674Z'
                  description: event end time upper excluded boundary
                handler_ids:
                  type: array
                  items:
                    type: string
                  example:
                    - b668c4a5-2191-476e-a261-3b4f9ce2e25e
                  description: list of handler IDs. Each event from result will contain one of the given handler IDs
                external_ids:
                  type: array
                  items:
                    type: string
                  example:
                    - some_external_id
                  description: list of external IDs. Each event from result will contain one of the given external IDs
                top_matching_candidates_label:
                  type: string
                  example: good_guys
                  description: top matching candidate label
                top_similar_object_ids:
                  type: array
                  items:
                    type: string
                  example:
                    - b668c4a5-2191-476e-a261-3b4f9ce2e25e
                  description: list of top similar object IDs. Each event from result will contain one of the given similar object IDs
                top_similar_external_ids:
                  type: array
                  items:
                    type: string
                  example:
                    - some_external_id
                  description: list of top similar external IDs. Each event from result will contain one of the given similar external IDs
                top_similar_object_similarity__gte:
                  type: number
                  minimum: 0
                  maximum: 1
                  example: 0.8
                  description: top similar object similarity lower included bound
                top_similar_object_similarity__lt:
                  type: number
                  minimum: 0
                  maximum: 1
                  example: 1
                  description: top similar object similarity lower excluded bound
                age__gte:
                  type: integer
                  minimum: 0
                  maximum: 100
                  example: 33
                  description: age lower included bound
                age__lt:
                  type: integer
                  minimum: 0
                  maximum: 100
                  example: 33
                  description: age lower excluded bound
                gender:
                  enum:
                    - 0
                    - 1
                  example: 1
                  description: gender, 0 - female, 1 - male
                emotions:
                  type: array
                  items:
                    type: integer
                    nullable: true
                  example:
                    - 1
                    - 2
                    - 4
                  description: |
                    list of emotions. Each event from result will contain one of the given emotions.

                    | emotions    | value |
                    |-----------------|---|
                    | anger           | 1 |
                    | disgust         | 2 |
                    | fear            | 3 |
                    | happiness       | 4 |
                    | neutral         | 5 |
                    | sadness         | 6 |
                    | surprise        | 7 |
                masks:
                  type: array
                  items:
                    type: integer
                    nullable: true
                  example:
                    - 2
                    - 3
                  description: |
                    list of masks. Each event from result will contain one of the given mask states.

                    | masks      | value |
                    |----------------|---|
                    | missing        | 1 |
                    | medical_mask   | 2 |
                    | occluded       | 3 |
                liveness:
                  type: array
                  items:
                    type: integer
                    nullable: true
                  example:
                    - 1
                  description: |
                    list of liveness. Each event from result will contain one of the given liveness.

                    | liveness | value |
                    |--------------|---|
                    | spoof        | 0 |
                    | real         | 1 |
                    | unknown      | 2 |
                deepfake:
                  type: array
                  items:
                    type: integer
                    nullable: true
                  example:
                    - 1
                  description: |
                    list of deepfake. Each event from result will contain one of the given deepfake.

                    | deepfake | value |
                    |--------------|---|
                    | fake         | 0 |
                    | real         | 1 |
                ethnic_groups:
                  type: array
                  items:
                    type: integer
                    nullable: true
                  ecample:
                    - 2
                  description: |
                    list of ethnic group. Each event from result will contain one of the given ethnic groups.

                    | ethnicity   | value |
                    |-----------------|---|
                    | african_american | 1 |
                    | indian          | 2 |
                    | asian           | 3 |
                    | caucasian       | 4 |
                face_ids:
                  type: array
                  items:
                    type: string
                  example:
                    - b668c4a5-2191-476e-a261-3b4f9ce2e25e
                  description: list of face IDs
                user_data:
                  type: string
                  example:
                    - some_user_data
                  description: user data filter. Objects whose user_data values are not contain the filter will be filtered
                sources:
                  type: array
                  items:
                    type: string
                  example:
                    - some_source
                  description: list of sources. Each event from result will contain one of the given sources
                stream_ids:
                  type: array
                  items:
                    type: string
                  example:
                    - b668c4a5-2191-476e-a261-3b4f9ce2e25e
                  description: list of stream IDs. Each event from result will contain one of the given stream ID
                tags:
                  type: array
                  items:
                    type: string
                  example:
                    - some_tag
                  description: list of tags. Each event from result will contain one of the given tags
                cities:
                  type: array
                  items:
                    type: string
                  example:
                    - some_city
                  description: list of cities. Each event from result will contain one of the given cities in location
                areas:
                  type: array
                  items:
                    type: string
                  example:
                    - some_area
                  description: list of areas. Each event from result will contain one of the given areas in location
                districts:
                  type: array
                  items:
                    type: string
                  example:
                    - some_district
                  description: list of districts. Each event from result will contain one of the given districts in location
                streets:
                  type: array
                  items:
                    type: string
                  example:
                    - some_street
                  description: list of streets. Each event from result will contain one of the given streets in location
                house_numbers:
                  type: array
                  items:
                    type: string
                  example:
                    - some_number
                  description: list of house_numbers. Each event from result will contain one of the given house_numbers in location
                geo_position:
                  type: object
                  properties:
                    latitude_delta:
                      type: number
                      minimum: 0
                      maximum: 90
                    longitude_delta:
                      type: number
                      minimum: 0
                      maximum: 90
                    origin_latitude:
                      type: number
                      minimum: -90
                      maximum: 90
                    origin_longitude:
                      type: number
                      minimum: -180
                      maximum: 18090
                  description: |
                    geo position filter is a bounding box specified by coordinates of its center (origin) and some delta. WARNING: boxes with a vertex or border on the International Date Line (IDL) or the North or South pole are not fully supported due to features of database spatial index - filter result may be unexpected
                track_ids:
                  type: array
                  items:
                    type: string
                  example:
                    - b668c4a5-2191-476e-a261-3b4f9ce2e25e
                  description: list of track IDs. Each event from result will contain one of the given track IDs
                apparent_age__gte:
                  type: integer
                  minimum: 0
                  maximum: 100
                  example: 33
                  description: apparent age lower included bound
                apparent_age__lt:
                  type: integer
                  minimum: 0
                  maximum: 100
                  example: 38
                  description: apparent age upper included bound
                apparent_gender:
                  type: array
                  items:
                    enum:
                      - 0
                      - 1
                      - 2
                    nullable: true
                  example:
                    - 1
                  description: |
                    apparent gender filter: 0 - female, 1 - male, 2 - undefined. Each event from result will contain one of the given state
                headwear_states:
                  type: array
                  items:
                    type: integer
                    nullable: true
                  example:
                    - 1
                  description: |
                    headwear state filter: 0 - absent, 1 - present, 2 - undefined. Each event from result will contain one of the given states
                headwear_apparent_colors:
                  type: array
                  items:
                    enum:
                      - undefined
                      - black
                      - white
                      - other
                    nullable: true
                  example:
                    - black
                  description: headwear apparent color filter. Each event from result will contain one of the given states
                sleeve_lengths:
                  type: array
                  items:
                    enum:
                      - short
                      - long
                      - undefined
                    nullable: true
                  example:
                    - short
                  description: sleeve length state filter. Each event from result will contain one of the given state
                upper_clothing_colors:
                  type: array
                  items:
                    enum:
                      - undefined
                      - black
                      - blue
                      - green
                      - gray
                      - orange
                      - purple
                      - red
                      - white
                      - yellow
                      - pink
                      - brown
                      - beige
                      - khaki
                      - multicolored
                    nullable: true
                  example:
                    - black
                  description: upper clothing color filter. Each event from result will contain at least one of the given clothing colors
                backpack_states:
                  type: array
                  items:
                    type: integer
                    nullable: true
                  example:
                    - 1
                  description: |
                    backpack state filter: 0 - absent, 1 - present, 2 - undefined. Each event from result will contain one of the given states
                lower_garment_colors:
                  type: array
                  items:
                    enum:
                      - undefined
                      - black
                      - blue
                      - green
                      - gray
                      - orange
                      - purple
                      - red
                      - white
                      - yellow
                      - pink
                      - brown
                      - beige
                      - khaki
                      - multicolored
                    nullable: true
                  example:
                    - black
                  description: lower garment color filter. Each event from result will contain at least one of the given clothing colors
                lower_garment_types:
                  type: array
                  items:
                    enum:
                      - undefined
                      - trousers
                      - shorts
                      - skirt
                    nullable: true
                  example:
                    - trousers
                  description: lower garment type filter. Each event from result will contain one of the given states
                shoes_apparent_colors:
                  type: array
                  items:
                    enum:
                      - undefined
                      - black
                      - white
                      - other
                    nullable: true
                  example:
                    - black
                  description: shoes apparent color filter. Each event from result will contain one of the given states
                meta:
                  type: object
                  nullable: true
                  additionalProperties: true
                  description: |
                    User-defined event meta's filters.

                    Parameter name pattern: `path.to.field[__operator]`

                    Path to field is an event meta's json field path. To navigate through nested objects the dot (.) is used.

                    Field comparison **operator** is optional one of `eq` (default), `neq`, `like`, `nlike`, `in`, `nin`, `gt`, `gte`, `lt`, `lte`.

                    Please note importance of using correct types when filtering. For example, the following filter is not valid:
                    {"age__gt": 20.0} in case some of the metas contain `age` with datatype different from `number`.

                    Allowed usage of filters is:

                    |  operator  | type |        |         |         |
                    |------------|------|--------|---------|---------|
                    |            | none | string | integer | numeric |
                    | eq         | +    | +      | +       | +       |
                    | neq        | +    | +      | +       | +       |
                    | like       | -    | +      | -       | -       |
                    | nlike      | -    | +      | -       | -       |
                    | in         | +    | +      | +       | +       |
                    | nin        | +    | +      | +       | +       |
                    | gt         | -    | +      | +       | +       |
                    | gte        | -    | +      | +       | +       |
                    | lt         | -    | +      | +       | +       |
                    | lte        | -    | +      | +       | +       |
                  example:
                    user.email: root@localhost
          required:
            - projection_type
        description:
          type: string
          description: User-defined projection info.
      required:
        - origin
        - params
      example:
        origin: events
        params:
          projection_type: view
          descriptors:
            descriptor_type: body
          targets:
            - event_id
            - account_id
            - create_time
            - end_time
            - handler_id
            - external_id
            - stream_id
            - source
            - top_match
            - match_result
            - face_detections
            - face_id
            - attach_result
            - gender
            - age
            - emotion
            - ethnic_group
            - liveness
            - deepfake
            - body_detections
            - body_basic_attributes
            - upper_body
            - lower_body
            - accessories
            - tags
            - user_data
            - location
            - mask
            - track_id
            - meta
          filters:
            account_id: 5e350789-034f-4ba4-af1d-8f36b9eef663
            event_ids:
              - 403c5d63-2a5b-42fd-8215-ef1e51f9f6f6
            event_id__gte: 1654abfe-cef2-434d-988d-be5784a1d081
            event_id__lt: f14f5f5b-bfa0-45d5-a111-ceaff97b19f6
            create_time__gte: '2025-06-25T19:11:41.674Z'
            create_time__lt: '2025-06-26T19:11:41.674Z'
            end_time__gte: '2025-06-25T19:11:41.674Z'
            end_time__lt: '2025-06-26T19:11:41.674Z'
            handler_ids:
              - 8707d541-4a61-48fe-acb8-80f3c3990e40
            external_ids:
              - some-external-id
            top_matching_candidates_label: 0fe192d6-77cf-4171-8a1e-bcdc9892d4d1
            top_similar_object_ids:
              - bedb5a63-d47a-4dd1-820c-20891058eaf3
            top_similar_external_ids:
              - some-external-id
            top_similar_object_similarity__gte: 0.5
            top_similar_object_similarity__lt: 0.6
            age__gte: 17
            age__lt: 19
            gender: 1
            emotions:
              - 1
            masks:
              - 1
            liveness:
              - 1
            deepfake:
              - 1
            ethnic_groups:
              - 1
            face_ids:
              - b584e70c-5816-45c0-b3e9-4a9a6d0da506
            user_data: some-user-data
            sources:
              - some-source
            stream_ids:
              - f1227aec-05a8-4ec5-8d0f-b64ac1cf38f4
            tags:
              - some-tag
            cities:
              - some-city
            areas:
              - some-area
            districts:
              - some-district
            streets:
              - some-street
            house_numbers:
              - some-house-number
            geo_position:
              latitude_delta: 1
              longitude_delta: 1
              origin_latitude: 0
              origin_longitude: 0
            track_ids:
              - e7358c32-264c-4e8c-8c84-89ccd2353174
            apparent_age__gte: 17
            apparent_age__lt: 19
            apparent_gender:
              - 1
            headwear_states:
              - 1
            sleeve_lengths:
              - short
            upper_clothing_colors:
              - black
            backpack_states:
              - 1
            lower_garment_colors:
              - black
            lower_garment_types:
              - trousers
            headwear_apparent_colors:
              - black
            shoes_apparent_colors:
              - black
            meta:
              foo.bar__like: baz
        description: My shiny event projection
    event_output_projection:
      allOf:
        - properties:
            projection_id:
              allOf:
                - $ref: '#/components/schemas/uuid'
              description: Projection ID.
        - $ref: '#/components/schemas/event_input_projection'
        - required:
            - projection_id
            - origin
            - descriptors
            - params
            - description
    output_projection:
      oneOf:
        - $ref: '#/components/schemas/event_output_projection'
      discriminator:
        propertyName: origin
        mapping:
          events: '#/components/schemas/event_output_projection'
      description: Projection registered.
    error:
      type: object
      properties:
        error_code:
          type: integer
          description: Error code.
        desc:
          type: string
          description: Short error description.
        detail:
          type: string
          description: Error details.
        link:
          type: string
          description: Link to the documentation website with the error description.
      required:
        - error_code
        - detail
        - desc
        - link
      example:
        error_code: 1
        detail: Internal server error
        desc: Internal server error
        link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-1
    input_projection:
      oneOf:
        - $ref: '#/components/schemas/event_input_projection'
      discriminator:
        propertyName: origin
        mapping:
          events: '#/components/schemas/event_input_projection'
      description: New projection to be registered.
    projection_patch:
      type: object
      properties:
        description:
          type: string
          description: User-defined projection info.
      required:
        - description
    int_version:
      type: integer
      minimum: 0
    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
  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'
    server_timeout_error:
      description: server timeout error.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/error'
            example:
              error_code: 9
              detail: Request timeout
              desc: Request timeout on http://127.0.0.1:5100/{...}, method {...}
              link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-9
    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
x-tagGroups:
  - name: Sys
    tags:
      - documents
      - config
      - metrics
      - health
      - version
  - name: Projections
    tags:
      - projections
