OpenApi

You can find spec for the Events service in the html document.

openapi: 3.0.0
info:
  version: 'v.4.13.3'
  title: 'Luna events API'
  description: |
    VisionLabs Luna Events API.

    Introduction

    This service is intended for searching events according to the specified filters and getting some statistics parameters of events. You can receive the following parameters:

    1) event count,
    2) average, max, min value numeric parameters.

    Events can be grouped by the creation time. Grouping is possible in two ways: grouping by time intervals and the frequency grouping (by day of month).

    The service store some fields in compressed state for query optimization and database size decrease.

      Mapping ethnicities to ID:

      | Group name | Group ID |
      | ---------- | -------- |
      | african_american  | 1 |
      | indian            | 2 |
      | asian             | 3 |
      | caucasian         | 4 |

      Mapping emotions to ID:

      | Group name | Group ID |
      | ---------- | -------- |
      | anger             | 1 |
      | disgust           | 2 |
      | fear              | 3 |
      | happiness         | 4 |
      | neutral           | 5 |
      | sadness           | 6 |
      | surprise          | 7 |

      Mapping masks to ID:

      | Group name | Group ID |
      | ---------- | -------- |
      | missing           | 1 |
      | medical_mask      | 2 |
      | occluded          | 3 |

      Mapping liveness to ID:

      | liveness | value |
      |--------------|---|
      | spoof        | 0 |
      | real         | 1 |
      | unknown      | 2 |


    OpenAPI specification is the only valid document providing up-to-date information about the service API.

    The specification can be used:

    - By documentation generation tools to visualize the API.
    - By code generation tools.

    All the documents and code generated using this specification can include inaccuracies and should be carefully checked.

    OpenAPI specification can be received using the "/docs/spec" resource. The "Accept" header should be set to "application/x-yaml".

