openapi: 3.0.0
info:
  version: 'v.2.14.1'
  title: 'Luna-Sender API'
  description: |
          VisionLabs Luna Sender API.

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

servers:
- description: SwaggerHub API Auto Mocking.
  url: https://virtserver.swaggerhub.com/visionlabs/luna-sender/v.2.14.1

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

    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
        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. Format is "{timestamp},{uuid}".
      required: true

    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:
    luna_request_id:
      in: header
      schema:
        type: string
        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 is "{timestamp},{uuid}". It will be returned with response.
      name: Luna-Request-Id

    gender:
      in: query
      name: gender
      schema:
        type: integer
        enum: [0, 1]
      description: Gender. 1 - male, 0 - female.
      example: 1

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

        | ethnicity   | value |
        |-----------------|---|
        | AfricanAmerican | 1 |
        | Indian          | 2 |
        | Asian           | 3 |
        | Caucasian       | 4 |

      example: "1,2"

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

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

      example: "0,2"

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

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

      example: "0,1"

    masks:
      in: query
      name: masks
      schema:
        type: string
        format: list of integer (1, 2, 3)
      description: |
        Comma-separated list of predominant masks. 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"

    emotions:
      in: query
      name: emotions
      schema:
        type: string
        format: list of integer (1, 2, 3, 4, 5, 6, 7)
      description: |
        Comma-separated list of predominant emotions. Each event from result will contain one of the given emotions.

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

    tags:
      in: query
      name: tags
      schema:
        type: array
        items:
          $ref: '#/components/schemas/tag'
        minItems: 0
      explode: false
      description: |
        A comma-separated list of tags. Each event from result will contain all of the given tags.
        Each tag can be at most 36 characters.
      example:
        - tag_1
        - tag_2

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

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

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

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

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

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

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

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

    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.

    matching_candidates_labels:
      in: query
      name: matching_candidates_labels
      schema:
        type: string
      description: Matching candidates labels. Each event from result will contain one or more given labels.
      example: "matching_label"

    object_similarity__gte:
      in: query
      name: object_similarity__gte
      schema:
        type: number
      description: Similar object similarity lower included bound (boundary for top matching candidate).
      example: 0.5

    object_similarity__lt:
      in: query
      name: object_similarity__lt
      schema:
        type: number
      description: Top similar object similarity upper excluded bound (boundary for top matching candidate).
      example: 0.5

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

    score_threshold:
      in: query
      name: score_threshold
      schema:
        $ref: '#/components/schemas/score_threshold'
      description: |
        Descriptor quality score threshold. All the attributes with quality score below the threshold will be
        ignored (and not stored in the DB). The function will proceed as usual with all the remaining descriptors
        (if left).

    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.

    required_luna_account_id:
      in: header
      name: Luna-Account-Id
      required: true
      schema:
        type: string
        format: uuid
        example: 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: Account ID. Specify an account ID to be noticed about events in the account.

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

    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.

    apparent_gender:
      in: query
      name: apparent_gender
      schema:
        type: integer
        enum: [ 0, 1, 2 ]
      description: |
        Comma-separated list of apparent gender: 0 - female, 1 - male, 2 - undefined. 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: integer
        enum: [ 0, 1, 2 ]
      description: |
        Comma-separated list of headwear states: 0 - absent, 1 - present, 2 - undefined. Each event from result will contain one of the given states.
      example: 1

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

    upper_clothing_colors:
      in: query
      name: upper_clothing_colors
      schema:
        $ref: "#/components/schemas/expanded_palette"
      description: |
        Comma-separated list of upper clothing colors. Each event from result will contain at least one of the given clothing colors.
      example: black,white

    lower_garment_colors:
      in: query
      name: lower_garment_colors
      schema:
        $ref: "#/components/schemas/expanded_palette"
      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

    lower_garment_types:
      in: query
      name: lower_garment_types
      schema:
        type: string
        enum: [ trousers, shorts, skirt, undefined ]
      description: |
        Comma-separated list of lower garment types 0 - trousers, 1 - shorts, 2 - skirt, 3 - undefined. Each event from result will contain at least one of the given types.
      example: trousers,skirt

    shoes_colors:
      in: query
      name: shoes_colors
      schema:
        $ref: "#/components/schemas/short_palette"
      description: |
        Comma-separated list of shoes colors. Each event from result will contain at least one of the given colors.
      example: black,white

    headwear_colors:
      in: query
      name: headwear_colors
      schema:
        $ref: "#/components/schemas/short_palette"
      description: |
        Comma-separated list of headwear colors. Each event from result will contain at least one of the given colors.
      example: black,white

    backpack_states:
      in: query
      name: backpack_states
      schema:
        type: integer
        enum: [ 0, 1, 2 ]
      description: |
        Comma-separated list of backpack states: 0 - absent, 1 - present, 2 - undefined. Each event from result will contain one of the given states.
      example: 1

    user_data:
      in: query
      name: user_data
      schema:
        type: string
      description: |
        User data filter. Each event from result will contain user data that matches the filter value.
        For example, events with user data of *abcd* and *cdef* will match the filter value *cd*.
      example: some%20special%20user%20info

    geo_position:
      in: query
      name: geo_position
      explode: false
      schema:
        type: object
        properties:
          origin_longitude:
            type: float
            minimum: -180
            maximum: 180
            description: Geo bbox origin longitude, in degrees.
          origin_latitude:
            type: float
            minimum: -90
            maximum: 90
            description: Geo bbox origin latitude, in degrees.
          longitude_delta:
            type: float
            minimum: 0
            maximum: 90
            default: 0.01
            description: Geo bbox longitude delta, in degrees.
          latitude_delta:
            type: float
            minimum: 0
            maximum: 90
            default: 0.01
            description: Geo bbox latitude delta, in degrees.
        required: [ origin_longitude, origin_latitude ]
      description: |
        Geo position filter, i.e. geo bounding box specified by coordinates of its center (origin) and some delta. Each event from result will be covered by bbox specified.
      example:
          origin_longitude: 36.616
          origin_latitude: 55.752
  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/

    account_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: ID of the luna account.

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

    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

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

    number01:
      type: number
      minimum: 0
      maximum: 1

    face_id:
      allOf:
      - $ref: '#/components/schemas/uuid'
      description: Face ID.

    event_id:
      allOf:
      - $ref: '#/components/schemas/uuid'
      description: Event ID.

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

    list_id:
      allOf:
      - $ref: '#/components/schemas/uuid'
      description: List ID.

    age:
      type: integer
      minimum: 0
      maximum: 100
      description: Age.
      example: 50

    gender:
      type: integer
      enum: [0, 1]
      description: Gender, 0 - female, 1 - male.

    glasses:
      type: object
      description: Estimated glasses.
      properties:
        glasses:
          type: string
          enum: [no_glasses, eyeglasses, sunglasses]
          description: Glasses estimation.
      required: [glasses]

    liveness:
      type: object
      description: Liveness prediction.
      properties:
        prediction:
          type: string
          enum: [spoof, real, unknown]
          description: Liveness prediction name.
        estimations:
          type: object
          description: Liveness estimations.
          properties:
            quality:
              allOf:
                - $ref: '#/components/schemas/number01'
              description: Liveness quality score.
            score:
              allOf:
                - $ref: '#/components/schemas/number01'
              description: Liveness prediction score.
          required: [quality, score]
      required: [prediction, estimations]
      example:
        prediction: spoof
        estimations:
          quality: 0.2
          score: 0.7

    deepfake:
      type: object
      description: Deepfake prediction.
      properties:
        prediction:
          type: string
          enum: [fake, real]
          description: Deepfake prediction name.
        score:
          allOf:
            - $ref: '#/components/schemas/number01'
          description: Deepfake prediction score.
      required: [prediction, score]
      example:
        prediction: fake
        score: 0.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.

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

      type: integer
      enum: [0, 1]

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

      description: |
        Predominant mask.

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


    tags:
      description: List of tags.
      type: array
      items:
        $ref: '#/components/schemas/tag'
      example: ['tag1', 'tag2']
      minItems: 1
      maxItems: 1000

    emotion:
       type: integer
       enum: [1,2,3,4,5,6,7]
       description: |
         Emotions enum.

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

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

      description: |
        Ethnic group.

        | ethnicity   | value |
        |-----------------|---|
        | AfricanAmerican | 1 |
        | Indian          | 2 |
        | Asian           | 3 |
        | Caucasian       | 4 |

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

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

    masks:
      type: object
      description: Estimated face mask state.
      properties:
        estimations:
          $ref: '#/components/schemas/mask_estimations'
        predominant_mask:
          $ref: '#/components/schemas/mask_predominant'
        face_occlusion:
          type: object
          description: Estimated face occlusion.
          properties:
            predominant_occlusion:
              type: string
              enum: ["full", "clear", "correct", "partially", "mouth", "chin"]
              description: The most likely face occlusion state.
            estimations:
              type: object
              description: Raw face occlusion estimations scores.
              properties:
                full:
                  allOf:
                  - $ref: '#/components/schemas/number01'
                  description: The probability that the mask occlude whole face.
                clear:
                  allOf:
                  - $ref: '#/components/schemas/number01'
                  description: The probability that the mask absent.
                correct:
                  allOf:
                  - $ref: '#/components/schemas/number01'
                  description: The probability that the mask is put on correctly.
                partially:
                  allOf:
                  - $ref: '#/components/schemas/number01'
                  description: The probability that the mask is put on partially correct.
                mouth:
                  allOf:
                  - $ref: '#/components/schemas/number01'
                  description: The probability that the mask is put on mouth only.
                chin:
                  allOf:
                  - $ref: '#/components/schemas/number01'
                  description: The probability that the mask is put on chin only.
              required: [full, clear, correct, partially, mouth, chin]
          required: [predominant_occlusion, estimations]
      required: [estimations, predominant_mask, face_occlusion]

    top_match_face:
      type: object
      properties:
        label:
          $ref: '#/components/schemas/top_matching_candidates_label'
        similarity:
          description: Similarity to the most similar face.
          type: number
          example: 0.7
        face_id:
          allOf:
          - $ref: '#/components/schemas/face_id'
          nullable: true
        external_id:
          allOf:
          - $ref: '#/components/schemas/external_id'
          nullable: true
      required: [label, similarity, face_id, external_id]

    top_match_event:
      type: object
      properties:
        label:
          $ref: '#/components/schemas/top_matching_candidates_label'
        similarity:
          description: Similarity to the most similar event.
          type: number
          example: 0.7
        event_id:
          allOf:
          - $ref: '#/components/schemas/event_id'
          nullable: true
        external_id:
          allOf:
          - $ref: '#/components/schemas/external_id'
          nullable: true
      required: [label, similarity, event_id, external_id]

    face_candidates_in_target_match_result:
      type: array
      items:
        type: object
        properties:
          similarity:
            description: Similarity to the most similar face.
            type: number
            example: 0.7
          face:
            type: object
            properties:
              face_id:
                allOf:
                  - $ref: '#/components/schemas/face_id'
                nullable: true
              external_id:
                allOf:
                - $ref: '#/components/schemas/face_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]
        required: [similarity, face]

    event_candidates_in_target_match_result:
      type: array
      items:
        type: object
        properties:
          similarity:
            description: Similarity to the most similar event.
            type: number
            example: 0.7
          event:
            type: object
            properties:
              event_id:
                allOf:
                  - $ref: '#/components/schemas/event_id'
                nullable: true
              external_id:
                allOf:
                  - $ref: '#/components/schemas/event_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/event_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]
        required: [similarity, event]

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

    score_threshold:
      type: number
      minimum: 0
      maximum: 1
      example: 0.99
      default: 0
      description: |
        Descriptor quality score threshold. All the attributes with quality score below the threshold will be
        ignored (and not stored in the DB). The function will proceed as usual with all the remaining descriptors
        (if left).

    int_version:
      type: integer
      minimum: 0

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

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

    time:
      type: string
      format: date-time
      example: "2021-06-18T02:44:58.653485+03:00"
      description: Time in format RFC 3339.

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

    longitude:
      type: number
      minimum: -180
      maximum: 180
      description: Longitude in degrees.
      example: 36.616

    latitude:
      type: number
      minimum: -90
      maximum: 90
      description: Latitude in degrees.
      example: 55.752

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

    source:
      description: Additional information that user provides with event.
      type: string
      example: "3rd Avenue"

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

    location:
      type: object
      properties:
        city:
          type: string
          description: City where event is incidented.
          nullable: true
          example: "Moscow"
        area:
          type: string
          description: Area where event is incidented.
          nullable: true
          example: "CAO"
        district:
          type: string
          description: District where event is incidented.
          nullable: true
          example: "mitino"
        street:
          type: string
          description: Street where event is incidented.
          nullable: true
          example: "schepkina"
        house_number:
          type: string
          description: House number where event is incidented.
          nullable: true
          example: "1/2str3"
        geo_position:
          allOf:
          - $ref: '#/components/schemas/geo_position'
          nullable: true

    event_from_ws:
      type: object
      description: Event format from handler.
      properties:
        face_attributes:
          allOf:
            - $ref: '#/components/schemas/Attribute'
          description: Extracted attributes from samples.
          nullable: true
        body_attributes:
          type: object
          description: Body attributes extracted from samples.
          nullable: true
          properties:
            score:
              type: number
              minimum: 0
              maximum: 1
              description: Quality of body descriptor.
            samples:
              type: array
              items:
                $ref: '#/components/schemas/uuid'
              example: ['a3e8716f-70dc-42ad-8428-7a552e800a37']
              description: resource for attributes.
          required: [score, samples]
        source:
          type: string
          description: Additional information that user provides with event.
          nullable: true
          example: "3rd Avenue"
        stream_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - nullable: true
          description: Stream id.
        tags:
          description: tag array.
          type: array
          items:
            $ref: '#/components/schemas/tag'
          example: ['tag1', 'tag2']
        event_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: Event id.
        url:
          type: string
          format: uri
          example: /0/events/24d405ce-bc56-4bf7-98e1-bdc962b4cf34
          description: Location of event.
          nullable: true
        matches:
          $ref: '#/components/schemas/Matches'
        external_id:
          $ref: '#/components/schemas/event_external_id'
        user_data:
          $ref: '#/components/schemas/event_user_data'
        location:
          $ref: '#/components/schemas/location'
        detections:
          type: array
          description: All detections which was generated the event.
          items:
            type: object
            properties:
              filename:
                type: string
                example: "penelope.jpeg"
              samples:
                type: object
                properties:
                  face:
                    allOf:
                      - $ref: '#/components/schemas/Face_Detection'
                    nullable: true
                  body:
                    allOf:
                      - $ref: '#/components/schemas/Body_Detection'
                    nullable: true
                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: [filename, samples, detect_time, image_origin, detect_ts]
        aggregate_estimations:
          $ref: '#/components/schemas/event_aggregate_estimations'
        track_id:
          allOf:
            - $ref: '#/components/schemas/track_id'
          nullable: true
        face:
          type: object
          nullable: true
          properties:
            external_id:
              $ref: '#/components/schemas/face_external_id'
            face_id:
              $ref: '#/components/schemas/face_id'
            url:
              $ref: '#/components/schemas/url'
            lists:
              $ref: '#/components/schemas/lists'
            user_data:
              $ref: '#/components/schemas/face_user_data'
            avatar:
              type: string
              default: ""
              description: Avatar for the face, references to a sample or a user-defined reference.
            event_id:
              allOf:
                - $ref: '#/components/schemas/uuid'
              description: Event ID associated with the face creation.
          required: [external_id, face_id, url,  lists, user_data, avatar, event_id]
        meta:
          $ref: "#/components/schemas/event_meta"
      required: [face_attributes, body_attributes, source, stream_id, tags, event_id, url, matches, external_id, user_data,
                 location, detections, aggregate_estimations, track_id, face, meta]

    emotions_estimations:
      type: object
      properties:
        anger:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: Anger probability.
        disgust:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: Disgust probability.
        fear:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: Fear probability.
        happiness:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: Happiness probability.
        neutral:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: Neutral face probability.
        sadness:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: Sadness probability.
        surprise:
          type: number
          format: double
          maximum: 1
          minimum: 0
          description: Surprise probability.
      required: [surprise, sadness, neutral, happiness, fear, disgust, anger]
      description: Emotion classifier response.

    emotions:
      type: object
      properties:
        estimations:
          allOf:
          - $ref: '#/components/schemas/emotions_estimations'
          description: Emotion classifier response.
        predominant_emotion:
          type: string
          description: Name of predominant emotion.
          enum: [surprise, sadness, neutral, happiness, fear, disgust, anger]
      required: [estimations, predominant_emotion]

    landmark:
      type: array
      items:
        type: integer
      description: |
        Key point coordinates. First element is `x` coordinate, second is `y`.
      minItems: 2
      maxItems: 2
      example: [12, 13]

    landmarks5:
      type: array
      items:
        $ref: '#/components/schemas/landmark'
      description: Array of 5 landmarks.
      minItems: 5
      maxItems: 5
      example:
      - - 23
        - 72
      - - 82
        - 71
      - - 42
        - 114
      - - 29
        - 140
      - - 79
        - 138

    landmarks68:
      description: Array of 68 landmarks.
      type: array
      items:
        $ref: '#/components/schemas/landmark'
      minItems: 68
      maxItems: 68

    landmarks32:
      description: Array of 32 landmarks.
      type: array
      items:
        $ref: '#/components/schemas/landmark'
      minItems: 32
      maxItems: 32

    mouth_attributes:
      description: Mouth attributes.
      type: object
      properties:
        score:
          allOf:
          - $ref: '#/components/schemas/number01'
          description: Mouth detection confidence (always 1).
        smile:
          allOf:
          - $ref: '#/components/schemas/number01'
          description: Smile probability.
        opened:
          allOf:
          - $ref: '#/components/schemas/number01'
          description: Opened mouth probability.
        occluded:
          allOf:
          - $ref: '#/components/schemas/number01'
          description: Occlusion probability.
      required: [score, smile, occluded, opened]
    eye_attributes:
      description: Eye attributes.
      type: object
      properties:
        state:
          type: string
          enum: [open, closed, occluded]
          description: Eye state.
        iris_landmarks:
          allOf:
          - $ref: '#/components/schemas/landmarks32'
          description: Iris landmarks.
      required: [state, iris_landmarks]

    eyes_attributes:
      description: Eyes attributes.
      type: object
      properties:
        left_eye:
          allOf:
          - $ref: '#/components/schemas/eye_attributes'
          description: Left eye attributes.
        right_eye:
          allOf:
          - $ref: '#/components/schemas/eye_attributes'
          description: Right eye attributes.
      required: [left_eye, right_eye]

    head_pose:
      description: Head pose.
      type: object
      properties:
        yaw:
          type: number
          description: Yaw angle in degrees.
        pitch:
          type: number
          description: Pitch angle in degrees.
        roll:
          type: number
          description: Roll angle in degrees.
      required: [yaw, pitch, roll]

    eye_gaze:
      type: object
      properties:
        yaw:
          type: number
          description: Yaw angle in degrees.
        pitch:
          type: number
          description: Pitch angle in degrees.
      required: [yaw, pitch]

    attributes:
      description: Face attributes.
      type: object
      properties:
        mouth_attributes:
          allOf:
          - $ref: '#/components/schemas/mouth_attributes'
          description: Optional mouth attributes.
        eyes_attributes:
          allOf:
          - $ref: '#/components/schemas/eyes_attributes'
          description: Optional eye attributes.
        emotions:
          allOf:
          - $ref: '#/components/schemas/emotions'
          description: Face emotions estimation.
        mask:
          allOf:
            - $ref: '#/components/schemas/masks'
          description: Face mask estimation.
        head_pose:
          allOf:
          - $ref: '#/components/schemas/head_pose'
          description: Head pose estimation.
        gaze:
          allOf:
          - $ref: '#/components/schemas/eye_gaze'
          description: Gaze estimation.
        glasses:
          $ref: '#/components/schemas/glasses'
        liveness:
          $ref: '#/components/schemas/liveness'
        deepfake:
          $ref: '#/components/schemas/deepfake'
        face_occlusion:
          $ref: '#/components/schemas/face_occlusion'
      example:
        liveness:
          prediction: "spoof"
          estimations:
            score: 0.5108324766
            quality: 0.7190976739
        deepfake:
          prediction: "fake"
          score: 0.5108324766
        face_occlusion:
          prediction: 0
          estimations:
            overall_score: 0.01
            hair_score: 0.02
            lower_face_score: 0.012
            nose_score: 0.002
            mouth_score: 0.003
            forehead_score: 0.012
            left_eye_score: 0.032
            right_eye_score: 0.021
          face_occlusion:
            lower_face_occluded: 0
            mouth_occluded: 0
            nose_occluded: 0
            left_eye_occluded: 0
            right_eye_occluded: 0
            forehead_occluded: 0
        mouth_attributes:
          occluded: 0.0
          opened: 0.121500025545354
          score: 0.999999165534973
          smile: 0.0
        eyes_attributes:
          left_eye:
            iris_landmarks: [ [ 92, 92 ], [ 92, 92 ], [ 93, 93 ], [ 93, 93 ], [ 94, 94 ], [ 95, 95 ], [ 96, 96 ], [ 98, 98 ], [ 99, 99 ], [ 100, 100 ], [ 101, 101 ], [ 102, 102 ], [ 103, 103 ], [ 104, 104 ], [ 105, 105 ], [ 105, 105 ], [ 105, 105 ], [ 105, 105 ], [ 105, 105 ], [ 104, 104 ], [ 103, 103 ], [ 102, 102 ], [ 101, 101 ], [ 100, 100 ], [ 99, 99 ], [ 98, 98 ], [ 97, 97 ], [ 96, 96 ], [ 95, 95 ], [ 94, 94 ], [ 93, 93 ], [ 93, 93 ]]
            state: open
          right_eye:
            iris_landmarks: [ [ 152, 152 ], [ 153, 153 ], [ 153, 153 ], [ 154, 154 ], [ 154, 154 ], [ 155, 155 ], [ 157, 157 ], [ 158, 158 ], [ 159, 159 ], [ 161, 161 ], [ 162, 162 ], [ 163, 163 ], [ 164, 164 ], [ 165, 165 ], [ 166, 166 ], [ 166, 166 ], [ 166, 166 ], [ 166, 166 ], [ 166, 166 ], [ 165, 165 ], [ 164, 164 ], [ 163, 163 ], [ 162, 162 ], [ 161, 161 ], [ 159, 159 ], [ 158, 158 ], [ 158, 158 ], [ 157, 157 ], [ 156, 156 ], [ 154, 154 ], [ 154, 154 ], [ 153, 153 ]]
            state: open
        emotions:
          estimations:
            anger: 0.00894705578684807
            disgust: 0.00000965219624049496
            fear: 0.00121302821207792
            happiness: 0.00129503419157118
            neutral: 0.986027479171753
            sadness: 0.00187553185969591
            surprise: 0.000632198702078313
          predominant_emotion: "neutral"
        mask:
          estimations:
            medical_mask: 0.7108324766
            missing: 0.0700698048
            occluded: 0.2190976739
          predominant_mask: "medical_mask"

        head_pose:
          pitch: 18.6827487945557
          roll: -10.3542232513428
          yaw: 15.4102487564087
        gaze:
          pitch: 10.7074518203735
          yaw: -14.6733160018921
        glasses:
          glasses: no_glasses

    rect:
      description: Bounding rectangle.
      type: object
      properties:
        height:
          type: integer
          description: Rectangle height.
          format: int32
          example: 200
        width:
          type: integer
          description: Rectangle width.
          format: int32
          example: 100
        x:
          type: integer
          description: Top left corner "x" coordinate.
          format: int32
          example: 17
        y:
          type: integer
          description: Top left corner "y" coordinate.
          format: int32
          example: 10
      required: [height, width, x, y]
      example:
        height: 240
        width: 209
        x: 170
        y: 198

    quality:
      description: |
        Image quality. Estimation of image visual properties.
      type: object
      properties:
        blurriness:
          type: number
          description: Low value means blurred image (e.g. due to depth of field or motion blur). High value means sharp image.
          maximum: 1
          minimum: 0
        dark:
          type: number
          description: Low value means underlit face area (i.e. due to backlight, poor lighting, sensor underexposure).
          maximum: 1
          minimum: 0
        illumination:
          type: number
          description: Low value means low illumination (e.g. low-contrast images).
          maximum: 1
          minimum: 0
        specularity:
          type: number
          description: Low value means low saturation (e.g. color-incorrect images).
          maximum: 1
          minimum: 0
        light:
          type: number
          description: Low value means overexposed face area (i.e. overbright lighting, sensor overexposure).
          maximum: 1
          minimum: 0
      required: [blurriness, dark, illumination, specularity, light]
      example:
        light: 0.87
        dark: 0.13
        illumination: 0.82
        blurriness: 0.2
        specularity: 0.84

    detect_time:
      allOf:
        - $ref: "#/components/schemas/time"
      description: Detection time.
      example: "2021-06-18T02:44:58.653485+03:00"

    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: The image url - source of the detection.
      nullable: true
      example: "/6/images/b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    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 ]

    body_basic_attributes_not_nullable:
      allOf:
      - $ref: "#/components/schemas/body_basic_attributes"
      nullable: false

    expanded_palette:
      description: |
        expanded color palette for clothing
        
        > **WARNING** This enum may be to expand. This field must be interpret as arbitrary string which can be equal 
        to one element from enum.
      type: string
      enum: [ black, blue, green, gray, orange, purple, red, white, yellow, pink, brown, beige, khaki, multicolored, undefined ]

    short_palette:
      description: |
        short color palette
        
        > **WARNING** This enum may be to expand. This field must be interpret as arbitrary string which can be equal 
        to one element from enum.
      type: string
      enum: [ black, other, white, undefined ]

    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:
              allOf:
                - $ref: "#/components/schemas/short_palette"
              description: |
                Headwear apparent color.
                
                > **WARNING** This enum may be to expand. This field must be interpret as arbitrary string which can be equal 
                to one element from enum.
              nullable: true
          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/expanded_palette"
              description: Upper clothing color set.
          required: [ colors ]
          description: Upper clothing attibutes.
      required: [ headwear, sleeve, upper_clothing ]

    upper_body_attributes_not_nullable:
      allOf:
      - $ref: "#/components/schemas/upper_body_attributes"
      nullable: false

    lower_garment_type:
      type: string
      enum: [ skirt, shorts, trousers, undefined ]
      description: |
        lower garment type.
        
        > **WARNING** This enum may be to expand. This field must be interpret as arbitrary string which can be equal 
        to one element from enum.

    lower_body_attributes:
      type: object
      description: Lower body attributes.
      nullable: true
      properties:
        shoes:
          type: object
          properties:
            apparent_color:
              allOf:
                - $ref: "#/components/schemas/short_palette"
              description: |
                Shoes apparent color.

                > **WARNING** This enum may be to expand. This field must be interpret as arbitrary string which can be equal
                to one element from enum.
          required: [ apparent_color ]
          description: shoes attributes.
        lower_garment:
          type: object
          properties:
            colors:
              type: array
              items:
                $ref: "#/components/schemas/expanded_palette"
              description: |
                lower garment color set.

                > **WARNING** This enum may be to expand. This field must be interpret as arbitrary string which can be equal 
                to one element from enum.
            type:
              $ref: "#/components/schemas/lower_garment_type"
          required: [ colors ]
          description: Lower garment attibutes.
      required: [ lower_garment, shoes ]

    lower_body_attributes_not_nullable:
      allOf:
      - $ref: "#/components/schemas/lower_body_attributes"
      nullable: false

    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 ]

    body_accessories_not_nullable:
      allOf:
      - $ref: "#/components/schemas/body_accessories"
      nullable: false

    body_attributes:
      type: object
      description: Body attributes.
      properties:
        basic_attributes:
          $ref: '#/components/schemas/body_basic_attributes_not_nullable'
        upper_body:
          $ref: '#/components/schemas/upper_body_attributes_not_nullable'
        lower_body:
          $ref: '#/components/schemas/lower_body_attributes_not_nullable'
        accessories:
          $ref: '#/components/schemas/body_accessories_not_nullable'
      example:
        basic_attributes:
          apparent_age: 0
          apparent_gender: 0
        upper_body:
          headwear:
            state: 0
          sleeve:
            length: "short"
          upper_clothing:
            colors: ["black"]
        accessories:
          backpack:
            state: 0

    body_detection:
      type: object
      description: Body detection.
      properties:
        rect:
          allOf:
          - $ref: '#/components/schemas/rect'
          - description: Body detection bounding box.
        attributes:
          $ref: '#/components/schemas/body_attributes'

    Body_Detection:
      type: object
      properties:
        sample_id:
          allOf:
          - $ref: '#/components/schemas/uuid'
          nullable: true
        detection:
          $ref: '#/components/schemas/body_detection'
        url:
          type: string
          format: uri
          example: /0/samples/a16c8b6c-2818-4bae-9fd5-65acc8d4bb5c
          nullable: true
      required: [detection, sample_id, url]

    image_format_threshold:
      type: array
      items:
        type: string
        enum: [ JPEG, JPEG2000, PNG ]
      default: [ JPEG, JPEG2000, PNG ]
      description: List of allowed image formats.

    face_check_name:
      type: string
      description: Unique estimation name.

    face_check_result:
      type: integer
      enum: [ 0, 1 ]
      description: Check result (1 - succeeded, 0 - failed).

    face_object_value_score:
      type: number
      format: double
      minimum: 0
      maximum: 1
      nullable: true
      description: Estimated value as a number.
      example: 0.15675428

    face_object_value_number:
      type: number
      format: double
      nullable: true
      description: Estimated value as a number.
      example: 0.15675428

    face_object_value_int_positive:
      type: integer
      minimum: 0
      nullable: true
      description: Estimated value as an integer.
      example: 1

    iso_object_value_string:
      type: string
      nullable: true
      description: Estimated value as a string.

    face_threshold_value_int_positive:
      type: object
      properties:
        min:
          type: integer
          minimum: 0
          nullable: true
          description: Lower bound of the allowed range.
          example: 0
        max:
          type: integer
          minimum: 0
          nullable: true
          description: Upper bound of the allowed range.
          example: 1
      required: [ min, max ]
      description: Allowed range of the estimation value.

    face_threshold_value_number:
      type: object
      properties:
        min:
          type: number
          nullable: true
          description: Lower bound of the allowed range.
          example: 0
        max:
          type: number
          nullable: true
          description: Upper bound of the allowed range.
          example: 1
      required: [ min, max ]
      description: Allowed range of the estimation value.

    face_check_element_number:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/face_check_name'
        object_value:
          $ref: '#/components/schemas/face_object_value_number'
        threshold_value:
          $ref: '#/components/schemas/face_threshold_value_number'
        result:
          $ref: '#/components/schemas/face_check_result'
      required: [ name, object_value, threshold_value, result ]

    face_check_element_int_positive:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/face_check_name'
        object_value:
          $ref: '#/components/schemas/face_object_value_int_positive'
        threshold_value:
          $ref: '#/components/schemas/face_threshold_value_int_positive'
        result:
          $ref: '#/components/schemas/face_check_result'
      required: [ name, object_value, threshold_value, result ]

    face_check_element_score:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/face_check_name'
        object_value:
          $ref: '#/components/schemas/face_object_value_score'
        threshold_value:
          $ref: '#/components/schemas/face_threshold_value_number'
        result:
          $ref: '#/components/schemas/face_check_result'
      required: [ name, object_value, threshold_value, result ]

    face_check_element_string:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/face_check_name'
        object_value:
          $ref: '#/components/schemas/iso_object_value_string'
        threshold_value:
          type: array
          items:
            type: string
          description: List of estimation values allowed.
        result:
          $ref: '#/components/schemas/face_check_result'
      required: [ name, object_value, threshold_value, result ]

    check_result:
      type: integer
      enum: [ 0, 1 ]
      description: Check result (1 - succeeded, 0 - failed).

    check_image_format:
      type: object
      properties:
        name:
          type: string
          enum: [ image_format ]
          description: Unique estimation name.
        object_value:
          type: string
          nullable: true
          enum: [ JPEG, JPEG2000, PNG, BMP, TIFF, Portable pixmap ]
          description: Original image format.
          example: JPEG
        threshold_value:
          $ref: '#/components/schemas/image_format_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]
      description: Checking the image format meets the standart.

    check_image_quality:
      allOf:
        - $ref: '#/components/schemas/face_check_element_score'
        - properties:
            name:
              enum: [ blurriness_quality, specularity_quality, illumination_quality, dark_quality, light_quality ]
        - description: Checking the image quality.

    check_glasses_state:
      allOf:
        - $ref: '#/components/schemas/face_check_element_string'
        - properties:
            name:
              enum: [ glasses ]
            object_value:
              type: string
              enum: [ no_glasses, eyeglasses, sunglasses ]
              example: eyeglasses
        - description: Checking eyes state.

    check_eyes_state:
      allOf:
        - $ref: '#/components/schemas/face_check_element_string'
        - properties:
            name:
              enum: [ left_eye, right_eye ]
            object_value:
              type: string
              enum: [ open, occluded, closed ]
              example: occluded
        - description: Checking eyes state.

    check_gaze_direction:
      allOf:
        - $ref: '#/components/schemas/face_check_element_number'
        - properties:
            name:
              enum: [ gaze_pitch, gaze_yaw ]
        - description: Checking the gaze direction angles.

    check_mouth_state:
      allOf:
        - $ref: '#/components/schemas/face_check_element_score'
        - properties:
            name:
              enum: [ mouth_open, mouth_smiling, mouth_occluded ]
        - description: Checking the mouth state.

    check_head_rotation:
      allOf:
        - $ref: '#/components/schemas/face_check_element_number'
        - properties:
            name:
              enum: [ head_pitch, head_roll, head_yaw ]
        - description: Checking the head rotation angles.

    check_head_position:
      allOf:
        - $ref: '#/components/schemas/face_check_element_number'
        - properties:
            name:
              enum: [ head_horizontal_center, head_vertical_center ]
        - description: Checking the head position is normally centered in relation to the original image.

    check_head_proportions:
      allOf:
        - $ref: '#/components/schemas/face_check_element_number'
        - properties:
            name:
              enum: [ head_width, head_height ]
        - description: Checking the head width & height are normal in relation to the size of the image.

    check_eye_distance:
      allOf:
        - $ref: '#/components/schemas/face_check_element_number'
        - properties:
            name:
              enum: [ eye_distance ]
        - description: Checking the distance between the eyes is sufficient.

    check_image_properties:
      allOf:
        - $ref: '#/components/schemas/face_check_element_int_positive'
        - properties:
            name:
              enum: [ image_width, image_height, image_size ]
        - description: Checking the image width & height (in pixels) and the image size (in bytes).

    check_aspect_ratio:
      allOf:
        - $ref: '#/components/schemas/face_check_element_number'
        - properties:
            name:
              enum: [ aspect_ratio ]
        - description: Checking the image width to height aspect ratio.

    check_face_properties:
      allOf:
        - $ref: '#/components/schemas/face_check_element_int_positive'
        - properties:
            name:
              enum: [ face_width, face_height, indent_left, indent_right, indent_upper, indent_lower ]
        - description: Checking the face width, height and horizontal and vertical indents (in pixels).

    check_face_illumination_uniformity:
      allOf:
        - $ref: '#/components/schemas/face_check_element_score'
        - properties:
            name:
              enum: [ illumination_uniformity, dynamic_range ]
        - description: Checking the face uniformity and dynamic illumination.

    eyebrow:
      type: string
      enum: ["squinting", "frowning", "raised", "neutral"]

    eyebrows_threshold:
      type: array
      items:
        $ref: '#/components/schemas/eyebrow'
      description: List of successful values.
      minItems: 1

    eyebrows_state:
      description: Eyebrows_state check.
      type: object
      properties:
        name:
          type: string
          enum: ["eyebrows_state"]
          description: Unique estimation name.
        object_value:
          allOf:
            - $ref: '#/components/schemas/eyebrow'
            - nullable: true
              description: eyebrows_state estimated value.
        threshold_value:
          $ref: '#/components/schemas/eyebrows_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]

    shoulders_position:
      type: string
      enum: ["non-parallel", "parallel", "hidden"]

    shoulders_position_threshold:
      type: array
      items:
        $ref: '#/components/schemas/shoulders_position'
      description: List of values to consider successful.
      minItems: 1

    shoulders_position_status:
      title: shoulders_position
      description: Shoulders position status check.
      type: object
      properties:
        name:
          type: string
          enum: ["shoulders_position"]
          description: Unique estimation name.
        object_value:
          allOf:
            - $ref: '#/components/schemas/shoulders_position'
            - nullable: true
              description: Eyebrows_state estimated value.
        threshold_value:
          $ref: '#/components/schemas/shoulders_position_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]

    headwear:
      type: string
      enum: ["none", "baseball_cap", "beanie", "peaked_cap", "shawl", "hat_with_earflaps", "helmet", "hood", "hat", "other"]

    headwear_threshold:
      type: array
      items:
        $ref: '#/components/schemas/headwear'
      description: List of successful values.
      minItems: 1

    headwear_type:
      description: headwear_type check.
      type: object
      properties:
        name:
          type: string
          enum: ["headwear_type"]
          description: Unique estimation name.
        object_value:
          allOf:
            - $ref: '#/components/schemas/headwear'
            - nullable: true
              description: Estimated value for headwear_type.
        threshold_value:
          $ref: '#/components/schemas/headwear_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]

    smile:
      type: string
      enum: ["none", "smile_lips", "smile_teeth"]

    smile_threshold:
      type: array
      items:
        $ref: '#/components/schemas/smile'
      description: List of successful values.
      minItems: 1

    smile_properties:
      type: object
      properties:
        name:
          type: string
          enum: ["smile_properties"]
          description: Unique estimation name.
        object_value:
          allOf:
            - $ref: '#/components/schemas/smile'
            - nullable: true
              description: smile_properties estimated value.
        threshold_value:
          $ref: '#/components/schemas/smile_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]
      description: smile_properties check.

    bool_threshold:
      type: integer
      enum: [ 0, 1 ]
      description: Value to consider successful.

    natural_light:
      type: object
      properties:
        name:
          type: string
          enum: ["natural_light"]
          description: Unique estimation name.
        object_value:
          nullable: true
          type: integer
          enum: [ 0, 1 ]
          description: Estimated value, 1 - detected face has a natural light, 0 - face lighting is not natural.
        threshold_value:
          $ref: '#/components/schemas/bool_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]
      description: natural_light estimation.

    radial_distortion:
      description: radial_distortion check.
      type: object
      properties:
        name:
          type: string
          enum: ["radial_distortion"]
          description: Unique estimation name.
        object_value:
          nullable: true
          type: integer
          enum: [ 0, 1 ]
          description: Estimated value, 1 - the detection has a radial distortion, 0 - there is no radial distortion.
        threshold_value:
          $ref: '#/components/schemas/bool_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]

    red_eyes:
      type: object
      description: red_eyes check.
      properties:
        name:
          type: string
          enum: ["red_eyes"]
          description: Unique estimation name.
        object_value:
          nullable: true
          type: integer
          enum: [ 0, 1 ]
          description: Estimated value, 1 - the detection has a red-eye effect, 0 - there is no red-eye effect.
        threshold_value:
          $ref: '#/components/schemas/bool_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]

    face_occlusion_face_quality:
      type: object
      properties:
        name:
          type: string
          enum: [ "face_occlusion" ]
          description: Unique estimation name.
        object_value:
          nullable: true
          type: integer
          enum: [ 0, 1 ]
          description: Estimated value, 1 - detected face has an overlap, 0 - face is not overlapped.
        threshold_value:
          $ref: '#/components/schemas/bool_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]
      description: face_occlusion estimation.

    lower_face_occlusion_face_quality:
      type: object
      properties:
        name:
          type: string
          enum: [ "lower_face_occlusion" ]
          description: estimation name.
        object_value:
          nullable: true
          type: integer
          enum: [ 0, 1 ]
          description: Estimated value, 1 - detected face has an overlap on lower face, 0 - lower face is not overlapped.
        threshold_value:
          $ref: '#/components/schemas/bool_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]
      description: lower_face_occlusion estimation.

    forehead_occlusion_face_quality:
      type: object
      properties:
        name:
          type: string
          enum: [ "forehead_occlusion" ]
          description: estimation name.
        object_value:
          nullable: true
          type: integer
          enum: [ 0, 1 ]
          description: Estimated value, 1 - forehead is overlapped by something, 0 - forehead is not overlapped.
        threshold_value:
          $ref: '#/components/schemas/bool_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]
      description: forehead_occlusion estimation.

    nose_occlusion_face_quality:
      type: object
      properties:
        name:
          type: string
          enum: [ "nose_occlusion" ]
          description: estimation name.
        object_value:
          nullable: true
          type: integer
          enum: [ 0, 1 ]
          description: Estimated value, 1 - nose is overlapped by something, 0 - nose is not overlapped.
        threshold_value:
          $ref: '#/components/schemas/bool_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]
      description: nose_occlusion estimation.

    face_color:
      type: string
      enum: ["color", "grayscale", "infrared"]

    face_color_type_threshold:
      type: array
      items:
        $ref: '#/components/schemas/face_color'
      description: List of values to consider successful.
      minItems: 1

    face_color_type:
      type: object
      description: face_color_type check.
      properties:
        name:
          type: string
          enum: ["face_color_type"]
          description: Unique estimation name.
        object_value:
          allOf:
            - $ref: '#/components/schemas/face_color'
            - nullable: true
              description: face_color_type estimated value.
        threshold_value:
          $ref: '#/components/schemas/face_color_type_threshold'
        result:
          $ref: '#/components/schemas/check_result'
      required: [ name, object_value, threshold_value, result ]

    background_uniformity:
      allOf:
        - $ref: '#/components/schemas/face_check_element_score'
        - properties:
            name:
              enum: [ background_uniformity ]
        - description:  Face detection background uniformity check.

    background_lightness:
      allOf:
      - $ref: '#/components/schemas/face_check_element_score'
      - properties:
          name:
            enum: [background_lightness]
      - description: Face detection background lightness check.

    face_quality_checks_reply:
      type: array
      description: Face quality container with all estimates.
      items:
        oneOf:
          - $ref: '#/components/schemas/check_image_format'
          - $ref: '#/components/schemas/check_image_quality'
          - $ref: '#/components/schemas/check_glasses_state'
          - $ref: '#/components/schemas/check_eyes_state'
          - $ref: '#/components/schemas/check_gaze_direction'
          - $ref: '#/components/schemas/check_mouth_state'
          - $ref: '#/components/schemas/check_head_rotation'
          - $ref: '#/components/schemas/check_head_position'
          - $ref: '#/components/schemas/check_head_proportions'
          - $ref: '#/components/schemas/check_eye_distance'
          - $ref: '#/components/schemas/check_image_properties'
          - $ref: '#/components/schemas/check_aspect_ratio'
          - $ref: '#/components/schemas/check_face_properties'
          - $ref: '#/components/schemas/eyebrows_state'
          - $ref: '#/components/schemas/headwear_type'
          - $ref: '#/components/schemas/smile_properties'
          - $ref: '#/components/schemas/natural_light'
          - $ref: '#/components/schemas/radial_distortion'
          - $ref: '#/components/schemas/red_eyes'
          - $ref: '#/components/schemas/face_color_type'
          - $ref: '#/components/schemas/check_face_illumination_uniformity'
          - $ref: '#/components/schemas/background_uniformity'
          - $ref: '#/components/schemas/background_lightness'
          - $ref: '#/components/schemas/shoulders_position_status'
          - $ref: '#/components/schemas/face_occlusion_face_quality'
          - $ref: '#/components/schemas/lower_face_occlusion_face_quality'
          - $ref: '#/components/schemas/nose_occlusion_face_quality'
          - $ref: '#/components/schemas/forehead_occlusion_face_quality'

      minItems: 0
      uniqueItems: true
      example:
        [
          {
            "name": image_format,
            "object_value": JPEG,
            "threshold_value": [ JPEG, JPEG2000, PNG ],
            "result": 1
          },
          {
            "name": illumination_quality,
            "object_value": 0.6005162000656128,
            "threshold_value": { "min": 0.3, "max": 1 },
            "result": 1
          },
          {
            "name": specularity_quality,
            "object_value": 0.7662366628646851,
            "threshold_value": { "min": 0.3, "max": 1 },
            "result": 1
          },
          {
            "name": blurriness_quality,
            "object_value": 0.9429352283477783,
            "threshold_value": { "min": 0.61, "max": 1 },
            "result": 1
          },
          {
            "name": dark_quality,
            "object_value": 0.9020983576774597,
            "threshold_value": { "min": 0.5, "max": 1 },
            "result": 1
          },
          {
            "name": light_quality,
            "object_value": 0.7881984114646912,
            "threshold_value": { "min": 0.57, "max": 1 },
            "result": 1
          },
          {
            "name": head_yaw,
            "object_value": 2.818983316421509,
            "threshold_value": { "min": -5.0, "max": 5.0 },
            "result": 1
          },
          {
            "name": head_pitch,
            "object_value": 3.816443920135498,
            "threshold_value": { "min": -5.0, "max": 5.0 },
            "result": 1
          },
          {
            "name": head_roll,
            "object_value": 5.434040069580078,
            "threshold_value": { "min": -8.0, "max": 8.0 },
            "result": 1
          },
          {
            "name": gaze_yaw,
            "object_value": -3.773012399673462,
            "threshold_value": { "min": -5.0, "max": 5.0 },
            "result": 1
          },
          {
            "name": gaze_pitch,
            "object_value": 0.7140519022941589,
            "threshold_value": { "min": -5.0, "max": 5.0 },
            "result": 1
          },
          {
            "name": mouth_smiling,
            "object_value": 0.000290759839117527,
            "threshold_value": { "min": 0, "max": 0.5 },
            "result": 1
          },
          {
            "name": mouth_occluded,
            "object_value": 9.619363845558837e-05,
            "threshold_value": { "min": 0, "max": 0.3 },
            "result": 1
          },
          {
            "name": mouth_open,
            "object_value": 0.6226108074188232,
            "threshold_value": { "min": 0, "max": 0.64 },
            "result": 1
          },
          {
            "name": glasses,
            "object_value": no_glasses,
            "threshold_value": [ no_glasses, eyeglasses ],
            "result": 1
          },
          {
            "name": left_eye,
            "object_value": open,
            "threshold_value": [ open ],
            "result": 1
          },
          {
            "name": right_eye,
            "object_value": open,
            "threshold_value": [ open ],
            "result": 1
          },
          {
            "name": head_horizontal_center,
            "object_value": 0.51,
            "threshold_value": { "min": 0.45, "max": 0.55 },
            "result": 1
          },
          {
            "name": head_vertical_center,
            "object_value": 0.51,
            "threshold_value": { "min": 0.3, "max": 0.5 },
            "result": 1
          },
          {
            "name": head_width,
            "object_value": 0.61,
            "threshold_value": { "min": 0.5, "max": 0.75 },
            "result": 1
          },
          {
            "name": head_height,
            "object_value": 0.71,
            "threshold_value": { "min": 0.6, "max": 0.9 },
            "result": 1
          },
          {
            "name":eye_distance,
            "object_value": 110,
            "threshold_value": { "min": 90, "max": null },
            "result": 1
          },
          {
            "name": image_width,
            "object_value": 1000,
            "threshold_value": { "min": 200, "max": 1100 },
            "result": 1
          },
          {
            "name": image_height,
            "object_value": 2000,
            "threshold_value": { "min": 200, "max": 1100 },
            "result": 1
          },
          {
            "name": aspect_ratio,
            "object_value": 0.5,
            "threshold_value": { "min": 0.1, "max": 1.0 },
            "result": 1
          },
          {
            "name": face_width,
            "object_value": 500,
            "threshold_value": { "min": 400, "max": 600 },
            "result": 1
          },
          {
            "name": face_height,
            "object_value": 500,
            "threshold_value": { "min": 400, "max": 600 },
            "result": 1
          },
          {
            "name": indent_left,
            "object_value": 100,
            "threshold_value": { "min": 10, "max": 500 },
            "result": 1
          },
          {
            "name": indent_right,
            "object_value": 100,
            "threshold_value": { "min": 10, "max": 500 },
            "result": 1
          },
          {
            "name": indent_upper,
            "object_value": 100,
            "threshold_value": { "min": 10, "max": 500 },
            "result": 1
          },
          {
            "name": indent_lower,
            "object_value": 100,
            "threshold_value": { "min": 10, "max": 500 },
            "result": 1
          },
          {
            "name": image_size,
            "object_value": 100500,
            "threshold_value": { "min": 10, "max": 100600 },
            "result": 1
          },
          {
            "name": eyebrows_state,
            "object_value": "neutral",
            "threshold_value": ["neutral"],
            "result": 1
          },
          {
            "name": smile_properties,
            "object_value": "smile_lips",
            "threshold_value": ["none"],
            "result": 0
          },
          {
            "name": headwear_type,
            "object_value": "hat",
            "threshold_value": ["none"],
            "result": 0
          },
          {
            "name": natural_light,
            "object_value": 1,
            "threshold_value": 1,
            "result": 1
          },
          {
            "name": radial_distortion,
            "object_value": 0,
            "threshold_value": 0,
            "result": 1
          },
          {
            "name": red_eyes,
            "object_value": 0,
            "threshold_value": 0,
            "result": 1
          },
          {
            "name": face_color_type,
            "object_value": "color",
            "threshold_value": ["color"],
            "result": 1
          },
          {
            "name": illumination_uniformity,
            "object_value": 0.6305162000656128,
            "threshold_value": { "min": 0.5, "max": 1.0 },
            "result": 1
          },
          {
            "name": dynamic_range,
            "object_value": 0.8605162000656128,
            "threshold_value": { "min": 0.5, "max": 1.0 },
            "result": 1
          },
          {
            "name": background_lightness,
            "object_value": 0.5780888795852661,
            "threshold_value": { "min": 0.2, "max": 1.0 },
            "result": 1
          },
          {
            "name": background_uniformity,
            "object_value": 0.8874394297599792,
            "threshold_value": { "min": 0.5, "max": 1.0 },
            "result": 1
          },
          {
            "name": shoulders_position,
            "object_value": "parallel",
            "threshold_value": ["parallel"],
            "result": 1
          }
        ]

    face_quality_checks_estimations:
      type: object
      description: Face quality estimations checks.
      properties:
        status:
          type: integer
          enum: [ 0, 1 ]
          description: Check status for all estimates.
        checks:
          $ref: '#/components/schemas/face_quality_checks_reply'
      required: [ status, checks ]

    face_occlusion:
      description: Face occlusion estimation
      type: object
      properties:
        prediction:
          allOf:
            - $ref: '#/components/schemas/int01'
            - description: overall prediction. A face overlap area is greater or not of `occlusion_threshold`
        estimations:
          description: Estimation scores
          type: object
          properties:
            overall_score:
              allOf:
                - $ref: '#/components/schemas/number01'
                - description: overlapped face area (takin the `hair_occlusion_threshold` parameter).
            hair_score:
              allOf:
                - $ref: '#/components/schemas/number01'
                - description: overlapped face area by hair.
            lower_face_score:
              allOf:
                - $ref: '#/components/schemas/number01'
                - description: |
                    score of overlapped area of a lower face. The area is measuremented relativity of a lower face area 
                    (not all face area), 1 means that all lower face area is overlapped.
            nose_score:
              allOf:
                - $ref: '#/components/schemas/number01'
                - description: |
                    score of overlapped area of a nose. The area is measuremented relativity of a nose area 
                    (not all face area), 1 means that all nose area is overlapped.
            mouth_score:
              allOf:
                - $ref: '#/components/schemas/number01'
                - description: |
                    score of overlapped area of a mouth. The area is measuremented relativity of a mouth area 
                    (not all face area), 1 means that all mouth area is overlapped.
            forehead_score:
              allOf:
                - $ref: '#/components/schemas/number01'
                - description: |
                    score of overlapped area of a forehead. The area is measuremented relativity of a forehead area 
                    (not all face area), 1 means that all overlapped area is overlapped.
            left_eye_score:
              allOf:
                - $ref: '#/components/schemas/number01'
                - description: |
                    score of overlapped area of a left eye. The area is measuremented relativity of a left eye area 
                    (not all face area), 1 means that all left eye area is overlapped
            right_eye_score:
              allOf:
                - $ref: '#/components/schemas/number01'
                - description: |
                    score of overlapped area of a right eye. The area is measuremented relativity of a right eye area 
                    (not all face area), 1 means that all right eye area is overlapped
          required: [overall_score, hair_score, lower_face_score, nose_score, mouth_score, forehead_score,
                     left_eye_score, right_eye_score]
        face_occlusion:
          description: an occlusion predict by each area
          type: object
          properties:
            lower_face_occluded:
              allOf:
                - $ref: '#/components/schemas/int01'
                - description: lower face is overlapped or not
            mouth_occluded:
              allOf:
                - $ref: '#/components/schemas/int01'
                - description: mouth is overlapped or not
            nose_occluded:
              allOf:
                - $ref: '#/components/schemas/int01'
                - description: nose is overlapped or not
            left_eye_occluded:
              allOf:
                - $ref: '#/components/schemas/int01'
                - description: left eye is overlapped or not
            right_eye_occluded:
              allOf:
                - $ref: '#/components/schemas/int01'
                - description: right eye is overlapped or not
            forehead_occluded:
              allOf:
                - $ref: '#/components/schemas/int01'
                - description: forehead is overlapped or not
          required: [lower_face_occluded, mouth_occluded, nose_occluded, left_eye_occluded, right_eye_occluded,
                     forehead_occluded]
      required: [prediction, estimations, face_occlusion]
      example:
        prediction: 0
        estimations:
          overall_score: 0.01
          hair_score: 0.02
          lower_face_score: 0.012
          nose_score: 0.002
          mouth_score: 0.003
          forehead_score: 0.012
          left_eye_score: 0.032
          right_eye_score: 0.021
        face_occlusion:
          lower_face_occluded: 0
          mouth_occluded: 0
          nose_occluded: 0
          left_eye_occluded: 0
          right_eye_occluded: 0
          forehead_occluded: 0

    Face_Detection:
      type: object
      properties:
        sample_id:
          allOf:
          - $ref: '#/components/schemas/sample_id'
          nullable: true
        detection:
          type: object
          properties:
            attributes:
              allOf:
              - $ref: '#/components/schemas/attributes'
              description: Face attributes estimation.
            quality:
              allOf:
              - $ref: '#/components/schemas/quality'
              description: Image quality estimation for this face detection region.
            rect:
              allOf:
              - $ref: '#/components/schemas/rect'
              description: Face detection bounding box.
            landmarks5:
              allOf:
              - $ref: '#/components/schemas/landmarks5'
              description: Facial landmarks.
            landmarks68:
              allOf:
              - $ref: '#/components/schemas/landmarks68'
              description: Facial landmarks.
            face_quality:
              $ref: '#/components/schemas/face_quality_checks_estimations'
        url:
          type: string
          format: uri
          example: /0/samples/a16c8b6c-2818-4bae-9fd5-65acc8d4bb5c
          nullable: true
      required: [detection, sample_id, url]

    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.
      required: [african_american, caucasian, indian, asian]

    ethnicities:
      description: Estimated ethnicities.
      type: object
      properties:
        estimations:
          allOf:
          - $ref: '#/components/schemas/ethnicities_estimations'
          description: Ethnicity classifier response.
        predominant_ethnicity:
          type: string
          description: Name of predominant ethnicity.
      required: [estimations, predominant_ethnicity]
      example:
        estimations:
          african_american: 1.92238889737406e-12
          asian: 0.954671621322632
          caucasian: 0.045328326523304
          indian: 7.65100649502415e-10
        predominant_ethnicity: "asian"

    Attribute:
      type: object
      properties:
        attribute_id:
          allOf:
          - $ref: '#/components/schemas/uuid'
          nullable: true
        basic_attributes:
          type: object
          properties:
            age:
              $ref: '#/components/schemas/age'
            gender:
              $ref: '#/components/schemas/gender'
            ethnicities:
              $ref: '#/components/schemas/ethnicities'
          required: [age, gender, ethnicities]
        score:
          type: number
          minimum: 0
          maximum: 1
          description: Face descriptor quality score.
        url:
          type: string
          format: uri
          example: /0/attributes/24d405ce-bc56-4bf7-98e1-bdc962b4cf34
          description: Location of attributes.
          nullable: true
        samples:
          type: array
          items:
            $ref: '#/components/schemas/uuid'
          example: ['a3e8716f-70dc-42ad-8428-7a552e800a37']
          description: resource for attributes.
      required: [attribute_id, url, samples]

    similarity:
      type: number
      description: Face similarity.
      minimum: 0
      maximum: 1

    url:
      type: string
      description: face url

    event_user_data:
      description: User data associated with face.
      type: string
      maxLength: 128
      default: ""
      example: "some event"

    event_meta:
      type: object
      additionalProperties: true
      description: User defined metadata (json object). Size shouldn't exceed 2MB.
      nullable: true
      example:
        key: value

    face_user_data:
      type: string
      maxLength: 128
      default: ""
      description: User data associated with face.
      example: "face of person"

    external_id:
      description: user-defined external ID.
      type: string
      example: "external id"
      maxLength: 36
      default: ""

    face_external_id:
      allOf:
      - $ref: '#/components/schemas/external_id'
      description: user-defined external ID of a face.

    event_external_id:
      allOf:
      - $ref: '#/components/schemas/external_id'
      description: user-defined external ID of an event.

    detection:
      type: object
      description: Detection.
      properties:
        rect:
          type: object
          description: Detection rectangle.
          properties:
            x:
              type: integer
              description: Detection rectangle x coordinate.
            y:
              type: integer
              description: Detection rectangle y coordinate.
            width:
              type: integer
              description: Detection rectangle width.
            height:
              type: integer
              description: Detection rectangle height.
          required: [ x, y, width, height ]
      required: [ rect ]

    face_candidate:
      type: object
      properties:
        face_id:
          $ref: '#/components/schemas/face_id'
        account_id:
          $ref: '#/components/schemas/account_id'
        external_id:
          $ref: '#/components/schemas/face_external_id'
        user_data:
          $ref: '#/components/schemas/face_user_data'
        create_time:
          allOf:
            - $ref: "#/components/schemas/time"
          description: time of the face creation.
        avatar:
          $ref: '#/components/schemas/avatar'
        lists:
          $ref: '#/components/schemas/lists'
        event_id:
          allOf:
            - $ref: '#/components/schemas/event_id'
          description: Event ID associated with the face creation.
          nullable: true
      example:
        face_id: 426542d6-5509-4e5b-8a01-e2abd5c0a8c6
        external_id: 2xQ2gprbMUePw1s9gw9fvA==
        user_data: fox1991
        create_time: "2021-06-18T02:44:58.653485+03:00"
        lists: ["429b0e78-4616-426a-b57f-02baa72d638d", '6d037c33-31ec-4d73-b3b3-ec80b09446c2']
        avatar: 'https://st.kp.yandex.net/images/actor_iphone/iphone360_460188.jpg'
        event_id: f9687459-986b-406d-9c1f-0d6289be5256

    event_candidate:
      type: object
      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:
          allOf:
            - $ref: '#/components/schemas/event_id'
          description: 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/event_external_id'
        track_id:
          allOf:
            - $ref: '#/components/schemas/track_id'
          nullable: true
        source:
          allOf:
            - $ref: '#/components/schemas/source'
          nullable: true
        stream_id:
          allOf:
            - $ref: '#/components/schemas/stream_id'
          nullable: true
        top_match:
          nullable: true
          description: Top match result from handler match policy.
          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:
            type: object
            properties:
              label:
                $ref: '#/components/schemas/top_matching_candidates_label'
              candidates:
                anyOf:
                  - $ref: '#/components/schemas/face_candidates_in_target_match_result'
                  - $ref: '#/components/schemas/event_candidates_in_target_match_result'
            required: [label, candidates]
        face_detections:
          description: List of all face detections and corresponding sample IDs.
          type: array
          nullable: true
          items:
            type: object
            properties:
              sample_id:
                $ref: '#/components/schemas/sample_id'
              detection:
                $ref: '#/components/schemas/detection'
              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 detections and corresponding sample IDs.
          type: array
          nullable: true
          items:
            type: object
            properties:
              sample_id:
                $ref: '#/components/schemas/sample_id'
              detection:
                $ref: '#/components/schemas/detection'
              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:
          allOf:
          - $ref: '#/components/schemas/body_basic_attributes'
          - nullable: true
        upper_body:
          allOf:
          - $ref: '#/components/schemas/upper_body_attributes'
          - nullable: true
        lower_body:
          allOf:
            - $ref: '#/components/schemas/lower_body_attributes'
            - nullable: true
        accessories:
          allOf:
          - $ref: '#/components/schemas/body_accessories'
          - nullable: true
        face_id:
          allOf:
            - $ref: '#/components/schemas/face_id'
          nullable: true
        attach_result:
          description: Contains attached lists IDs.
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/list_id'
            nullable: true
        gender:
          allOf:
            - $ref: '#/components/schemas/gender'
          nullable: true
        age:
          allOf:
            - $ref: '#/components/schemas/age'
          nullable: true
        emotion:
          allOf:
            - $ref: '#/components/schemas/emotion'
          nullable: true
        mask:
          allOf:
            - $ref: '#/components/schemas/mask_enum'
          nullable: true
        ethnic_group:
          allOf:
            - $ref: '#/components/schemas/ethnic_group'
          nullable: true
        tags:
          allOf:
            - $ref: '#/components/schemas/tags'
          nullable: true
        user_data:
          $ref: '#/components/schemas/event_user_data'
        location:
          $ref: '#/components/schemas/location'
        liveness:
          allOf:
            - $ref: '#/components/schemas/liveness_enum'
          nullable: true
        deepfake:
          allOf:
            - $ref: '#/components/schemas/deepfake_enum'
          nullable: true
        face_occlusion:
          allOf:
            - $ref: '#/components/schemas/face_occlusion'
          nullable: true
        meta:
          $ref: "#/components/schemas/event_meta"

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

    event_match_candidate:
      type: object
      properties:
        event:
          $ref: '#/components/schemas/event_candidate'
        similarity:
          allOf:
            - $ref: '#/components/schemas/similarity'
          description: Event similarity.
      required: [event, similarity]

    top_matching_candidates_label:
      type: string
      maxLength: 36
      example: "matching_label"

    match_candidates_faces:
      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'
      required: [label, candidates]

    match_candidates_events:
      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'
      required: [label, candidates]

    match_candidates:
      anyOf:
        - $ref: '#/components/schemas/match_candidates_faces'
        - $ref: '#/components/schemas/match_candidates_events'

    Matches:
      type: array
      description: Matches list.
      items:
        $ref: '#/components/schemas/match_candidates'
      example:
        [{
           label: good guys,
           candidates: [{
                          face:{
                            face_id: 426542d6-5509-4e5b-8a01-e2abd5c0a8c6,
                            external_id: 2xQ2gprbMUePw1s9gw9fvA==,
                            account_id: 904e635f-3a47-4832-b4d6-d2d72ba78451,
                            user_data: fox1991,
                            create_time: "2021-08-18T02:43:37.196724+03:00",
                            lists: ["429b0e78-4616-426a-b57f-02baa72d638d", '6d037c33-31ec-4d73-b3b3-ec80b09446c2'],
                            avatar: 'https://st.kp.yandex.net/images/actor_iphone/iphone360_460188.jpg',
                            event_id: f9687459-986b-406d-9c1f-0d6289be5256
                          },
                        similarity: 0.5
                        }]},
         {
           label: bad guys,
           candidates: [{
                          event:{
                            event_id: 426542d6-5509-4e5b-8a01-e2abd5c0a8c7,
                            external_id: 2xQ2gprbMUePw1s9gw9fvA==,
                            user_data: fox1991,
                            create_time: "2021-06-18T02:44:58.653485+03:00",
                            handler_id: 426542d6-5509-4e5b-8a01-e2abd5c0a8c7,
                            source: 426542d6-5509-4e5b-8a01-e2abd5c0a8c7
                          },
                        similarity: 0.3
                        }]}]

    Message_from_ws:
      type: object
      properties:
        event:
          $ref: '#/components/schemas/event_from_ws'
        handler_id:
          allOf:
          - $ref: '#/components/schemas/uuid'
          description: ID of the handler, which has produced the event.
        event-create-time:
          description: Event creation time.
          type: string
          format: date-time
        event-end-time:
          description: Event end time.
          type: string
          format: date-time
        Luna-Request-id:
          type: string
          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: ID of the request, which gave birth to the event. Format is "{timestamp},{uuid}".
      required: [event, handler_id, event-create-time, event-end-time, Luna-Request-id]
      description: Example message that will be send by websocket.

    Message_from_general_ws:
      type: object
      properties:
        event:
          description: General event.
          type: object
        event_type:
          description: General event type.
          type: string
        account_id:
          allOf:
          - $ref: '#/components/schemas/uuid'
          description: ID of the account, which has owned the event.
        event-create-time:
          description: Event creation time.
          type: string
          format: date-time
        event-end-time:
          description: Event end time.
          type: string
          format: date-time
      required: [event, event_type]
      description: Example message that will be send by websocket.

    accept_docs_handler:
      type: string
      enum: [application/x-yaml, text/html]

    tag:
      type: string
      example: "good"
      maxLength: 36

    face_aggregation_attributes:
      type: object
      description: estimated attributes.
      properties:
        liveness:
          $ref: "#/components/schemas/liveness"
        deepfake:
          $ref: "#/components/schemas/deepfake"
        mask:
          $ref: '#/components/schemas/masks'
        emotions:
          $ref: '#/components/schemas/emotions'
        face_occlusion:
          $ref: '#/components/schemas/face_occlusion'

    body_aggregation_attributes:
      allOf:
      - $ref: '#/components/schemas/body_attributes'
      description: Aggregated body attributes.

    event_aggregate_estimations:
      type: object
      description: Aggregated attributes estimated from samples.
      properties:
        face:
          type: object
          description: Face aggregated estimations.
          properties:
            attributes:
              $ref: '#/components/schemas/face_aggregation_attributes'
          required: [attributes]
        body:
          type: object
          description: Aggregated body estimations.
          properties:
            attributes:
              $ref: '#/components/schemas/body_aggregation_attributes'
          required: [attributes]
      required: [face, body]

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

    events_to_be_published:
      type: object
      properties:
        events:
          description: User generated events to be published.
          type: array
          items:
            description: Raw event.
            type: object
          minItems: 1
        handler_id:
          description: Event handler ID.
          type: string
        event_create_time:
          description: Event creation time.
          type: string
        event_end_time:
          description: Event end time.
          type: string
      required: [ events, handler_id, event_create_time, event_end_time  ]

    general_events_to_be_published:
      type: object
      properties:
        events:
          description: User generated events to be published.
          type: array
          items:
            description: Raw event.
            type: object
          minItems: 1
        event_type:
          description: General event type.
          type: string
        account_id:
          description: Event account ID.
          type: string
        event_create_time:
          description: Event creation time.
          type: string
        event_end_time:
          description: Event end time.
          type: string
      required: [ events, event_type  ]

    general_event_to_be_published:
      type: object
      properties:
        event:
          description: Raw event.
          type: object
        event_type:
          description: General event type.
          type: string
        account_id:
          description: Event account ID.
          type: string
        event_create_time:
          description: Event creation time.
          type: string
        event_end_time:
          description: Event end time.
          type: string
      required: [ event, event_type  ]

    general_event_input:
      oneOf:
        - $ref: '#/components/schemas/general_event_to_be_published'
        - $ref: '#/components/schemas/general_events_to_be_published'

    plugin_status:
      type: object
      properties:
        name:
          type: string
          description: Plugin name
        running:
          type: integer
          enum: [0, 1]
          description: Whether plugin is running or not.
      required: [name, running]

    plugins:
      type: object
      properties:
        plugins:
          description: list of imported plugins
          type: array
          items:
            $ref: '#/components/schemas/plugin_status'
      required: [plugins]
      example:
        plugins:
          - name: foo
            running: 1
  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 versions of services.
      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/ws:
    get:
      tags:
      - ws
      summary: ws handshake
      description: |
        Ws handshake.
        > ### Attention!
        > **Subscription to events occurs via [WebSocket](https://en.wikipedia.org/wiki/WebSocket).**
        > Messages sent by ws you can view in callback section.
        > Connection supports [autoping](https://tools.ietf.org/html/rfc6455#section-5.5.2).
      operationId: wsHandshake
      parameters:
      - $ref: '#/components/parameters/required_luna_account_id'
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/sources'
      - $ref: '#/components/parameters/stream_ids'
      - $ref: '#/components/parameters/matching_candidates_labels'
      - $ref: '#/components/parameters/object_similarity__gte'
      - $ref: '#/components/parameters/object_similarity__lt'
      - $ref: '#/components/parameters/age__lt'
      - $ref: '#/components/parameters/age__gte'
      - $ref: '#/components/parameters/gender'
      - $ref: '#/components/parameters/ethnic_groups'
      - $ref: '#/components/parameters/liveness'
      - $ref: '#/components/parameters/deepfake'
      - $ref: '#/components/parameters/masks'
      - $ref: '#/components/parameters/emotions'
      - $ref: '#/components/parameters/tags'
      - $ref: '#/components/parameters/user_data'
      - $ref: '#/components/parameters/geo_position'
      - $ref: '#/components/parameters/cities'
      - $ref: '#/components/parameters/areas'
      - $ref: '#/components/parameters/districts'
      - $ref: '#/components/parameters/streets'
      - $ref: '#/components/parameters/house_numbers'
      - $ref: '#/components/parameters/handler_ids'
      - $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/sleeve_lengths'
      - $ref: '#/components/parameters/upper_clothing_colors'
      - $ref: '#/components/parameters/lower_garment_colors'
      - $ref: '#/components/parameters/lower_garment_types'
      - $ref: '#/components/parameters/shoes_colors'
      - $ref: '#/components/parameters/headwear_colors'
      - $ref: '#/components/parameters/backpack_states'

      responses:
        101:
          description: Success handshake.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message_from_ws'
        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:
                oneOf:
                - $ref: '#/components/schemas/Error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'estimate_quality'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        500:
          $ref: '#/components/responses/internal_server_error'
      x-codeSamples:
        - lang: python
          label: sync with luna3
          source: |
            from luna3.sender.wsclient import LunaWSClient

            senderAPI = LunaWSClient(origin="http://127.0.0.1:5080", api=2, accountId="8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a")
            # Note filtering by gender!
            with senderAPI.connect(gender=1) as ws:
                for _ in range(3):
                    resp = ws.recv()
                    print(resp)

        - lang: python
          label: async with luna3
          source: |
            import asyncio
            from luna3.sender.wsclient import LunaWSClient

            async def main():
                senderAPI = LunaWSClient(origin="http://127.0.0.1:5080", api=2, accountId="8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a")
                # Note filtering by gender!
                async with senderAPI.connect(gender=1, asyncRequest=True) as ws:
                    count = 0
                    async for resp in ws:
                        count += 1
                        print(resp.data)
                        if count > 2:
                            await ws.close()
                            raise SystemExit(0)


            asyncio.run(main())

        - lang: python
          label: async with websockets library
          source: |
            import asyncio
            import websockets

            async def main():
                uri = "ws://127.0.0.1:5080/2/ws?gender=1"  # Note filtering by gender!
                headers = {"Luna-Account-Id": "fe2f19a5-0df0-4a75-9d5c-212f7193684a"}
                async with websockets.connect(uri, extra_headers=headers) as websocket:
                    while True:
                        data = await websocket.recv()
                        print(data)


            asyncio.run(main())

        - lang: bash
          label: using curl
          source: |
            curl -i -N \
              -H "Connection: Upgrade" \
              -H "Upgrade: websocket" \
              -H "Sec-WebSocket-Version: 13" \
              -H "Sec-WebSocket-Key: YWFhYWFhYWFhYWFhYWFhYQ==" \
              -H "Luna-Account-Id: 8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a" \
              "http://127.0.0.1:5080/2/ws?shoes_colors=white&lower_garment_types=skirt"
  /2/events:
    post:
      tags: [events]
      summary: publish events
      description: |
        Publish events generated by the user.
      operationId: publishEvent
      parameters:
        - $ref: '#/components/parameters/required_luna_account_id'
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/applicationJsonContent'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/events_to_be_published'
        required: true
      responses:
        204:
          description: Accepted.
          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_input_data:
                  value:
                    error_code: 11027
                    desc: Bad/incomplete input data
                    detail: "Failed to validate input json. Path: 'handler_id',  message: 'field required'"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11027"
                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"
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/general/ws:
    get:
      tags:
      - ws
      summary: ws handshake for general events
      description: |
        Ws handshake.
        > ### Attention!
        > **Subscription to events occurs via [WebSocket](https://en.wikipedia.org/wiki/WebSocket).**
        > Messages sent by ws you can view in callback section.
        > Connection supports [autoping](https://tools.ietf.org/html/rfc6455#section-5.5.2).
      operationId: wsHandshakeForGeneralEvents
      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - in: query
        name: event_type
        schema:
          type: string
          format: list of strings (event_type_1, event_type_1)
        example: some_event_type_1,some_event_type_1
        description: Comma-separated list of general event types to subscribe.
      - in: query
        name: account_id
        schema:
          type: string
        example: 8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a
        description: General event account to subscribe.
      - $ref: '#/components/parameters/stream_ids'
      - $ref: '#/components/parameters/sources'
      - $ref: '#/components/parameters/geo_position'
      - $ref: '#/components/parameters/cities'
      - $ref: '#/components/parameters/areas'
      - $ref: '#/components/parameters/districts'
      - $ref: '#/components/parameters/streets'
      - $ref: '#/components/parameters/house_numbers'
      - in: query
        name: '* (event.path.to.field__operator:type)'
        schema:
          type: string
        description: |
          User-defined general event filters.
          
          Parameter name pattern: `event.<path.to.field>__<operator>:<type>`
          
          Path to field is an event 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:
          event.field_1__gt:numeric: 36.6
          event.field_2.field_3__in: value,none
          event.field_4:integer: 5
          event: null

      responses:
        101:
          description: Success handshake.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message_from_general_ws'
        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:
                oneOf:
                - $ref: '#/components/schemas/Error'
              examples:
                bad_query:
                  value:
                    error_code: 11027
                    desc: Bad/incomplete input data
                    detail: "Failed to validate input json. Path: 'event_type',  message: 'field required'"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11027"
        500:
          $ref: '#/components/responses/internal_server_error'
      x-codeSamples:
        - lang: python
          label: sync with luna3
          source: |
            from luna3.sender.wsclient import LunaWSClient

            senderAPI = LunaWSClient(origin="http://127.0.0.1:5080", api=2)
            with senderAPI.generalConnect(eventType="some_event_type") as ws:
                for _ in range(3):
                    resp = ws.recv()
                    print(resp)

        - lang: python
          label: async with luna3
          source: |
            import asyncio
            from luna3.sender.wsclient import LunaWSClient

            async def main():
                senderAPI = LunaWSClient(origin="http://127.0.0.1:5080", api=2)
                async with senderAPI.generalConnect(eventType="some_event_type", asyncRequest=True) as ws:
                    count = 0
                    async for resp in ws:
                        count += 1
                        print(resp.data)
                        if count > 2:
                            await ws.close()
                            raise SystemExit(0)


            asyncio.run(main())

        - lang: python
          label: async with websockets library
          source: |
            import asyncio
            import websockets

            async def main():
                uri = "ws://127.0.0.1:5080/2/general/ws?event_type=some_event_type"
                async with websockets.connect(uri) as websocket:
                    while True:
                        data = await websocket.recv()
                        print(data)


            asyncio.run(main())

        - lang: bash
          label: using curl
          source: |
            curl -i -N \
              -H "Connection: Upgrade" \
              -H "Upgrade: websocket" \
              -H "Sec-WebSocket-Version: 13" \
              -H "Sec-WebSocket-Key: YWFhYWFhYWFhYWFhYWFhYQ==" \
              "http://127.0.0.1:5080/2/general/ws?event_type=some_event_type"
  /2/general/events:
    post:
      tags: [events]
      summary: publish general events
      description: |
        Publish events generated by the user.
      operationId: publishGeneralEvents
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/applicationJsonContent'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/general_event_input'
        required: true
      responses:
        204:
          description: Accepted.
          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_input_data:
                  value:
                    error_code: 11027
                    desc: Bad/incomplete input data
                    detail: "Failed to validate input json. Path: 'event_type',  message: 'field required'"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11027"
        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'