components:
  headers:
    application_json:
      schema:
        type: string
        enum:
        - application/json
      required: true
      description: Content type is application/json.

    application_json_or_xbinary:
      schema:
        type: string
        enum:
          - application/json
          - application/x-sdk-descriptor
      required: true
      description: Content type is application/json or application/x-sdk-descriptor.

    text_plain:
      schema:
        type: string
        enum:
        - text/plain
      required: true
      description: Content type is text/plain.

    image_jpeg:
      schema:
        type: string
        enum:
        - image/jpeg
      description: Content type is image/jpeg.
      required: true

    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

    application_zip:
      schema:
        type: string
        enum:
        - application/zip
      required: true
      description: Content type is application/zip.

    content_disposition:
      schema:
        type: string
      example: 'attachment; filename=task_146.zip'
      required: true
      description: Content disposition with filename.

    docs_content_type:
      schema:
        type: string
        enum:
          - application/x-yaml
          - text/html
      required: true
      description: Type of receiving data.

    text_html:
      schema:
        type: string
        enum:
          - text/html
      required: true
      description: Content type is text/html.

    config_accept_content_type:
      schema:
        type: string
        enum:
          - application/json
          - text/plain
      required: false
      description: The content type of the response body.
  parameters:
    page:
      in: query
      name: page
      schema:
        type: integer
        minimum: 1
        default: 1
      description: Page number.

    accept:
      in: header
      schema:
        type: string
        example: "application/x-sdk-descriptor"
      description: Content type which is acceptable for the response. If 'application/x-sdk-descriptor' is specified, the binary descriptor will be returned in the response body, otherwise 'application/json' content type will be applied.
      required: false
      name: Accept

    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

    wait_events_saving:
      in: query
      name: wait_events_saving
      schema:
        type: integer
        enum:
        - 0
        - 1
        default: 0
      description: |
        Whether to wait for events saving.

        If "0" is specified, the 202 status code will be expected in response to a successful request. This status code is returned after events are validated and added to the buffer. The system does not wait until the events are saved to the database. The events will be stored in the database after the response is sent.

        If "1" is specified, the 204 status code will be expected in response to a successful request. This status code is returned only after events are stored in the database.

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

    limit:
      in: query
      name: limit
      schema:
        type: integer
        minimum: 1
        maximum: 1000000
        default: 5
      description: Event limit in a match response.

    threshold:
      in: query
      name: threshold
      schema:
        type: number
        minimum: 0.0
        maximum: 1.0
        default: 0.0
      description: Event similarity threshold in a match response - events with a similarity lower than this parameter will not be returned.

    search_order:
      in: query
      name: order
      schema:
        type: string
        enum: ["asc", "desc"]
      description: |
        The sort order.

        By default, the results will be sorted by event creation time.
        If "desc" is set, the newest events will be shown first. If "asc" is set, the oldest events will be shown first.

        But if some event ID range filters specified (`event_id__gte` or `event_id__lt`), the results will be sorted by event ID.

    match_order:
      in: query
      name: order
      schema:
        type: string
        enum: [ "asc", "desc" ]
      description: |
        The sort order.
        If "desc" is set, the most similar events will be shown first. If "asc" is set, the least similar events will be shown first.

    gender:
      in: query
      name: gender
      schema:
        oneOf:
          - type: integer
            enum: [0, 1]
          - $ref: '#/components/schemas/null_filter'
      description: Gender. 1 - male, 0 - female, "null" - null value .
      example: 1

    emotions:
      in: query
      name: emotions
      schema:
        type: string
        format: list of integer and null (1, 2, 3, 4, 5, 6, 7, null)
      description: |
        Comma-separated list of predominant emotions or null. 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 |
      example: "1,2,3,null"

    masks:
      in: query
      name: masks
      schema:
        type: string
        format: list of integer and null (1, 2, 3, null)
      description: |
        Comma-separated list of predominant masks or null. Each event from result will contain one of the given mask state.

        | mask        | value |
        |-----------------|---|
        | missing         | 1 |
        | medical_mask    | 2 |
        | occluded        | 3 |
      example: "1,2,3,null"

    ethnic_groups:
      in: query
      name: ethnic_groups
      schema:
        type: string
        format: list of integer and null (1, 2, 3, 4, null)
      description: |
        Comma-separated list of dominant ethnic group or null. Each event from result will contain one of the given ethnic groups.

        | ethnicity    | value |
        |------------------|---|
        | African american | 1 |
        | Indian           | 2 |
        | Asian            | 3 |
        | Caucasian        | 4 |

      example: "1,2,null"

    liveness:
      in: query
      name: liveness
      schema:
        type: string
        format: list of integer and null (0, 1 ,2, null)
      description: |
        Comma-separated list of dominant liveness or null. Each event from result will contain one of the given liveness.

        | liveness | value |
        |--------------|---|
        | spoof        | 0 |
        | real         | 1 |
        | unknown      | 2 |

      example: "1,2,null"

    deepfake:
      in: query
      name: deepfake
      schema:
        type: string
        format: list of integer and null (0, 1, null)
      description: |
        Comma-separated list of dominant deepfakes or null. Each event from result will contain one of the given deepfake.

        | deepfake | value |
        |--------------|---|
        | fake         | 0 |
        | real         | 1 |

      example: "1,2,null"

    tags:
      in: query
      name: tags
      schema:
        type: array
        items:
          $ref: '#/components/schemas/tag'
        minItems: 0
      explode: false
      description: Comma-separated list of tags. Each event from result will contain all of the given tags.
      example:
        - tag_1
        - tag_2

    age__lt:
      in: query
      name: age__lt
      schema:
        type: integer
        minimum: 0
        maximum: 100
      description: Age upper excluded bound.
      example: 50

    age__gte:
      in: query
      name: age__gte
      schema:
        type: integer
        minimum: 0
        maximum: 100
      description: Age lower included bound.
      example: 50

    account_id:
      in: query
      name: account_id
      schema:
        $ref: '#/components/schemas/uuid'
      description: Account ID.
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    face_ids:
      in: query
      name: face_ids
      schema:
        type: string
        format: list of uuid
      description: List of comma-separated face IDs.
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb,346a5645-ec89-4806-820a-dbcb6e0dc38'

    event_ids:
      in: query
      name: event_ids
      schema:
        type: string
        format: list of uuid.
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb,346a5645-ec89-4806-820a-dbcb6e0dc38'
      description: List of comma-separated event IDs.

    event_id__gte:
      in: query
      name: event_id__gte
      schema:
        type: string
        format: uuid.
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'
      description: Lower including event ID boundary.

    event_id__gte_sorting:
      in: query
      name: event_id__gte
      schema:
        type: string
        format: uuid.
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'
      description: Lower including event ID boundary. Events in response will be sorted by their ids. If neither *event_id__lt* or *event_id__gte* is specified, the faces will be sorted by creation time.

    event_id__lt:
      in: query
      name: event_id__lt
      schema:
        type: string
        format: uuid.
      example: '346a5645-ec89-4806-820a-dbcb6e0dc38'
      description: Upper excluding event ID boundary.

    event_id__lt_sorting:
      in: query
      name: event_id__lt
      schema:
        type: string
        format: uuid.
      example: '346a5645-ec89-4806-820a-dbcb6e0dc38'
      description: Upper excluding event ID boundary. Events in response will be sorted by their ids. If neither *event_id__lt* or *event_id__gte* is specified, the faces will be sorted by creation time.

    handler_id:
      in: query
      name: handler_id
      schema:
        type: string
        format: uuid.
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'
      description: Handler ID.

    handler_ids:
      in: query
      name: handler_ids
      schema:
        type: string
        format: list of uuid.
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb,346a5645-ec89-4806-820a-dbcb6e0dc38'
      description: List of comma-separated handler IDs.

    external_id:
      in: query
      name: external_id
      schema:
        type: string
        maxLength: 36
      description: External ID.

    external_ids:
      in: query
      name: external_ids
      schema:
        type: string
        format: list of strings.
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb,346a5645-ec89-4806-820a-dbcb6e0dc38'
      description: List of comma-separated external IDs.

    user_data:
      in: query
      name: user_data
      schema:
        type: string
      description: Find all objects with user_data that is similar to this parameter.
      example: "user_data"

    sources:
      in: query
      name: sources
      schema:
        type: string
      description: Comma-separated list of sources or null. Each event from result will contain one of the given sources.
      example: "cam1,cam2,null"

    stream_ids:
      in: query
      name: stream_ids
      schema:
        type: string
        format: list of uuid.
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb,346a5645-ec89-4806-820a-dbcb6e0dc38'
      description: List of comma-separated stream IDs.

    cities:
      in: query
      name: cities
      schema:
        type: string
      description: Comma-separated list of cities or null. Each event from result will contain one of the given cities in location.
      example: "moscow,New-York,null"

    areas:
      in: query
      name: areas
      schema:
        type: string
      description: Comma-separated list of areas or null. Each event from result will contain one of the given areas in location.
      example: "CAO,central park,null"

    districts:
      in: query
      name: districts
      schema:
        type: string
      description: Comma-separated list of districts or null. Each event from result will contain one of the given districts in location.
      example: "mitino,central park,null"

    streets:
      in: query
      name: streets
      schema:
        type: string
      description: |
        Comma-separated list of streets or null. Each event from result will contain one of the given streets  in location.
      example: "arbat,schepkina,null"

    house_numbers:
      in: query
      name: house_numbers
      schema:
        type: string
      description: |
        Comma-separated list of house numbers or null. Each event from result will contain one of the given house numbers
        in location.
      example: "1,1/2str3,null"

    origin_longitude:
      in: query
      name: origin_longitude
      schema:
        oneOf:
          - $ref: '#/components/schemas/longitude'
          - $ref: '#/components/schemas/null_filter'
      description: |
        Longitude origin in degrees, a part of composite geo position filter or null for undefined geo position.
                Geo position filter is a bounding box specified by coordinates of its center (origin) and some delta.
                Geo position filter is considered as properly specified if both *origin_longitude* and
                *origin_latitude* are set, and considered as properly empty if neither of *origin_longitude*,
                *origin_latitude*, *longitude_delta*, *latitude_delta* is set.
                Null filter applied only if *origin_longitude* or *origin_latitude* is set to 'null', and
                *longitude_delta* and *latitude_delta* is not set.
      example: "36.616"

    origin_latitude:
      in: query
      name: origin_latitude
      schema:
        oneOf:
          - $ref: '#/components/schemas/latitude'
          - $ref: '#/components/schemas/null_filter'
      description: |
        Latitude origin in degrees, a part of composite geo position filter or null for undefined geo position.
                Geo position filter is a bounding box specified by coordinates of its center (origin) and some delta.
                Geo position filter is considered as properly specified if both *origin_longitude* and
                *origin_latitude* are set, and considered as properly empty if neither of *origin_longitude*,
                *origin_latitude*, *longitude_delta*, *latitude_delta* is set.
                Null filter applied only if *origin_longitude* or *origin_latitude* is set to 'null', and
                *longitude_delta* and *latitude_delta* is not set.
      example: "55.752"

    longitude_delta:
      in: query
      name: longitude_delta
      schema:
        type: number
        minimum: 0
        maximum: 90
        default: 0.01
      description: |
        Longitude delta in degrees, a part of composite geo position filter.
                Geo position filter is a bounding box specified by coordinates of its center (origin) and some delta.
                Geo position filter is considered as properly specified if both *origin_longitude* and
                *origin_latitude* are set, and considered as properly empty if neither of *origin_longitude*,
                *origin_latitude*, *longitude_delta*, *latitude_delta* is set. If both *origin_longitude* and
                *origin_latitude* are set and *longitude_delta* is not set - default is applied.
                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.
                Box edges more than 180 degrees long are not allowed. Boundaries of valid range are **exclusive**.
                NOTE: highly recommended for citywide use only.
      example: "0.01"

    latitude_delta:
      in: query
      name: latitude_delta
      schema:
        type: number
        minimum: 0
        maximum: 90
        default: 0.01
      description: |
        Latitude delta in degrees, a part of composite geo position filter.
                Geo position filter is a bounding box specified by coordinates of its center (origin) and some delta.
                Geo position filter is considered as properly specified if both *origin_longitude* and
                *origin_latitude* are set, and considered as properly empty if neither of *origin_longitude*,
                *origin_latitude*, *longitude_delta*, *latitude_delta* is set. If both *origin_longitude* and
                *origin_latitude* are set and *latitude_delta* is not set - default is applied.
                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.
                Box edges more than 180 degrees long are not allowed. Boundaries of valid range are **exclusive**.
                NOTE: highly recommended for citywide use only.
      example: "0.01"

    top_matching_candidates_label:
      in: query
      name: top_matching_candidates_label
      schema:
        type: string
      description: Top matching candidates label. Each event from result will contain the given label.
      example: "matching_label"

    top_similar_object_ids:
      in: query
      name: top_similar_object_ids
      schema:
        type: array
        items:
          $ref: '#/components/schemas/uuid'
      description: Comma-separated list of top similar object IDs. Each event from result will contain one of the given top similar object IDs.

    top_similar_external_ids:
      in: query
      name: top_similar_external_ids
      schema:
        type: array
        items:
          $ref: '#/components/schemas/external_id'
      description: Comma-separated list of top similar external IDs. Each event from result will contain one of the given top similar external IDs.

    top_similar_object_similarity__gte:
      in: query
      name: top_similar_object_similarity__gte
      schema:
        type: number
      description: Top similar object similarity lower included bound.
      example: 0.5

    top_similar_object_similarity__lt:
      in: query
      name: top_similar_object_similarity__lt
      schema:
        type: number
      description: Top similar object similarity upper excluded bound.
      example: 0.5

    get_event_target:
      in: query
      name: target
      schema:
        type: string
        enum: ["account_id", "create_time", "end_time", "event_id", "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",
        ]
      description: |
        Comma-separated list of event fields.
        If set, each event from result will contain only specified fields, otherwise, events with all fields will be returned.
      example: "extract_result"

    post_event_match_target:
      in: query
      name: target
      schema:
        type: string
        enum: ["account_id", "create_time", "end_time", "event_id", "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",
               "similarity", "meta",
        ]
      description: |
        Comma-separated list of event fields.
        If set, each event from result will contain only specified fields, otherwise, events with the "event_id" and "similarity" fields will be returned.
      example: "extract_result,similarity"

    list_id:
      in: query
      name: list_id
      schema:
        $ref: '#/components/schemas/uuid'
      description: ID of a list that contains faces.

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

    insert_time__lt:
      in: query
      name: insert_time__lt
      schema:
        type: string
        format: date-time
      description: The upper insert time excluding boundary.
      example: "2018-08-11T09:11:41.674Z"

    insert_time__gte:
      in: query
      name: insert_time__gte
      schema:
        type: string
        format: date-time
      description: The lower insert time including boundary.
      example: "2018-08-11T09:11:41.674Z"

    create_time__lt:
      in: query
      name: create_time__lt
      schema:
        type: string
        format: date-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:
        type: string
        format: date-time
      description: The lower create time including boundary.
      example: "2018-08-11T09:11:41.674Z"

    end_time__lt:
      in: query
      name: end_time__lt
      schema:
        type: string
        format: date-time
      description: Upper bound for object end_time.
      example: "2018-08-11T09:11:41.674Z"

    end_time__gte:
      in: query
      name: end_time__gte
      schema:
        type: string
        format: date-time
      description: The lower end time including boundary.
      example: "2018-08-11T09:11:41.674Z"

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

    descriptor_version:
      in: query
      name: descriptor_version
      schema:
        type: integer
        minimum: 0
        maximum: 110
        # Fake boundaries, used to prevent schematesis from sending huge integers.
      description: Event descriptor version. By default used the platform default descriptor version.
      example: 56

    descriptor_version_required:
      in: query
      name: version
      schema:
        type: integer
        minimum: 0
        maximum: 1000
        # Fake boundaries, used to prevent schematesis from sending huge integers.
      description: Event descriptor version.
      required: true
      example: 56

    event_id:
      in: path
      name: event_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: Event ID.

    descriptor_type:
      in: query
      name: descriptor_type
      schema:
        type: string
        enum: [face, body]
      description: The type of the event's descriptor.
      example: face

    descriptor_type_required:
      in: query
      name: descriptor_type
      schema:
        type: string
        enum: [face, body]
      description: The type of the event's descriptor.
      required: true
      example: face

    track_ids:
      in: query
      name: track_ids
      schema:
        oneOf:
          - type: string
            format: list of track ids
          - $ref: '#/components/schemas/null_filter'
      example: 'track_id1,track_id_2, null'
      description: List of comma-separated track IDs.

    kind:
      in: query
      name: kind
      schema:
        type: string
        enum: [basic_attributes, face_descriptor, body_descriptor]
      description: |
          Kind of missing attributes to look for.

          Only 1 value at time is supported because the response doesn't
          contain information required to distinguish kinds of the events.
      required: true
      example: basic_attributes

    missing_version:
      in: query
      name: missing_version
      schema:
        type: integer
      description: Event descriptor version. By default used the platform default descriptor version.
      example: 56

    application_json_or_msgpack_content:
      in: header
      name: Content-Type
      schema:
        type: string
        enum:
          - application/json
          - application/msgpack
      description: The response content type header.

    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

    delete_event_target:
      in: query
      name: target
      schema:
        type: array
        items:
          type: string
          enum: [ face_samples, body_samples, image_origins ]
        default: [ face_samples, body_samples, image_origins ]
      explode: false
      description: |
        Comma-separated list of event deletion info attributes.
        If set, each item from the result will contain only specified attributes in addition to the event ID, otherwise, all the deletion info attributes will be returned.
        If empty value set, each item from the result will contain only event ID.
      example: image_origins

    apparent_gender:
      in: query
      name: apparent_gender
      schema:
        type: array
        items:
          oneOf:
            - type: integer
              enum: [ 0, 1, 2 ]
            - $ref: '#/components/schemas/null_filter'
      explode: false
      description: |
        Comma-separated list of apparent gender: 0 - female, 1 - male, 2 - undefined, "null" - null value. Each event from result will contain one of the given states.
      example: 1

    apparent_age__lt:
      in: query
      name: apparent_age__lt
      schema:
        type: integer
        minimum: 0
        maximum: 100
      description: Apparent age upper excluded bound.
      example: 50

    apparent_age__gte:
      in: query
      name: apparent_age__gte
      schema:
        type: integer
        minimum: 0
        maximum: 100
      description: Apparent age lower included bound.
      example: 50

    headwear_states:
      in: query
      name: headwear_states
      schema:
        type: array
        items:
          oneOf:
            - type: integer
              enum: [ 0, 1, 2 ]
            - $ref: '#/components/schemas/null_filter'
      explode: false
      description: |
        Comma-separated list of headwear states: 0 - absent, 1 - present, 2 - undefined, "null" - null value. Each event from result will contain one of the given states.
      example: 1

    headwear_colors:
      in: query
      name: headwear_apparent_colors
      schema:
        type: array
        items:
          oneOf:
            - $ref: '#/components/schemas/headwear_color'
            - $ref: '#/components/schemas/null_filter'
      explode: false
      description: |
        Comma-separated list of headwear apparent colors or null value. Each event from result will contain one of the given states.
      example: white,undefined,null

    sleeve_lengths:
      in: query
      name: sleeve_lengths
      schema:
        type: array
        items:
          type: string
          enum: [ short, long, undefined, null]
      explode: false
      description: |
        Comma-separated list of sleeve length states or null value. Each event from result will contain one of the given states.
      example: short,null

    upper_clothing_colors:
      in: query
      name: upper_clothing_colors
      schema:
        oneOf:
          - type: array
            items:
              $ref: '#/components/schemas/clothing_color'
          - $ref: '#/components/schemas/null_filter'
      explode: false
      description: |
        Comma-separated list of upper clothing colors or null for not specified colors. Each event from result will contain at least one of the given clothing colors.
      example: black,white

    lower_garment_types:
      in: query
      name: lower_garment_types
      schema:
        type: array
        items:
          type: string
          enum: [ undefined, trousers, shorts, skirt, null ]
      explode: false
      description: |
        Comma-separated list of lower garment types or null value. Each event from result will contain one of the given types.
      example: trousers,undefined,null

    lower_garment_colors:
      in: query
      name: lower_garment_colors
      schema:
        oneOf:
          - type: array
            items:
              $ref: '#/components/schemas/clothing_color'
          - $ref: '#/components/schemas/null_filter'
      explode: false
      description: |
        Comma-separated list of lower garment colors. Each event from result will contain at least one of the given clothing colors.
      example: black,white

    shoes_colors:
      in: query
      name: shoes_apparent_colors
      schema:
        type: array
        items:
          oneOf:
            - $ref: '#/components/schemas/shoes_color'
            - $ref: '#/components/schemas/null_filter'
      explode: false
      description: |
        Comma-separated list of shoes apparent colors or null value. Each event from result will contain one of the given states.
      example: white,undefined,null

    backpack_states:
      in: query
      name: backpack_states
      schema:
        type: array
        items:
          oneOf:
          - type: integer
            enum: [ 0, 1, 2 ]
          - $ref: '#/components/schemas/null_filter'
      explode: false
      description: |
        Comma-separated list of backpack states: 0 - absent, 1 - present, 2 - undefined, "null" - not specified. Each event from result will contain one of the given states.
      example: 1

    luna_account_id_required:
      name: Luna-Account-Id
      in: header
      schema:
        type: string
        format: uuid
        example: 8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a
        pattern: ^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}$
      description: Luna account Id. Designed to identify the created object.
      required: true

    meta:
      in: query
      name: '* (meta.path.to.field__operator:type)'
      schema:
        oneOf:
          - type: string
          - $ref: '#/components/schemas/null_filter'
      description: |
        User-defined event meta's filters.
        
        Parameter name pattern: `meta.<path.to.field>__<operator>:<type>`
        
        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`.
        
        Field data **type** is optional one of `string` (default), `integer`, `numeric`.
        
        Allowed usage of filters is:

        |  operator  | type |        |         |         |
        |------------|------|--------|---------|---------|
        |            | none | string | integer | numeric |
        | eq         | +    | +      | +       | +       |
        | neq        | +    | +      | +       | +       |
        | like       | -    | +      | -       | -       |
        | nlike      | -    | +      | -       | -       |
        | in         | +    | +      | +       | +       |
        | nin        | +    | +      | +       | +       |
        | gt         | -    | +      | +       | +       |
        | gte        | -    | +      | +       | +       |
        | lt         | -    | +      | +       | +       |
        | lte        | -    | +      | +       | +       |

      example:
        meta.field_1__gt:numeric: 36.6
        meta.field_2.field_3__in: value,none
        meta.field_4:integer: 5
        meta: null
  schemas:
    Error:
      type: object
      properties:
        error_code:
          type: integer
          description: Error code.
        desc:
          type: string
          description: Short error description.
        detail:
          type: string
          description: Error details.
        link:
          type: string
          description: Link to the documentation website with the error description.
      required:
      - error_code
      - detail
      - desc
      - link
      example:
        error_code: 1
        detail: "Internal server error"
        desc: "Internal server error"
        link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-1"

    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'
      description: account id.
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    sample_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: Sample ID.
      nullable: true
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    external_id:
      description: user-defined external id for face
      type: string
      pattern: "^[^\\x00]*$"
      example: "external id"
      maxLength: 36

    track_id:
      description: Event track ID.
      type: string
      pattern: '^[a-zA-Z0-9_\-]{1,36}$'
      example: "useful_track_id_number_1"

    face_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: Face ID.
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    list_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: List ID.
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    event_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: Event ID.
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    stream_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: Stream ID.
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    handler_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: Handler ID.
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    count:
      type: integer
      minimum: 0
      description: object count.
      example: 100

    int01:
      type: integer
      enum:
      - 0
      - 1

    int0100:
      type: integer
      minimum: 0
      maximum: 100

    int0180:
      type: integer
      default: 180
      minimum: 0
      maximum: 180

    number01:
      type: number
      minimum: 0
      maximum: 1

    estimation_not_nullable:
      type: number
      format: double
      maximum: 1
      minimum: 0
      nullable: false

    null_filter:
      type: string
      enum: [null]

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

    detect_time:
      allOf:
        - $ref: "#/components/schemas/time"
        - description: Detection time.
      example: "2018-08-11T09:11:41.674Z"

    detect_ts:
      type: number
      minimum: 0.0
      maximum: 158731466399.999
      description: User-defined timestamp relative to something, such as the start of a video.
      example: 123.456
      nullable: true

    image_origin:
      type: string
      maxLength: 256
      description: Image URL - source of the detection.
      nullable: true
      example: "/6/images/b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    column:
      type: string
      enum: [event_id, external_id, handler_id, stream_id, source, top_similar_object_id, top_similar_external_id, create_time,
             end_time, liveness, deepfake, top_matching_candidates_label, top_similar_object_similarity, face_id, gender, age,
             emotion, ethnic_group, user_data, tags, city, area, district, street, house_number, geo_position, mask,
             track_id, apparent_age, apparent_gender, sleeve_length, headwear_state, upper_clothing_colors,
             backpack_state, lower_garment_colors, headwear_apparent_color lower_garment_type, shoes_apparent_color, 'meta.*']
      description: Fields to aggregate.
      example: "meta.profile.age"

    gender:
      allOf:
        - $ref: '#/components/schemas/int01'
        - description: Gender. 0 - female, 1 - male.

    age:
      allOf:
        - $ref: '#/components/schemas/int0100'
        - description: Age.

    aggregator:
      type: string
      enum: [count, max, min, avg, group_by]
      example: "count"
      description: Aggregation function for column.
      default: count

    operator_filter:
      type: string
      enum: [eq, neq, in, nin, like, nlike, gt, gte, lt, lte, covered]
      description: |
        Filter operator. For tags it is required to be like/nlike only.
        For geo position filter it is required to be covered only.
      example: "gt"

    operator_period:
      type: string
      enum: [gt, gte, lt, lte]
      description: Filter operator for event creation time.
      example: "gt"

    value_period:
      type: string
      format: date-time
      example: "2018-01-01T00:00:00Z"
      pattern: (^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$|^now-\d+(y|M|w|d|h|m|s)$)
      description: Filter value for event creation time. In ISO or now-time format.

    longitude:
      type: number
      minimum: -180
      maximum: 180
      example: 36.616

    latitude:
      type: number
      minimum: -90
      maximum: 90
      example: 55.752

    geo_position:
      type: object
      description: Geo position specified by geographic coordinates - longitude and latitude.
      properties:
        longitude:
          allOf:
            - $ref: '#/components/schemas/longitude'
            - description: Longitude in degrees.
        latitude:
          allOf:
            - $ref: '#/components/schemas/latitude'
            - description: Latitude in degrees.
      required: [longitude, latitude]

    geo_position_bbox:
      type: object
      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.
      properties:
        origin_longitude:
          allOf:
            - $ref: '#/components/schemas/longitude'
            - description: Origin longitude in degrees.
        origin_latitude:
          allOf:
            - $ref: '#/components/schemas/latitude'
            - description: Origin latitude in degrees.
        longitude_delta:
          description: |
              Longitude delta in degrees. Box edges more than 180 degrees long are not allowed.
              Boundaries of valid range are **exclusive**. NOTE: highly recommended for citywide use only.
          type: number
          minimum: 0
          maximum: 90
          default: 0.01
          example: 0.01
        latitude_delta:
          description: |
              Latitude delta in degrees. Box edges more than 180 degrees long are not allowed.
              Boundaries of valid range are **exclusive**. NOTE: highly recommended for citywide use only.
          type: number
          minimum: 0
          maximum: 90
          default: 0.01
          example: 0.01
      required: [origin_longitude, origin_latitude]

    value_filter:
      oneOf:
        - type: string
        - type: number
        - type: array
          items:
            oneOf:
              - type: string
              - type: number
        - $ref: '#/components/schemas/geo_position_bbox'
      description: |
        Filter value. It is required to be string, integer, float or its array
        or object with specific properties in case of geo position filter -
        geo position filter is bounding box specified by coordinates of its center (origin) and some delta.
      example: "London"

    user_data:
      description: user data.
      type: string
      pattern: "^[^\\x00]*$"
      maxLength: 128
      default: ""

    face_user_data:
      allOf:
        - $ref: '#/components/schemas/user_data'
      description: User data associated with face.
      example: "face of person"

    location_str:
      type: string
      pattern: "^[^\\x00]*$"
      maxLength: 36
      nullable: true

    input_location:
      type: object
      description: Information about a place where event is incidented.
      properties:
        city:
          allOf:
            - $ref: '#/components/schemas/location_str'
            - description: City where event is incidented.
        area:
          allOf:
            - $ref: '#/components/schemas/location_str'
            - description: Area where event is incidented.
        district:
          allOf:
            - $ref: '#/components/schemas/location_str'
            - description: District where event is incidented.
        street:
          allOf:
            - $ref: '#/components/schemas/location_str'
            - description: Street where event is incidented.
        house_number:
          allOf:
            - $ref: '#/components/schemas/location_str'
            - description: House number where event is incidented.
        geo_position:
          allOf:
            - $ref: '#/components/schemas/geo_position'
            - nullable: true

      example:
        city: "Moscow"
        area: "CAO"
        district: "Arbat"
        street: "Arbat"
        house_number: "3"
        geo_position:
          longitude: 36.616
          latitude: 55.752

    output_location:
      allOf:
        - $ref: '#/components/schemas/input_location'
        - required: [city, area, district, street, house_number, geo_position]

    target:
      type: object
      properties:
        column:
          $ref: '#/components/schemas/column'
        aggregator:
          $ref: '#/components/schemas/aggregator'
      required: [column , aggregator]

    targets:
      type: array
      description: |
        Fields and functions to aggregate.

        Allowed usage of aggregators is:

        | Column                        | Aggregator |     |     |     |          |
        |-------------------------------|------------|-----|-----|-----|----------|
        |                               | count      | max | min | avg | group_by |
        | event_id                      | +          | -   | -   | -   | +        |
        | external_id                   | +          | -   | -   | -   | +        |
        | handler_id                    | +          | -   | -   | -   | +        |
        | stream_id                     | +          | -   | -   | -   | +        |
        | source                        | +          | -   | -   | -   | +        |
        | top_similar_object_id         | +          | -   | -   | -   | +        |
        | top_similar_external_id       | +          | -   | -   | -   | +        |
        | top_matching_candidates_label | +          | -   | -   | -   | +        |
        | create_time                   | +          | +   | +   | -   | -        |
        | end_time                      | +          | +   | +   | -   | -        |
        | top_similar_object_similarity | +          | +   | +   | +   | -        |
        | face_id                       | +          | -   | -   | -   | +        |
        | gender                        | +          | +   | +   | +   | +        |
        | age                           | +          | +   | +   | +   | +        |
        | emotion                       | +          | +   | +   | +   | +        |
        | mask                          | +          | +   | +   | +   | +        |
        | ethnic_group                  | +          | +   | +   | +   | +        |
        | liveness                      | +          | +   | +   | +   | +        |
        | deepfake                      | +          | +   | +   | +   | +        |
        | user_data                     | +          | -   | -   | -   | +        |
        | tags                          | +          | +   | +   | -   | -        |
        | city                          | +          | -   | -   | -   | +        |
        | area                          | +          | -   | -   | -   | +        |
        | district                      | +          | -   | -   | -   | +        |
        | street                        | +          | -   | -   | -   | +        |
        | house_number                  | +          | -   | -   | -   | +        |
        | geo_position                  | +          | -   | -   | -   | -        |
        | track_id                      | +          | -   | -   | -   | +        |
        | apparent_age                  | +          | +   | +   | +   | +        |
        | apparent_gender               | +          | +   | +   | +   | +        |
        | sleeve_length                 | +          | -   | -   | -   | +        |
        | headwear_state                | +          | +   | +   | +   | +        |
        | upper_clothing_colors         | +          | -   | -   | -   | -        |
        | backpack_state                | +          | +   | +   | +   | +        |
        | lower_garment_colors          | +          | -   | -   | -   | -        |
        | headwear_apparent_color       | +          | -   | -   | -   | +        |
        | lower_garment_type            | +          | -   | -   | -   | +        |
        | shoes_apparent_color          | +          | -   | -   | -   | +        |
        | meta.*                        | +          | +   | +   | +   | -        |
      items:
        $ref: '#/components/schemas/target'
      minItems: 1
      default:
        - {'column': 'event_id', 'aggregator': 'count'}

    filter:
      type: object
      description: Filter for sample restriction.
      properties:
        column:
          $ref: '#/components/schemas/column'
        operator:
          $ref: '#/components/schemas/operator_filter'
        value:
          $ref: '#/components/schemas/value_filter'
      required: [column , operator, value]

    filters:
      type: array
      description: |
        Set of filters for sample restriction.

        Allowed usage of filters is:
        | Filter                        | Operator    |         |         |                  |         |             |
        |-------------------------------|-------------|---------|---------|------------------|---------|-------------|
        |                               | like, nlike | in, nin | eq, neq | gt, gte, lt, lte | covered | eq/neq null |
        | tags                          | +           | -       | -       | -                | -       | -           |
        | source                        | -           | +       | +       | -                | -       | +           |
        | stream_id                     | -           | +       | +       | -                | -       | +           |
        | user_data                     | -           | +       | +       | -                | -       | -           |
        | account_id                    | -           | +       | +       | +                | -       | -           |
        | event_id                      | -           | +       | +       | +                | -       | -           |
        | external_id                   | -           | +       | +       | +                | -       | -           |
        | handler_id                    | -           | +       | +       | +                | -       | -           |
        | top_similar_object_id         | -           | +       | +       | +                | -       | -           |
        | top_similar_external_id       | -           | +       | +       | +                | -       | -           |
        | top_matching_candidates_label | -           | +       | +       | -                | -       | -           |
        | top_similar_object_similarity | -           | -       | -       | +                | -       | -           |
        | face_id                       | -           | +       | +       | +                | -       | -           |
        | gender                        | -           | +       | +       | +                | -       | +           |
        | age                           | -           | +       | +       | +                | -       | +           |
        | emotion                       | -           | +       | +       | +                | -       | +           |
        | mask                          | -           | +       | +       | +                | -       | +           |
        | ethnic_group                  | -           | +       | +       | +                | -       | +           |
        | liveness                      | -           | +       | +       | +                | -       | +           |
        | deepfake                      | -           | +       | +       | +                | -       | +           |
        | city                          | -           | +       | +       | -                | -       | +           |
        | area                          | -           | +       | +       | -                | -       | +           |
        | district                      | -           | +       | +       | -                | -       | +           |
        | street                        | -           | +       | +       | -                | -       | +           |
        | house_number                  | -           | +       | +       | -                | -       | +           |
        | geo_position                  | -           | -       | -       | -                | +       | +           |
        | track_id                      | -           | +       | +       | -                | -       | +           |
        | apparent_age                  | -           | +       | +       | +                | -       | +           |
        | apparent_gender               | -           | +       | +       | +                | -       | +           |
        | sleeve_length                 | -           | +       | +       | -                | -       | +           |
        | headwear_state                | -           | +       | +       | +                | -       | +           |
        | upper_clothing_colors         | -           | +       | -       | -                | -       | +           |
        | backpack_state                | -           | +       | +       | +                | -       | +           |
        | lower_garment_colors          | -           | +       | -       | -                | -       | +           |
        | headwear_apparent_color       | -           | +       | +       | -                | -       | +           |
        | lower_garment_type            | -           | +       | +       | -                | -       | +           |
        | shoes_apparent_color          | -           | +       | +       | -                | -       | +           |
        | meta.*                        | +           | +       | +       | +                | -       | +           |

        Warning: must be at least one aggregator different with 'group_by' in request

      items:
        $ref: '#/components/schemas/filter'
      minItems: 0

    period:
      description: Min and max of event creation time for sample restriction.
      type: object
      properties:
        operator:
          $ref: '#/components/schemas/operator_period'
        value:
          $ref: '#/components/schemas/value_period'
      required: [operator, value]

    periods:
      type: array
      description: It is possible to set start and end of period.
      items:
        $ref: '#/components/schemas/period'
      minItems: 0

    group_by:
      type: string
      description: |
        Event for grouping by creation time.

        Grouping is possible in two ways

        1) Grouping by time intervals - number and dimension

        | The parameter value | Description  |
        |---------------------|--------------|
        | `1m`                | one minute   |
        | `2h`                | two hours    |
        | `7d`                | seven days   |
        | `5w`                | five weeks   |
        | `3M`                | three months |
        | `10y`               | ten years    |

        2) The frequency grouping - one of the following

        | The parameter value | Description        |
        |---------------------|--------------------|
        | `monthOfYear`       | by month of year   |
        | `weekOfYear`        | by week of year    |
        | `dayOfYear`         | by day of year     |
        | `dayOfMonth`        | by day of month    |
        | `dayOfWeek`         | by day of week     |
        | `hourOfDay`         | by hours of day    |
        | `minuteOfHour`      | by minutes of hour |

      example: "dayOfWeek"

    ethnicities_enum:
      type: integer
      enum: [1, 2, 3, 4]
      description: |
        Reference ethnicity

        | ethnicity    | value |
        |------------------|---|
        | African american | 1 |
        | Indian           | 2 |
        | Asian            | 3 |
        | Caucasian        | 4 |

    predominant_ethnicity:
      type: string
      description: Most likely ethnicity of a human from the event.
      enum: ["african_american", "indian", "caucasian", "asian"]

    emotion_enum:
      description: |
        predominant emotion.

        | emotions    | value |
        |-----------------|---|
        | anger           | 1 |
        | disgust         | 2 |
        | fear            | 3 |
        | happiness       | 4 |
        | neutral         | 5 |
        | sadness         | 6 |
        | surprise        | 7 |

      type: integer
      enum: [1, 2, 3, 4, 5, 6, 7]

    mask_enum:
      description: |
        Predominant mask.

        | masks      | value |
        |----------------|---|
        | missing        | 1 |
        | medical_mask   | 2 |
        | occluded       | 3 |

      type: integer
      enum: [1, 2, 3]

    liveness_enum:
      description: |
        Predominant liveness.

        | liveness | value |
        |--------------|---|
        | spoof        | 0 |
        | real         | 1 |
        | unknown      | 2 |

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

    deepfake_enum:
      description: |
        Predominant deepfake.

        | liveness | value |
        |--------------|---|
        | fake         | 0 |
        | real         | 1 |

      type: integer
      enum: [0, 1]

    int_version:
      type: integer
      minimum: 0

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

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

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

    avatar:
      type: string
      format: uri-reference
      default: ""
      nullable: true
      description: Avatar for the face, references to a sample or a user-defined reference.

    lists:
      type: array
      items:
        $ref: '#/components/schemas/list_id'
      minItems: 0
      description: List of luna lists, which contain the face.

    url:
      type: string
      description: Face URL.
      nullable: true

    face:
      type: object
      properties:
        face_id:
          $ref: '#/components/schemas/face_id'
        lists:
          type: array
          items:
            $ref: '#/components/schemas/list_id'
          minItems: 0
          description: List of luna lists, which contain the face.
      required: [face_id, lists]
      example:
        face_id: "426542d6-5509-4e5b-8a01-e2abd5c0a8c6"
        lists: ["429b0e78-4616-426a-b57f-02baa72d638d", "6d037c33-31ec-4d73-b3b3-ec80b09446c2"]

    face_candidate:
      type: object
      properties:
        face_id:
          $ref: '#/components/schemas/face_id'
        external_id:
          $ref: '#/components/schemas/external_id'
        user_data:
          $ref: '#/components/schemas/face_user_data'
        create_time:
          allOf:
            - $ref: "#/components/schemas/time"
            - description: Time of the face creation.

    face_candidate_reply:
      type: object
      properties:
        face_id:
          allOf:
          - $ref: '#/components/schemas/face_id'
          nullable: true
        external_id:
          allOf:
          - $ref: '#/components/schemas/external_id'
          nullable: true
        user_data:
          allOf:
          - $ref: '#/components/schemas/face_user_data'
          nullable: true
        create_time:
          allOf:
          - $ref: "#/components/schemas/time"
          - description: Time of the face creation.
          nullable: true
      required: [face_id, external_id, user_data, create_time]

    event_candidate:
      type: object
      properties:
        event_id:
          $ref: '#/components/schemas/event_id'
        external_id:
          $ref: '#/components/schemas/external_id'
        handler_id:
          $ref: '#/components/schemas/handler_id'
        source:
          allOf:
          - $ref: '#/components/schemas/source'
          nullable: true
        stream_id:
          allOf:
            - $ref: '#/components/schemas/stream_id'
          nullable: true
        user_data:
          $ref: '#/components/schemas/face_user_data'
        create_time:
          allOf:
            - $ref: "#/components/schemas/time"
            - description: Time of the event creation.

    event_candidate_reply:
      type: object
      properties:
        event_id:
          allOf:
          - $ref: '#/components/schemas/event_id'
          nullable: true
        external_id:
          allOf:
          - $ref: '#/components/schemas/external_id'
          nullable: true
        handler_id:
          allOf:
          - $ref: '#/components/schemas/handler_id'
          nullable: true
        source:
          allOf:
          - $ref: '#/components/schemas/source'
          nullable: true
        stream_id:
          allOf:
            - $ref: '#/components/schemas/stream_id'
          nullable: true
        user_data:
          allOf:
          - $ref: '#/components/schemas/face_user_data'
          nullable: true
        create_time:
          allOf:
          - $ref: "#/components/schemas/time"
          - description: Time of the event creation.
          nullable: true
      required: [event_id, external_id, handler_id, source, stream_id, user_data, create_time]

    source:
      description: Additional information that user provides with event.
      type: string
      pattern: "^[^\\x00]*$"
      example: "3rd Avenue"

    tag:
      description: Tag. All characters allowed except *NUL*.
      type: string
      pattern: "^[^\\x00]+$"
      example: "good"
      maxLength: 36

    Tags:
      description: Tag array.
      type: array
      items:
        $ref: '#/components/schemas/tag'
      example: ["tag1", "tag2"]

    top_matching_candidates_label:
      description: Top matching candidates label.
      type: string
      pattern: "^[^\\x00]*$"
      maxLength: 36
      example: "good guys"

    top_match_face:
      type: object
      description: The most similar object is face.
      properties:
        face_id:
          allOf:
          - $ref: '#/components/schemas/face_id'
          nullable: true
        similarity:
          $ref: '#/components/schemas/face_similarity'
        label:
          $ref: '#/components/schemas/top_matching_candidates_label'
        external_id:
          allOf:
          - $ref: '#/components/schemas/external_id'
          nullable: true
      required: [face_id, similarity, label, external_id]

    top_match_event:
      type: object
      description: The most similar object is event.
      properties:
        event_id:
          allOf:
          - $ref: '#/components/schemas/event_id'
          nullable: true
        similarity:
          $ref: '#/components/schemas/event_similarity'
        label:
          $ref: '#/components/schemas/top_matching_candidates_label'
        external_id:
          allOf:
          - $ref: '#/components/schemas/external_id'
          nullable: true
      required: [event_id, similarity, label, external_id]

    Event:
      type: object
      description: Event.
      properties:
        create_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: Event creation time.
        end_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: Event end time.
        event_id:
          $ref: '#/components/schemas/event_id'
        handler_id:
          allOf:
            - $ref: '#/components/schemas/handler_id'
          description: ID of the handler, which gave birth to the event.
        account_id:
          $ref: '#/components/schemas/account_id'
        external_id:
          $ref: '#/components/schemas/external_id'
        source:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/source'
        stream_id:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/stream_id'
        top_match:
          nullable: true
          oneOf:
            - $ref: '#/components/schemas/top_match_face'
            - $ref: '#/components/schemas/top_match_event'
        match_result:
          description: Object that contains match result.
          type: array
          nullable: true
          items:
            $ref: '#/components/schemas/match_candidates_reply'
          example:
            [{
               "label": "good guys",
               "candidates": [{
                              "face":{
                                "face_id": "426542d6-5509-4e5b-8a01-e2abd5c0a8c6",
                                "external_id": "2xQ2gprbMUePw1s9gw9fvA==",
                                "user_data": "fox1991",
                                "create_time": "2018-08-11T09:11:41.674Z"
                              },
                              "similarity": 0.5
                            }]},
             {
               "label": "bad guys",
               "candidates": [{
                              "event":{
                                "event_id": "426542d6-5509-4e5b-8a01-e2abd5c0a8c7",
                                "external_id": "2xQ2gprbMUePw1s9gw9fvA==",
                                "user_data": "fox1991",
                                "create_time": "2018-08-11T09:11:41.674Z",
                                "handler_id": "426542d6-5509-4e5b-8a01-e2abd5c0a8c7",
                                "stream_id": "426542d6-5509-4e5b-8a01-e2abd5c0a8c7",
                                "source": "426542d6-5509-4e5b-8a01-e2abd5c0a8c7"
                              },
                              "similarity": 0.3
                            }]}]
        face_detections:
          description: List of all face detection and corresponding sample IDs.
          type: array
          nullable: true
          items:
            type: object
            properties:
              sample_id:
                $ref: '#/components/schemas/sample_id'
              detection:
                type: object
                description: Detection.
                properties:
                  rect:
                    $ref: '#/components/schemas/rect'
                required: [rect]
              detect_time:
                $ref: '#/components/schemas/detect_time'
              detect_ts:
                $ref: '#/components/schemas/detect_ts'
              image_origin:
                $ref: '#/components/schemas/image_origin'
            required: [sample_id, detect_time, image_origin, detect_ts]
        body_detections:
          description: List of all body detection and corresponding sample IDs.
          type: array
          nullable: true
          items:
            type: object
            properties:
              sample_id:
                $ref: '#/components/schemas/sample_id'
              detection:
                type: object
                description: Detection.
                properties:
                  rect:
                    $ref: '#/components/schemas/rect'
              detect_time:
                $ref: '#/components/schemas/detect_time'
              detect_ts:
                $ref: '#/components/schemas/detect_ts'
              image_origin:
                $ref: '#/components/schemas/image_origin'
            required: [sample_id, detect_time, image_origin, detect_ts]

        body_basic_attributes:
          $ref: '#/components/schemas/body_basic_attributes'
        upper_body:
          allOf:
            - $ref: '#/components/schemas/upper_body_attributes'
            - properties:
                headwear:
                  properties:
                    apparent_color:
                      nullable: true
                  required: [ state, apparent_color ]
        lower_body:
          $ref: '#/components/schemas/lower_body_attributes'
        accessories:
          $ref: '#/components/schemas/body_accessories'
        face_id:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/face_id'
        attach_result:
          description: Contains attached lists IDs.
          type: array
          items:
            $ref: '#/components/schemas/list_id'
          minItems: 0
        gender:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/gender'
        age:
          description: Age.
          type: integer
          nullable: true
          maximum: 100
          minimum: 0
        emotion:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/emotion_enum'
        mask:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/mask_enum'
        ethnic_group:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/ethnicities_enum'
        liveness:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/liveness_enum'
        deepfake:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/deepfake_enum'
        tags:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/Tags'
        user_data:
          $ref: '#/components/schemas/user_data'
        location:
          $ref: '#/components/schemas/output_location'
        track_id:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/track_id'
        meta:
          type: object
          nullable: true
          additionalProperties: true
          description: User defined metadata (json object). Size shouldn't exceed 2MB

    Events:
      type: array
      items:
        $ref: '#/components/schemas/Event'

    EventsWithoutCount:
      type: object
      properties:
        events:
          $ref: '#/components/schemas/Events'

    face_similarity:
      allOf:
        - $ref: '#/components/schemas/number01'
      description: Face similarity.

    event_similarity:
      allOf:
        - $ref: '#/components/schemas/number01'
      description: Event similarity.

    face_match_candidate:
      type: object
      properties:
        face:
          $ref: '#/components/schemas/face_candidate'
        similarity:
          $ref: '#/components/schemas/face_similarity'
      required: [face, similarity]

    face_match_candidate_reply:
      type: object
      properties:
        face:
          $ref: '#/components/schemas/face_candidate_reply'
        similarity:
          $ref: '#/components/schemas/face_similarity'
      required: [face, similarity]

    event_match_candidate:
      type: object
      properties:
        event:
          $ref: '#/components/schemas/event_candidate'
        similarity:
          $ref: '#/components/schemas/event_similarity'
      required: [event, similarity]

    event_match_candidate_reply:
      type: object
      properties:
        event:
          $ref: '#/components/schemas/event_candidate_reply'
        similarity:
          $ref: '#/components/schemas/event_similarity'
      required: [event, similarity]

    match_candidates_faces:
      type: array
      description: List of faces candidates.
      items:
        $ref: '#/components/schemas/face_match_candidate'

    match_candidates_faces_reply:
      type: object
      properties:
        label:
          $ref: '#/components/schemas/top_matching_candidates_label'
        candidates:
          type: array
          description: List of faces candidates.
          items:
            $ref: '#/components/schemas/face_match_candidate_reply'
      required: [label, candidates]

    match_candidates_events:
      type: array
      description: List of events candidates.
      items:
        $ref: '#/components/schemas/event_match_candidate'

    match_candidates_events_reply:
      type: object
      properties:
        label:
          $ref: '#/components/schemas/top_matching_candidates_label'
        candidates:
          type: array
          description: List of events candidates.
          items:
            $ref: '#/components/schemas/event_match_candidate_reply'
      required: [label, candidates]

    match_candidates_reply:
      anyOf:
        - $ref: '#/components/schemas/match_candidates_faces_reply'
        - $ref: '#/components/schemas/match_candidates_events_reply'

    match_candidates_new_event_faces:
      type: object
      minItems: 1
      properties:
        candidates:
          $ref: '#/components/schemas/match_candidates_faces'
        label:
          $ref: '#/components/schemas/top_matching_candidates_label'
      required: [candidates, label]

    match_candidates_new_event_events:
      type: object
      minItems: 1
      properties:
        candidates:
          $ref: '#/components/schemas/match_candidates_events'
        label:
          $ref: '#/components/schemas/top_matching_candidates_label'
      required: [candidates, label]

    match_candidates_new_event:
      oneOf:
        - $ref: '#/components/schemas/match_candidates_new_event_faces'
        - $ref: '#/components/schemas/match_candidates_new_event_events'

    rect:
      type: object
      description: Detection rectangle.
      properties:
        x:
          type: integer
          description: Detection rectangle x coordinate.
          maximum: 32767
          minimum: -32768
        y:
          type: integer
          description: Detection rectangle y coordinate.
          maximum: 32767
          minimum: -32768
        width:
          type: integer
          description: Detection rectangle width.
          maximum: 32767
          minimum: 0
        height:
          type: integer
          description: Detection rectangle height.
          maximum: 32767
          minimum: 0
      required: [x, y, width, height]

    basic_attributes:
      type: object
      description: Basic attributes.
      properties:
        age:
          $ref: '#/components/schemas/age'
        gender:
          $ref: '#/components/schemas/gender'
        ethnicities:
          $ref: '#/components/schemas/ethnic_estimations'

    face_attributes_json:
      type: object
      description: Face attributes.
      properties:
        basic_attributes:
          $ref: '#/components/schemas/basic_attributes'
        descriptor_data:
          $ref: '#/components/schemas/descriptor_base64_with_version'

    face_attributes_msgpack:
      type: object
      description: Face attributes.
      properties:
        basic_attributes:
          $ref: '#/components/schemas/basic_attributes'
        descriptor_data:
          $ref: '#/components/schemas/descriptor_binary_with_version'

    body_attributes_json:
      type: object
      description: Body attributes.
      properties:
        descriptor_data:
          $ref: '#/components/schemas/descriptor_base64_with_version'

    body_attributes_msgpack:
      type: object
      description: Body attributes.
      properties:
        descriptor_data:
          $ref: '#/components/schemas/descriptor_binary_with_version'

    body_basic_attributes:
      type: object
      description: Body basic attributes.
      nullable: true
      properties:
        apparent_age:
          type: integer
          maximum: 100
          minimum: 0
          description: Apparent age.
        apparent_gender:
          type: integer
          enum: [ 0, 1, 2 ]
          description: Apparent gender (0 - female, 1 - male, 2 - undefined).
      required: [ apparent_age, apparent_gender ]

    headwear_color:
      type: string
      enum: [ undefined, black, white, other ]
      description: Headwear apparent color.

    clothing_color:
      type: string
      enum: [ undefined, black, blue, green, gray, orange, purple, red, white, yellow, pink, brown, beige, khaki, multicolored ]
      description: Clothing color.

    shoes_color:
      type: string
      enum: [ undefined, black, white, other ]
      description: Shoes apparent color.

    upper_body_attributes:
      type: object
      description: Upper body attributes.
      nullable: true
      properties:
        headwear:
          type: object
          properties:
            state:
              type: integer
              enum: [ 0, 1, 2 ]
              description: Headwear state (0 - absent, 1 - present, 2 - undefined).
            apparent_color:
              $ref: '#/components/schemas/headwear_color'
          required: [ state ]
          description: Headwear attributes.
        sleeve:
          type: object
          properties:
            length:
              type: string
              enum: [ short, long, undefined ]
              description: Sleeve length.
          required: [ length ]
          description: Sleeve attributes.
        upper_clothing:
          type: object
          properties:
            colors:
              type: array
              items:
                $ref: '#/components/schemas/clothing_color'
              description: Upper clothing color set.
          required: [ colors ]
          description: Upper clothing attibutes.
      required: [ headwear, sleeve, upper_clothing ]

    lower_body_attributes:
      type: object
      description: Lower body attributes.
      nullable: true
      properties:
        lower_garment:
          type: object
          properties:
            type:
              type: string
              enum: [ undefined, trousers, shorts, skirt ]
            colors:
              type: array
              items:
                $ref: '#/components/schemas/clothing_color'
              description: Lower clothing color set.
          required: [ type, colors ]
          description: Lower clothing attibutes.
        shoes:
          type: object
          properties:
            apparent_color:
              $ref: '#/components/schemas/shoes_color'
          required: [ apparent_color ]
          description: Shoes attributes.
      required: [ lower_garment, shoes ]

    body_accessories:
      type: object
      description: Body accessories.
      nullable: true
      properties:
        backpack:
          type: object
          properties:
            state:
              type: integer
              enum: [ 0, 1, 2 ]
              description: Backpack state (0 - absent, 1 - present, 2 - undefined).
          description: Backpack attributes.
          required: [ state ]
      required: [ backpack ]

    base_new_event:
      type: object
      description: Event.
      properties:
        create_time:
          allOf:
            - type: string
              description: Event creation time.
            - $ref: '#/components/schemas/time'
        end_time:
          allOf:
            - type: string
              description: Event end time, if it was not set, the system will set it by the time of creation.
            - $ref: '#/components/schemas/time'
        event_id:
          allOf:
            - type: string
              description: Event ID.
            - $ref: '#/components/schemas/event_id'
        handler_id:
          allOf:
            - type: string
              description: ID of the handler, which gave birth to the event.
            - $ref: '#/components/schemas/handler_id'
        external_id:
          allOf:
          - $ref: '#/components/schemas/external_id'
          nullable: true
          default: ""
        user_data:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/user_data'
        meta:
          type: object
          nullable: true
          additionalProperties: true
          description: User defined metadata (json object). Size shouldn't exceed 2MB.
          example:
            {
               "key": "value"
            }
        source:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/source'
        stream_id:
          allOf:
            - $ref: '#/components/schemas/stream_id'
          nullable: true
        track_id:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/track_id'
        tags:
          allOf:
            - nullable: true
            - $ref: '#/components/schemas/Tags'
        face:
          allOf:
            - $ref: '#/components/schemas/face'
            - description: Face object.
            - nullable: true
        matches:
          type: array
          description: Matches list.
          nullable: true
          items:
            $ref: '#/components/schemas/match_candidates_new_event'
          example:
            [{
               "label": "good guys",
               "candidates": [{
                              "face": {
                                "face_id": "426542d6-5509-4e5b-8a01-e2abd5c0a8c6",
                                "external_id": "2xQ2gprbMUePw1s9gw9fvA==",
                                "user_data": "fox1991",
                                "create_time": "2018-08-11T09:11:41.674Z"
                              },
                            similarity: 0.5
                            }]},
             {
               "label": "bad guys",
               "candidates": [{
                              "event": {
                                "event_id": "426542d6-5509-4e5b-8a01-e2abd5c0a8c7",
                                "external_id": "2xQ2gprbMUePw1s9gw9fvA==",
                                "user_data": "fox1991",
                                "create_time": "2018-08-11T09:11:41.674Z",
                                "handler_id": "426542d6-5509-4e5b-8a01-e2abd5c0a8c7",
                                "source": "426542d6-5509-4e5b-8a01-e2abd5c0a8c7",
                                "stream_id": "426542d6-5509-4e5b-8a01-e2abd5c0a8c7",
                              },
                            "similarity": 0.3
                            }]}]
        detections:
          type: array
          description: Detection list.
          items:
            type: object
            properties:
              filename:
                type: string
                description: samples filename
              samples:
                description: a couple of face and body samples - both refer to the same person
                type: object
                properties:
                  face:
                    description: Face detection.
                    type: object
                    nullable: true
                    properties:
                      sample_id:
                        $ref: '#/components/schemas/sample_id'
                      detection:
                        type: object
                        description: Detection.
                        properties:
                          rect:
                            $ref: '#/components/schemas/rect'
                    required: [sample_id]
                  body:
                    description: Body detection.
                    type: object
                    nullable: true
                    properties:
                      sample_id:
                        $ref: '#/components/schemas/sample_id'
                      detection:
                        type: object
                        description: Detection.
                        properties:
                          rect:
                            $ref: '#/components/schemas/rect'
                    required: [sample_id]
                required: [face, body]
              detect_time:
                $ref: '#/components/schemas/detect_time'
              detect_ts:
                $ref: '#/components/schemas/detect_ts'
              image_origin:
                $ref: '#/components/schemas/image_origin'
            required: [samples, filename, detect_time]
        location:
          $ref: '#/components/schemas/input_location'
        aggregate_estimations:
          type: object
          description: Aggregated estimations.
          properties:
            face:
              type: object
              nullable: true
              description: Aggregated face estimations.
              properties:
                attributes:
                  type: object
                  nullable: false
                  description: Aggregated face attributes.
                  properties:
                    liveness:
                      allOf:
                        - description: Aggregated liveness result.
                        - $ref: '#/components/schemas/liveness_result'
                    deepfake:
                      allOf:
                        - description: Aggregated deepfake result.
                        - $ref: '#/components/schemas/deepfake_result'
                    emotions:
                      allOf:
                        - description: Aggregated emotions result.
                        - $ref: '#/components/schemas/emotions'
                    mask:
                      allOf:
                        - description: Aggregated mask result.
                        - $ref: '#/components/schemas/mask'
              required: [attributes]
            body:
              type: object
              nullable: true
              description: Aggregated body estimations.
              properties:
                attributes:
                  type: object
                  description: Body extra attributes.
                  properties:
                    basic_attributes:
                      $ref: '#/components/schemas/body_basic_attributes'
                    upper_body:
                      $ref: '#/components/schemas/upper_body_attributes'
                    lower_body:
                      $ref: '#/components/schemas/lower_body_attributes'
                    accessories:
                      $ref: '#/components/schemas/body_accessories'
              required: [ attributes ]
      required: [create_time, event_id, handler_id]

    new_event_json:
      allOf:
        - $ref: '#/components/schemas/base_new_event'
        - properties:
            face_attributes:
              $ref: '#/components/schemas/face_attributes_json'
            body_attributes:
              $ref: '#/components/schemas/body_attributes_json'

    new_event_msgpack:
      allOf:
        - $ref: '#/components/schemas/base_new_event'
        - properties:
            face_attributes:
              $ref: '#/components/schemas/face_attributes_msgpack'
            body_attributes:
              $ref: '#/components/schemas/body_attributes_msgpack'

    event_for_update_json:
      type: object
      description: Event for update.
      properties:
        face_attributes:
          $ref: '#/components/schemas/face_attributes_json'
        body_attributes:
          $ref: '#/components/schemas/body_attributes_json'

    event_for_update_msgpack:
      type: object
      description: Event for update.
      properties:
        face_attributes:
          $ref: '#/components/schemas/face_attributes_msgpack'
        body_attributes:
          $ref: '#/components/schemas/body_attributes_msgpack'

    ethnicities_estimations:
      type: object
      description: Ethnicity classifier response.
      properties:
        asian:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: Asian ethnicity probability.
        indian:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: Indian ethnicity probability.
        caucasian:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: Caucasian ethnicity probability.
        african_american:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: African American ethnicity probability.

    ethnic_estimations:
      type: object
      description: Ethnicities estimations.
      properties:
        estimations:
          $ref: '#/components/schemas/ethnicities_estimations'
        predominant_ethnicity:
          $ref: '#/components/schemas/predominant_ethnicity'

    getEventStats:
      type: object
      properties:
        targets:
          $ref: '#/components/schemas/targets'
        filters:
          $ref: '#/components/schemas/filters'
        period:
          $ref: '#/components/schemas/periods'
        group_by:
          $ref: '#/components/schemas/group_by'

    emotions_estimations:
      type: object
      properties:
        anger:
          allOf:
          - $ref: '#/components/schemas/estimation_not_nullable'
          - description: Anger probability.
        disgust:
          allOf:
          - $ref: '#/components/schemas/estimation_not_nullable'
          - description: Disgust probability.
        fear:
          allOf:
          - $ref: '#/components/schemas/estimation_not_nullable'
          - description: Fear probability.
        happiness:
          allOf:
          - $ref: '#/components/schemas/estimation_not_nullable'
          - description: Happiness probability.
        neutral:
          allOf:
          - $ref: '#/components/schemas/estimation_not_nullable'
          - description: Neutral face probability.
        sadness:
          allOf:
          - $ref: '#/components/schemas/estimation_not_nullable'
          - description: Sadness probability.
        surprise:
          allOf:
          - $ref: '#/components/schemas/estimation_not_nullable'
          - description: Surprise probability.
      required: [surprise, sadness, neutral, happiness, fear, disgust, anger]
      description: emotion classifier response.
      example: {anger: 0.1, disgust: 0.2, fear: 0.3, happiness: 0.4, neutral: 0.5, sadness: 0.6, surprise: 0.7}

    predominant_emotion:
      type: string
      description: Name of predominant emotion.
      enum: [surprise, sadness, neutral, happiness, fear, disgust, anger]

    emotions:
      type: object
      description: emotion
      properties:
        estimations:
          allOf:
            - $ref: '#/components/schemas/emotions_estimations'
            - description: Emotion classifier response.
        predominant_emotion:
          $ref: '#/components/schemas/predominant_emotion'
      required: [predominant_emotion, estimations]

    liveness_score:
      allOf:
        - $ref: '#/components/schemas/number01'
      description: |
        The parameter shows the probability of a live person being present in the
        image, i.e. it is not a presentation attack.

        In general, the estimated probability must exceed the theoretical
        threshold of 50%. The value may be increased according to your business rules.
      example: 0.99

    deepfake_score:
      allOf:
        - $ref: '#/components/schemas/number01'
      description: |
        The parameter shows the probability that image is real and wasn't created using deepfake.

        In general, the estimated probability must exceed the theoretical
        threshold of 50%. The value may be increased according to your business rules.
      example: 0.99

    liveness_quality:
      allOf:
        - $ref: '#/components/schemas/number01'
      description: |
        Quality value is a probability of "appropriate image".
        The parameter describes the integral value of image, facial and environmental characteristics.
      example: 1.0

    liveness_prediction:
      type: string
      enum: ["spoof", "real", "unknown"]
      description: Prediction that a person in the image is real (not a fake).
      example: "real"

    liveness_result:
      type: object
      description: liveness prediction result.
      properties:
        prediction:
          $ref: '#/components/schemas/liveness_prediction'
        estimations:
          type: object
          description: Liveness estimations result.
          properties:
            score:
              $ref: '#/components/schemas/liveness_score'
            quality:
              $ref: '#/components/schemas/liveness_quality'
          required: [score, quality]
      required: [prediction, estimations]

    deepfake_prediction:
      type: string
      enum: ["fake", "real"]
      description: Prediction that a person in the image created via deepfake (or not).
      example: "real"

    deepfake_result:
      type: object
      description: Deepfake prediction result.
      properties:
        prediction:
          $ref: '#/components/schemas/deepfake_prediction'
        score:
          $ref: '#/components/schemas/deepfake_score'
      required: [prediction, score]

    mask_estimations:
      type: object
      description: Raw mask estimations.
      properties:
        medical_mask:
          allOf:
          - $ref: '#/components/schemas/estimation_not_nullable'
          description: The probability that the `medical mask` exists on the face and is worn properly.
        missing:
          allOf:
          - $ref: '#/components/schemas/estimation_not_nullable'
          description: The probability that the `medical mask` doesn't exist on the face.
        occluded:
          allOf:
          - $ref: '#/components/schemas/estimation_not_nullable'
          description: The probability that the face is occluded by other object (not by `medical mask`).
      required: [medical_mask, missing, occluded]
      example: {medical_mask: 0.1, missing: 0.2, occluded: 0.3}

    mask_predominant:
      type: string
      enum: [medical_mask, missing, occluded]
      description: Most likely mask state.

    mask:
      type: object
      description: Estimated face mask state.
      properties:
        estimations:
          $ref: '#/components/schemas/mask_estimations'
        predominant_mask:
          $ref: '#/components/schemas/mask_predominant'
      required: [estimations, predominant_mask]

    descriptor_base64_with_version:
      description: Descriptor with descriptor version in the json format.
      type: object
      properties:
        descriptor:
          description: Raw descriptor bytes encoded in base64.
          type: string
          format: base64
        descriptor_version:
          description: Descriptor version.
          type: integer
          example: 52
      required: [descriptor, descriptor_version]

    descriptor_binary_with_version:
      description: Raw descriptor with version.
      type: object
      properties:
        descriptor:
          description: Raw descriptor bytes.
          type: string
          format: binary
        descriptor_version:
          description: Descriptor version.
          type: integer
          example: 52
      required: [descriptor, descriptor_version]

    empty_string:
      type: string
      enum: [""]
      description: No descriptor found.

    event_deletion_info:
      type: array
      items:
        type: object
        properties:
          event_id:
            $ref: '#/components/schemas/event_id'
          face_samples:
            description: Array of face sample IDs.
            type: array
            items:
              $ref: '#/components/schemas/sample_id'
            minItems: 0
            uniqueItems: true
          body_samples:
            description: Array of body sample IDs.
            type: array
            items:
              $ref: '#/components/schemas/sample_id'
            minItems: 0
            uniqueItems: true
          image_origins:
            description: Array of image origins.
            type: array
            items:
              $ref: '#/components/schemas/image_origin'
            minItems: 0
            uniqueItems: true
        required: [ event_id ]
      minItems: 0
      maxItems: 10000

    removed_descriptors_event_list:
      type: object
      properties:
        event_ids:
          type: array
          description: Event IDs which descriptors were removed.
          items:
            $ref: '#/components/schemas/event_id'
          maxItems: 10000
      required: [event_ids]

    EventsWithMissingAttributes:
      type: object
      properties:
        events:
          type: array
          items:
            type: object
            properties:
              event_id:
                $ref: '#/components/schemas/event_id'
              samples:
                description: |
                    Either face sample IDs (for `basic_attributes` or `face_descriptor` kinds) or body sample IDs (for
                    `body_descriptor` kind).
                type: array
                items:
                  $ref: '#/components/schemas/sample_id'
            required: [event_id]
          minItems: 0
          maxItems: 1000
      required: [events]

    EventsWithMissingAttributesCount:
      type: object
      properties:
        events_count:
          type: integer
          description: Count of events.
          example: 55
      required: [events_count]

    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: events_db
            error:
              error_code: 0
              desc: Success
              detail: Success
              link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0"
            status: 1
          - component: events_db_migration
            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
  
    plugin_status:
      type: object
      properties:
        name:
          type: string
          description: Plugin name
        running:
          allOf:
            - $ref: '#/components/schemas/int01'
            - description: Whether plugin is running or not.
      required: [name, running]

    plugins:
      type: object
      properties:
        plugins:
          description: list of imported plugins
          type: array
          items:
            $ref: '#/components/schemas/plugin_status'
      required: [plugins]
      example:
        plugins:
          - name: foo
            running: 1
  
  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'

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

      summary: get version
      description: Get version of service.
      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/events/{event_id}:
    parameters:
      - $ref: '#/components/parameters/event_id'

    head:
      tags:
      - events
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/account_id'
      summary: check event
      description: Check event existence by ID.
      operationId: checkEvent
      responses:
        '200':
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        '404':
          description: Event not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
        '500':
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
      - events
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/get_event_target'
      - $ref: '#/components/parameters/account_id'

      summary: get event
      description: |
        Get event by ID.
        If target is not set, reply will contain all event fields.
      operationId: getEvent
      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/Event'
        '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 'target'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        '404':
          description: Event 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: 23001
                desc: Object not found
                detail: Event with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-23001"
        '500':
          $ref: '#/components/responses/internal_server_error'

    patch:
      tags:
        - events
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/application_json_or_msgpack_content'
        - $ref: '#/components/parameters/account_id'

      summary: patch event
      description: Update event by ID.
      operationId: patchEvent
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/event_for_update_json'
          application/msgpack:
            schema:
              $ref: '#/components/schemas/event_for_update_msgpack'
        required: true
      responses:
        '204':
          description: Update success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        '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_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: "Failed to validate input json. Path: 'face_attributes',  message: face_attributes must be object"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022"
                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"
            application/msgpack:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_msgpack:
                  value:
                    error_code: 12047
                    desc: Bad/incomplete input data
                    detail: "Failed to validate input msgpack. Path: 'face_attributes',  message: face_attributes must be object"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12047"
        '404':
          description: Event 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: 23001
                desc: Object not found
                detail: Event with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-23001"
        '500':
          $ref: '#/components/responses/internal_server_error'
  /2/events:
    get:
      tags:
      - events
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/get_event_target'
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/create_time__gte'
      - $ref: '#/components/parameters/create_time__lt'
      - $ref: '#/components/parameters/end_time__gte'
      - $ref: '#/components/parameters/end_time__lt'
      - $ref: '#/components/parameters/sources'
      - $ref: '#/components/parameters/stream_ids'
      - $ref: '#/components/parameters/top_matching_candidates_label'
      - $ref: '#/components/parameters/top_similar_object_ids'
      - $ref: '#/components/parameters/top_similar_external_ids'
      - $ref: '#/components/parameters/top_similar_object_similarity__gte'
      - $ref: '#/components/parameters/top_similar_object_similarity__lt'
      - $ref: '#/components/parameters/age__lt'
      - $ref: '#/components/parameters/age__gte'
      - $ref: '#/components/parameters/gender'
      - $ref: '#/components/parameters/emotions'
      - $ref: '#/components/parameters/masks'
      - $ref: '#/components/parameters/ethnic_groups'
      - $ref: '#/components/parameters/liveness'
      - $ref: '#/components/parameters/deepfake'
      - $ref: '#/components/parameters/apparent_gender'
      - $ref: '#/components/parameters/apparent_age__gte'
      - $ref: '#/components/parameters/apparent_age__lt'
      - $ref: '#/components/parameters/headwear_states'
      - $ref: '#/components/parameters/headwear_colors'
      - $ref: '#/components/parameters/sleeve_lengths'
      - $ref: '#/components/parameters/upper_clothing_colors'
      - $ref: '#/components/parameters/lower_garment_types'
      - $ref: '#/components/parameters/lower_garment_colors'
      - $ref: '#/components/parameters/shoes_colors'
      - $ref: '#/components/parameters/backpack_states'
      - $ref: '#/components/parameters/face_ids'
      - $ref: '#/components/parameters/event_ids'
      - $ref: '#/components/parameters/event_id__gte_sorting'
      - $ref: '#/components/parameters/event_id__lt_sorting'
      - $ref: '#/components/parameters/handler_ids'
      - $ref: '#/components/parameters/external_ids'
      - $ref: '#/components/parameters/user_data'
      - $ref: '#/components/parameters/tags'
      - $ref: '#/components/parameters/cities'
      - $ref: '#/components/parameters/areas'
      - $ref: '#/components/parameters/districts'
      - $ref: '#/components/parameters/streets'
      - $ref: '#/components/parameters/house_numbers'
      - $ref: '#/components/parameters/origin_longitude'
      - $ref: '#/components/parameters/origin_latitude'
      - $ref: '#/components/parameters/longitude_delta'
      - $ref: '#/components/parameters/latitude_delta'
      - $ref: '#/components/parameters/track_ids'
      - $ref: '#/components/parameters/meta'
      - $ref: '#/components/parameters/search_order'
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/page_size'

      summary: get events
      description: |
        Get events that satisfy filters.

        Default filters for events:

          - `create_time__lt` - current datetime
          - `create_time__gte` - current datetime minus month

          > **Default filters are not used if any of the following parameters are defined**:

            - list of event IDs (`event_ids`)
            - lower event ID boundary (`event_id__gte`)
            - upper event ID boundary (`event_id__lt`)
            - lower create time boundary (`create_time__gte`)
            - upper create time boundary (`create_time__lt`)

        The `target` parameter determines field that will be shown for each event.
        If target is not set, the response will contain all the fields, except the descriptor data.

        To count events, use <a href="#tag/events-stats">"get statistics on events"</a> request.
      operationId: getEvents
      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/EventsWithoutCount'
        '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"
        '422':
          description: Unprocessable.
          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:
                cannot_cast_jsonb:
                  value:
                    error_code: 10020
                    desc: Database error
                    detail: |
                      SQL request execution failed due to incompatible user-defined filters: cannot cast jsonb string to type integer
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-10020"
        '500':
          $ref: '#/components/responses/internal_server_error'

    post:
      tags:
      - events
      summary: create new events
      description: Creates new events.
      operationId: createEvents
      parameters:
        - $ref: '#/components/parameters/luna_account_id_required'
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/application_json_or_msgpack_content'
        - $ref: '#/components/parameters/wait_events_saving'
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/new_event_json'
              minItems: 1
          application/msgpack:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/new_event_msgpack'
              minItems: 1
        required: true
      responses:
        '202':
          description: Events data is received. Events will be saved to the database soon.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        '204':
          description: Events were created and stored in the database.
          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_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: "Failed to validate input json. Path: 'face_attributes.basic_attributes.age',  message: 'face_attributes.basic_attributes.age must be smaller than or equal to 100'"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022"
                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"
            application/msgpack:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_msgpack:
                  value:
                    error_code: 12047
                    desc: Bad/incomplete input data
                    detail: "Failed to validate input msgpack. Path: 'face_attributes.basic_attributes.age',  message: 'face_attributes.basic_attributes.age must be smaller than or equal to 100'"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12047"
        '409':
          description: Event 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'
              examples:
                duplicated_id:
                  value:
                    error_code: 23003
                    desc: Unique constraint error
                    detail: "One or more event id from '1231531' already exist"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-23003"
        '500':
          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'
              examples:
                events_saving_error:
                  value:
                    error_code: 23010
                    desc: internal server error
                    detail: Unknown error
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-23010"
                save_events_timeout:
                  value:
                    error_code: 23007
                    desc: Internal server error
                    detail: Timeout (5 seconds) for save events into history database has been expired
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-23007"
                common_error:
                  value:
                    error_code: 1
                    detail: internal server error
                    desc: internal server error
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-1"

    delete:
      tags:
      - events
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/delete_event_target'
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/handler_id'
      - $ref: '#/components/parameters/create_time__gte'
      - $ref: '#/components/parameters/create_time__lt'
      - $ref: '#/components/parameters/insert_time__gte'
      - $ref: '#/components/parameters/insert_time__lt'

      summary: delete events
      description: Delete oldest 10000 events that satisfy filters.
      operationId: deleteEvents
      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/event_deletion_info'
        '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 'handler_id'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        '500':
          $ref: '#/components/responses/internal_server_error'
  /2/events/attributes/missing:
    get:
      tags:
      - administration
      parameters:
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/kind'
      - $ref: '#/components/parameters/insert_time__gte'
      - $ref: '#/components/parameters/insert_time__lt'
      - $ref: '#/components/parameters/event_id__gte'
      - $ref: '#/components/parameters/event_id__lt'
      - $ref: '#/components/parameters/handler_id'
      - $ref: '#/components/parameters/missing_version'
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/page_size'

      summary: get events with missing attributes
      description: |
        Get events with samples and with missing attributes that satisfy filters.

      operationId: getEventsMissing
      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/EventsWithMissingAttributes'
        '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 'insert_time__lt'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        '500':
          $ref: '#/components/responses/internal_server_error'
  /2/events/attributes/missing/count:
    get:
      tags:
      - administration
      parameters:
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/kind'
      - $ref: '#/components/parameters/insert_time__gte'
      - $ref: '#/components/parameters/insert_time__lt'
      - $ref: '#/components/parameters/event_id__gte'
      - $ref: '#/components/parameters/event_id__lt'
      - $ref: '#/components/parameters/handler_id'
      - $ref: '#/components/parameters/missing_version'

      summary: get count of events with missing attributes
      description: |
        Get count of events with samples and with missing attributes that satisfy filters.

      operationId: getEventsMissingCount
      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/EventsWithMissingAttributesCount'
        '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 'insert_time__lt'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        '500':
          $ref: '#/components/responses/internal_server_error'
  /2/events/descriptors:
    delete:
      tags:
      - administration
      parameters:
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/event_id__gte'
      - $ref: '#/components/parameters/event_id__lt'
      - $ref: '#/components/parameters/descriptor_version_required'
      - $ref: '#/components/parameters/descriptor_type_required'

      summary: delete events descriptors
      description: Delete 10000 event descriptors that satisfy filters.

      operationId: deleteDescriptors
      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/removed_descriptors_event_list'
        '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 'event_id__lt'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        '500':
          $ref: '#/components/responses/internal_server_error'
  /2/events/{event_id}/descriptor:
    parameters:
      - $ref: '#/components/parameters/event_id'

    get:
      tags:
      - event descriptor
      parameters:
      - $ref: '#/components/parameters/accept'
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/descriptor_version'
      - $ref: '#/components/parameters/descriptor_type'

      summary: get event descriptor
      description: Get event descriptor that corresponds to the specified parameters.
      operationId: getEventDescriptor
      responses:
        '200':
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json_or_xbinary'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/descriptor_base64_with_version'
            application/x-sdk-descriptor:
              schema:
                type: string
                format: binary
                description: Content type is application/x-sdk-descriptor, a binary descriptor is returned in the response body.
              example: "<a binary descriptor in the SDK format>"
        '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 'descriptor_version'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012"
        '404':
          description: Object 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:
                event_not_found:
                  value:
                    error_code: 23001
                    desc: Object not found
                    detail: Event with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-23001"
                face_descriptor_not_found:
                  value:
                    error_code: 22018
                    desc: Object not found
                    detail: Face descriptor of version 7 is not found for object with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-22018"
                human_descriptor_not_found:
                  value:
                    error_code: 23007
                    desc: Object not found
                    detail: Human descriptor of version 7 is not found for object with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-23007"
        '500':
          $ref: '#/components/responses/internal_server_error'
  /2/events/stats:
    post:
      tags:
      - events stats
      summary: get statistics on events
      description: |
        Get event statistics by target(s) with applied filters.

        Event fields and/or functions (count, min, etc.) can be set as targets for aggregation of events.

        Grouping by frequency or grouping by time intervals is available.
      operationId: getEventStats
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/getEventStats'
            example:
              targets:
                - column: event_id
                  aggregator: count
                - column: age
                  aggregator: group_by
                - column: gender
                  aggregator: group_by
              filters:
                - column: source
                  operator: eq
                  value: Main_hall_camera
                - column: geo_position
                  operator: covered
                  value:
                    origin_longitude: 37
                    origin_latitude: 55
                    longitude_delta: 0.04
                    latitude_delta: 0.04

              period:
                - operator: gt
                  value: 2020-02-04T00:00:00Z
                - operator: lt
                  value: 2020-02-06T00:00:00Z
              group_by: dayOfWeek
        required: true
      responses:
        '200':
          description: Created.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  fields:
                    type: array
                    items:
                      type: string
                    description: |
                      Reply structure description includes is as follows:
                      - First element of a list is 'Group by time' section if request includes time or frequency grouping.
                      - Other elements are pairs of columns and aggregators for the columns.

                      List of columns and aggregators presents in the same order as in stats.
                  stats:
                    type: array
                    description: grouped values array.
                    items:
                      type: array
                      items:
                        description: |
                          grouped values. Value order is corresponding to order of request targets order.
                        nullable: true
                        anyOf:
                          - type: integer
                          - type: number
                          - type: string
                      minItems: 1
              examples:
                count_dayOfWeek:
                  value:
                    fields:
                      - "Group by time: dayOfWeek"
                      - "gender, aggregator 'group_by'"
                      - "age, aggregator 'group_by'"
                      - "event_id, aggregator 'count'"
                    stats:
                    - - Tuesday
                      - 0
                      - 22
                      - 45
                    - - Tuesday
                      - 0
                      - 27
                      - 23
                    - - Tuesday
                      - 1
                      - 27
                      - 45
                    - - Wednesday
                      - 0
                      - 25
                      - 34
                    - - Wednesday
                      - 1
                      - 33
                      - 345

        '400':
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''Additional properties are not allowed (''userdata'' was unexpected)'''
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022"
        '422':
          description: Unprocessable.
          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:
                cannot_cast_jsonb:
                  value:
                    error_code: 10020
                    desc: Database error
                    detail: |
                      SQL request execution failed due to incompatible user-defined filters: cannot cast jsonb string to type integer
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-10020"
        '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
                    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'
  /2/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'
  /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: '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'
  /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'
      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'