openapi: 3.0.0
info:
  version: 'v.1.13.1'
  title: 'Luna Video Agent API'
  description: |
     'VisionLabs Luna Video Agent'

components:
  headers:
    application_json:
      schema:
        type: string
        enum:
        - application/json
      required: true
      description: The content type of the response body.

    luna_request_id:
      schema:
        type: string
        format: timestamp,uuid
        example: 1536751345,8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a
        pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
      description: request id. Helps to uniquely identify messages that correspond to particular requests, in system logs.
      required: true

    docs_content_type:
      schema:
        type: string
        enum:
          - application/x-yaml
          - text/html
      required: true
      description: The content type of the response body.

    text_html:
      schema:
        type: string
        enum:
          - text/html
      required: true
      description: The content type of the response body.

    config_accept_content_type:
      schema:
        type: string
        enum:
          - application/json
          - text/plain
      required: false
      description: The content type of the response body.

    application_json_or_msgpack_content:
      schema:
        type: string
        default: application/json
        enum:
          - application/json
          - application/msgpack
      description: The response content type header. Depends on Accept header in the request.
  parameters:
    luna_request_id:
      in: header
      schema:
        type: string
        format: timestamp,uuid
        example: 1536751345,8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a
        pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
      description: |
        external request id. Helps to uniquely identify messages that correspond to particular requests, in system logs.
        If it was not set, system will set it in default format ("timestamp,UUID"). It will be returned with response.
      name: Luna-Request-Id

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

    Accept:
      in: header
      name: Accept
      schema:
        type: string
        enum:
          - application/json
      description: Preferred response content type

    accept_config_handler:
      in: header
      name: Accept
      schema:
        type: string
        enum:
          - application/json
          - text/plain
        description: One of application/json, text/plain
      required: false
      description: acceptable type of receiving data

    include_luna_services:
      in: query
      name: include_luna_services
      schema:
        type: integer
        enum: [0, 1]
        default: 0
      description: Whether to perform healthchecks for dependent luna services.

    stream_id:
      in: query
      required: true
      name: stream_id
      schema:
        $ref: '#/components/schemas/stream_id'
      description: Stream ID for events you need to subscribe to.

    account_id:
      in: query
      required: false
      name: account_id
      schema:
        $ref: '#/components/schemas/account_id'
      description: Account id of stream owner.

    analytic_index:
      in: query
      name: analytic_index
      schema:
        $ref: '#/components/schemas/analytic_index'
      required: true
  schemas:
    error:
      type: object
      properties:
        error_code:
          type: integer
          description: Error code.
        desc:
          type: string
          description: Short error description.
        detail:
          type: string
          description: Error details.
        link:
          type: string
          description: Link to the documentation website with the error description.
      required: [error_code, detail, desc, link]
      example:
        error_code: 1
        detail: internal server error
        desc: internal server error
        link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-1"

    int_version:
      type: integer
      minimum: 0

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

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

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

    plugin_status:
      type: object
      properties:
        name:
          type: string
          description: Plugin name
        running:
          allOf:
            - $ref: '#/components/schemas/int01'
            - description: Whether plugin is running or not.
      required: [name, running]

    plugins:
      type: object
      properties:
        plugins:
          description: List of imported plugins.
          type: array
          items:
            $ref: '#/components/schemas/plugin_status'
      required: [plugins]
      example:
        plugins:
          - name: foo
            running: 1

    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: licenses
            error:
              error_code: 38001
              desc: Health check error
              detail: License error
              link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-38001
            status: 0

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

    int0100:
      type: integer
      minimum: 0
      maximum: 100

    int090:
      type: integer
      minimum: 0
      maximum: 90

    roi_int_coordinates:
      type: integer
      minimum: 0
      default: 0
      maximum: 65536
      example: 3327

    roi_float_percent:
      type: number
      format: float
      minimum: 0
      default: 0.0
      maximum: 100.0
      example: 87.4

    roi_float_percent_size:
      type: number
      format: float
      minimum: 0.00001
      maximum: 100.0
      example: 66.3

    roi_abs:
      type: object
      properties:
        x:
          $ref: '#/components/schemas/roi_int_coordinates'
        y:
          $ref: '#/components/schemas/roi_int_coordinates'
        width:
          $ref: '#/components/schemas/roi_int_coordinates'
        height:
          $ref: '#/components/schemas/roi_int_coordinates'
        mode:
          type: string
          enum: [abs]
          example: "abs"
          description: Coordinates and size are set in pixels.
      required: [x, y, width, height, mode]

    roi_percent:
      type: object
      properties:
        x:
          $ref: '#/components/schemas/roi_float_percent'
        y:
          $ref: '#/components/schemas/roi_float_percent'
        width:
          $ref: '#/components/schemas/roi_float_percent_size'
        height:
          $ref: '#/components/schemas/roi_float_percent_size'
        mode:
          type: string
          enum: [ percent ]
          example: "percent"
          description: Coordinates and size are set in percentage.
      required: [x, y, width, height, mode]

    roi:
      oneOf:
        - $ref: '#/components/schemas/roi_abs'
        - $ref: '#/components/schemas/roi_percent'
      description: |
          Region of interest on a frame. Boundaries of the area are described in `x`, `y` coordinates 
          of the top left point and `width`, `height` properties
          **Region must not be any bigger than the original frame**

          The region of interest will be sent to estimator. The smaller the `roi`, the smaller the area the estimator 
          will process and, accordingly, work faster.

    droi_base:
      type: object
      properties:
        mode:
          type: string
          description: DROI coordinates mode - percent or abs (absolute).
          enum: [ percent, abs ]
        form:
          type: string
          enum: [ common, wkt ]
      required: [ area, mode, form ]
      default: null

    droi_common:
      allOf:
        - $ref: '#/components/schemas/droi_base'
        - properties:
            area:
              description: |
                  Polygon defined by a number of vertex coordinates.
                  
                  The people coordinates located outside of the `droi` will not be taken into account.
              type: array
              items:
                type: array
                items:
                  type: object
                  properties:
                    x:
                      type: number
                      minimum: 0
                    y:
                      type: number
                      minimum: 0
                  required: [ x, y ]
                minItems: 3
              minItems: 1
            form:
              type: string
              enum: [ common ]
          required: [ area, mode, form ]

    droi_wkt:
      allOf:
        - $ref: '#/components/schemas/droi_base'
        - properties:
            area:
              description: |
                  Polygon defined by vector geometry objects, see [wkt](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) for details.
                  
                  The people coordinates located outside of the `droi` will not be taken into account.
                
                  It is highly recommended to specify coordinates in such a way that the geometric primitives specified
                  by these coordinates do not have intersections, since such coordinates are highly likely
                  to be invalid as DROI.
              type: string
              nullable: false
              example: "GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 10, 20 20, 10 40),POLYGON ((40 40, 20 45, 45 30, 40 40)))"
            form:
              type: string
              enum: [ wkt ]
          required: [ area, mode, form ]

    droi:
      default: null
      description: |
        Region of interest on a frame to apply filter for targets estimated.

        Boundaries of the area are described by a combination of polygons defined by vertex coordinates in `common` 
        mode or by Well-known text (WKT) in `wkt` mode.
      oneOf:
        - $ref: '#/components/schemas/droi_common'
        - $ref: '#/components/schemas/droi_wkt'
      discriminator:
        propertyName: form
        mapping:
          common: '#/components/schemas/droi_common'
          wkt: '#/components/schemas/droi_wkt'
      example:
        form: wkt
        mode: abs
        area: GEOMETRYCOLLECTION (POINT (40 10),LINESTRING (10 10, 20 20, 10 40),POLYGON ((40 40, 20 45, 45 30, 40 40)))

    number01:
      type: number
      minimum: 0
      maximum: 1

    rate:
      type: object
      description: |
        Analytic rate execution determines on which frames the analytics will be launched.
        
        Analytic rate execution can be configured in next ways:
        - execute analytic on each Nth frame (`unit` - `frame`)
        - execute analytic on each frame corresponding to the Nth second (`unit` - `second`)
      properties:
        period:
          type: integer
          minimum: 1
          default: 1
          description: Period length.
        unit:
          type: string
          enum:
            - frame
            - second
          default: frame
          description: Unit for a period calculation (every `n` seconds or every `n` frames).
      required: [ unit, period ]

    callback_base:
      type: object
      properties:
        enable:
          type: integer
          enum: [0, 1]
          default: 1
          description: Whether callback enabled or not.

    callback_trigger:
      type: object
      properties:
        trigger:
          type: object
          description: Callback actuation trigger.
          properties:
            threshold:
              type: integer
              minimum: 1
              default: 1
              description: Lower included boundary of `people_count` in generated event for callback execution.

    callback_ws_human_tracking:
      allOf:
        - $ref: "#/components/schemas/callback_base"
        - type: object
          properties:
            type:
              type: string
              enum: [luna-ws-notification]
              description: Event will be sent with `human_tracking` type.
      required: [type]

    callback_event_human_tracking:
      allOf:
        - $ref: "#/components/schemas/callback_base"
        - type: object
          properties:
            type:
              type: string
              enum: [luna-event]
              description: Event will be sent with `human_tracking` type.
      required: [type]

    callback_basic_authorization:
      type: object
      properties:
        type:
          type: string
          description: Authorization type.
          enum: [basic]
        login:
          type: string
          maxLength: 128
          description: Login.
        password:
          type: string
          maxLength: 128
          description: Password.
      required: [ type, login, password]
      description: Callback basic authorization parameters.

    callback_http:
      allOf:
        - $ref: "#/components/schemas/callback_base"
        - type: object
          properties:
            type:
              type: string
              enum: [http]
              description: Event will be sent to http url.
            url:
              type: string
              description: Callback url.
            authorization:
              $ref: '#/components/schemas/callback_basic_authorization'
            params:
              type: object
              properties:
                timeout:
                  type: integer
                  default: 60
                  description: Callback request timeout.
                content_type:
                  type: string
                  default: application/json
                  enum: [application/json, application/msgpack]
                  description: Callback request content type.
                headers:
                  type: object
                  description: Callback request headers.
                  additionalProperties: true
              description: Callback request parameters
      required: [url, type]

    callback_http_people_count:
      allOf:
        - $ref: '#/components/schemas/callback_http'
        - $ref: '#/components/schemas/callback_trigger'

    callback_ws_people_count:
      allOf:
        - $ref: "#/components/schemas/callback_base"
        - type: object
          properties:
            type:
              type: string
              enum: [ luna-ws-notification ]
              description: Event will be sent with `crowd` type.
        - $ref: '#/components/schemas/callback_trigger'

    callback_event_people_count:
      allOf:
        - $ref: "#/components/schemas/callback_base"
        - type: object
          properties:
            type:
              type: string
              enum: [ luna-event ]
              description: Event will be sent with `crowd` type.
        - $ref: '#/components/schemas/callback_trigger'

    callback_people_count:
      oneOf:
        - $ref: '#/components/schemas/callback_http_people_count'
        - $ref: '#/components/schemas/callback_ws_people_count'
        - $ref: '#/components/schemas/callback_event_people_count'
      discriminator:
        propertyName: type
        mapping:
          http: '#/components/schemas/callback_http_people_count'
          luna-ws-notification: '#/components/schemas/callback_ws_people_count'
          luna-event: '#/components/schemas/callback_event_people_count'

    image_retain_policy_non_ttl:
      type: object
      description: |
        Image retain policy applicable when analytic `overview` target is specified, 
        and configures parameters with which will image be saved.
      properties:
        mimetype:
          type: string
          enum:
            - PNG
            - JPEG
          default: JPEG
          description: Image format.
        quality:
          allOf:
            - $ref: '#/components/schemas/number01'
            - default: 1
          description: Image quality, on a scale from 0 (worst) to 1 (best). Has no effect on `PNG`.
        max_size:
          type: integer
          minimum: 0
          default: 640
          description: > 
            Image max size, in pxl. Neither the width nor the height will exceed this value.

            The `0` value means not to scale, but keep original resolution of image. 

    image_retain_policy:
      allOf:
      - $ref: '#/components/schemas/image_retain_policy_non_ttl'
      - properties:
          ttl:
            type: integer
            enum: [-1, 1, 2, 3, 4, 5, 6, 7, 14, 30, 60, 90, 180, 365]
            nullable: false
            description: |
              Lifetime for object, in days. By default, parent bucket lifetime configuration applied. 
              For object to be retained indefinitely, setup `ttl=-1`.

    period_event_policy:
      type: object
      properties:
        trigger:
          type: string
          enum: [period]
        interval:
          type: float
          description: Event generation period interval in seconds.
          minimum: 0.0
          default: 1.0
      required: [trigger, interval]

    start_event_policy:
      type: object
      properties:
        trigger:
          type: string
          enum: [start]
      required: [trigger]

    end_event_policy:
      type: object
      properties:
        trigger:
          type: string
          enum: [end]
      required: [trigger]

    probe_count:
      type: integer
      minimum: 0
      default: 3
      description: |
        minimal number of some feature probe before analytics start event tracking. This parameter is intended to 
        prevent false positives from analytics.

    people_count_parameters:
      type: object
      properties:
        targets:
          type: array
          default: []
          items:
            type: string
            enum: [coordinates, overview]
          description: |
            Estimations to perform on the video.

            `coordinates` will add `people_coordinates` to frames estimations.
            
            `overview` will add overview processing and enable image saving.
        callbacks:
          type: array
          description: |
            Callbacks parameters.
            
            `http` type callback sends events to the specified url by POST request.

            `luna-ws-notification` type callback sends events to websocket using sender.

            `luna-event` type callback sends events to the luna-events service.
          maxItems: 10
          items:
            $ref: '#/components/schemas/callback_people_count'

        parameters:
          type: object
          description: Estimation parameters.
          properties:
            people_count_threshold:
              type: integer
              minimum: 0
              description: Minimal human count for an analytics track generation.
              default: 0
            event_policy:
              description: |
                Event policy. 
                
                When people count reaches specified `people_count_threshold` the new `track` will starts, when people count will
                be less than `people_count_threshold` `track` will ends. Event can be generated in next cases:

                - when track starts (`trigger` - `start`)
                - when track ends (`trigger` - `end`)
                - periodically while track exists (`trigger` - `period`)
              type: object
              properties:
              oneOf:
                - $ref: '#/components/schemas/period_event_policy'
                - $ref: '#/components/schemas/start_event_policy'
                - $ref: '#/components/schemas/end_event_policy'
              discriminator:
                propertyName: trigger
                mapping:
                  period: '#/components/schemas/period_event_policy'
                  start: '#/components/schemas/start_event_policy'
                  end: '#/components/schemas/end_event_policy'
              default:
                trigger: period
                interval: 1.0
            image_retain_policy:
              $ref: '#/components/schemas/image_retain_policy'
            roi:
              $ref: '#/components/schemas/roi'
            droi:
              $ref: '#/components/schemas/droi'
            rate:
              $ref: '#/components/schemas/rate'
            probe_count:
              allOf:
                - $ref: '#/components/schemas/probe_count'
                - description: |
                    A number of consecutive `people count` estimations where people count more or equal 
                    `people_count_threshold` before start analytic track generation. This parameter is intended to
                    prevent false positives from analytics.

    people_count_parameters_videosdk:
      type: object
      properties:
        roi:
          $ref: '#/components/schemas/roi'
        droi:
          $ref: '#/components/schemas/droi'
        rate:
          allOf:
            - $ref: '#/components/schemas/rate'
            - default:
                unit: frame
                period: 10
        probe_count:
          allOf:
          - description: |
              A number of consecutive `people count` estimations where people count more or equal 
              `people_count_threshold` before start `crowd event` generation. This parameter is intended to
              prevent false positives from analytics.
          - $ref: '#/components/schemas/probe_count'
        image_retain_policy:
          $ref: '#/components/schemas/image_retain_policy_non_ttl'
        people_count_threshold:
          type: integer
          minimum: 0
          default: 1
          description: minimal human count for an analytics event generation

    string36_nullable:
      type: string
      maxLength: 36
      nullable: true

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

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

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

    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"

    people_count:
      type: integer
      minimum: 0
      description: People count on a frame.

    time_offset:
      type: number
      example: 1.234
      description: Frame time offset (seconds).

    people_coordinates:
      type: array
      description: |
        People coordinates estimation.
                    
        Required analytic target `coordinates` to be enabled to send this value.
      items:
        type: array
        items:
          type: integer
        minItems: 2
        maxItems: 2
        description: Human x, y coordinates.
        example: [ 64, 128 ]
      example: [ [ 64, 128 ], [ 491, 375 ] ]

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

    base_callback_request:
      type: object
      properties:
        account_id:
          type: string
          description: Account id of event.
        event_create_time:
          type: string
          description: Event creation time.
        event_end_time:
          type: string
          description: Event end time.

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

    people_count_callback_request:
      allOf:
        - $ref: '#/components/schemas/base_callback_request'
        - type: object
          properties:
            event_type:
              type: string
              enum: [crowd]
              description: Event type.
            event:
              type: object
              description: Event.
              properties:
                stream_id:
                  allOf:
                    - $ref: '#/components/schemas/uuid'
                  description: Stream ID.
                event_id:
                  allOf:
                    - $ref: '#/components/schemas/uuid'
                  description: Event ID.
                track_id:
                  allOf:
                    - $ref: '#/components/schemas/uuid'
                  description: Track id.
                  nullable: true
                people_count:
                  $ref: '#/components/schemas/people_count'
                overview:
                  type: object
                  description: Event overview.
                  properties:
                    people_coordinates:
                      $ref: '#/components/schemas/people_coordinates'
                    image:
                      type: string
                      description: |
                        Url of saved image.
                        
                        Required analytic target `overview` to be enabled to send this value.
                    time_offset:
                      $ref: '#/components/schemas/time_offset'
                location:
                  type: object
                  properties:
                    city:
                      allOf:
                        - $ref: '#/components/schemas/string36_nullable'
                      example: Moscow
                      description: City that stream belongs.
                    area:
                      allOf:
                        - $ref: '#/components/schemas/string36_nullable'
                      example: Central
                      description: Area that stream belongs.
                    district:
                      allOf:
                        - $ref: '#/components/schemas/string36_nullable'
                      example: Basmanny
                      description: District that stream belongs.
                    street:
                      allOf:
                        - $ref: '#/components/schemas/string36_nullable'
                      example: Podsosensky lane
                      description: Street that stream belongs.
                    house_number:
                      allOf:
                        - $ref: '#/components/schemas/string36_nullable'
                      example: 23 bldg.3
                      description: Street that stream belongs.
                    geo_position:
                      $ref: '#/components/schemas/geo_position'
                  description: |
                    Stream location parameters.

                    Required callback `location` target to send this value.
                source:
                  $ref: '#/components/schemas/source'
                video_segment:
                  type: object
                  description: Video segment.
                  properties:
                    start_time_offset:
                      type: number
                      example: 0.123
                      description: Event start video segment offset (seconds).
                    end_time_offset:
                      type: number
                      example: 1.234
                      description: Event end video segment offset (seconds).
              required: [stream_id, event_id, people_count, video_segment, track_id]
          required: [event_type, event, account_id, event_create_time, event_end_time]


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


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

    handler_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - description: |
            Handler ID. 
            Handler that will be used for event generation. Note that handler must be
            non dynamic and be assigned to the same account as the stream
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    handlers_reply_event:
      type: object
      description: | 
        Event received after detections processing by handler. Event contains information about face and/or body of a 
        single person. See `luna-handlers` documentation for details

    human_tracking_callback_request:
      allOf:
        - $ref: '#/components/schemas/base_callback_request'
        - type: object
          properties:
            event_type:
              type: string
              enum: [human_tracking]
              description: Event type.
            event:
              $ref: '#/components/schemas/handlers_reply_event'
          requred: [event_type, event]

    event_status:
      type: string
      enum: [started, in_process, finished]
      description: event status

    track_status:
      type: string
      enum: [started, in_process, finished]
      description: event status

    event_from_ws:
      type: object
      description: crowd analytics results
      properties:
        track_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: Track id.
        event_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: Event id.
          nullable: true
        people_count:
          allOf:
          - $ref: '#/components/schemas/people_count'
          example: 2
        time_offset:
          $ref: '#/components/schemas/time_offset'
        event_status:
          $ref: '#/components/schemas/event_status'
        people_coordinates:
          $ref: '#/components/schemas/people_coordinates'
      required: [ track_id, event_id, people_count, time_offset, event_status ]

    finished_stream:
      type: object
      description: Stream processing finish message
      properties:
        error_code:
          type: integer
          description: Success error code.
          enum: [0]
        desc:
          type: string
          description: Success short description.
          enum: [Success]
        detail:
          type: string
          description: Success details.
          enum: [Success]
        link:
          type: string
          description: Link to the documentation website with the error description.
          enum: ["https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0"]
      required: [error_code, detail, desc, link]

    error_stream:
      type:
        - string
        - "null"
      description: Stream analytics processing error.
      example: "decoding error"
      nullable: true

    error_stream_obj:
      type: object
      description: Processing error. Null means no error occurred.
      properties:
        error:
          $ref: '#/components/schemas/error_stream'
      required: [error]

    ws_stream_status:
      type: string
      enum: [in_progress, error, finished]
      description: |
        Stream processing status.

        `in_progress` means stream processing is in progress.
        
        `error` means fatal error occurred, interrupting processing, the connection will closed.

        `finished` means stream processing was successfully finished, the connection will closed.

    base_message_from_ws:
      type: object
      description: Event from websocket.
      properties:
        stream_status:
          $ref: '#/components/schemas/ws_stream_status'
        error:
          allOf:
          - $ref: '#/components/schemas/error_stream'
          description: Stream processing error.
      required: [stream_status, error]

    people_count_analytics_results:
      type: object
      description: Analytics results.
      properties:
        crowd:
          description: Crowd analytics results.
          oneOf:
          - $ref: '#/components/schemas/event_from_ws'
          - $ref: '#/components/schemas/error_stream_obj'
      required: [crowd]

    message_from_ws_people_count:
      allOf:
      - $ref: '#/components/schemas/base_message_from_ws'
      - properties:
          analytics_results:
            $ref: '#/components/schemas/people_count_analytics_results'

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

    human_track:
      type: object
      properties:
        bbox:
          $ref: '#/components/schemas/rect'
        score:
          allOf:
            - $ref: '#/components/schemas/number01'
            - nullable: true
          description: Detection confidence.
            If `score` is `null`, there was actually no detection, but detector expected the object to be within the specified area.
      description: Human detection.
      required: [ bbox, score ]

    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]

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

    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

    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]

    shot_info:
      type: object
      properties:
        time_offset:
          $ref: '#/components/schemas/time_offset'
        image:
          $ref: '#/components/schemas/shot'
      required: [ time_offset, image ]

    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]

    quality:
      description: |
        Image quality. Estimation of image visual properties.
      type: object
      properties:
        dark:
          allOf:
            - $ref: '#/components/schemas/number01'
            - description: Low value means under-exposured face area (i.e. due to backlight, poor lighting, sensor underexposure).
        light:
          allOf:
            - $ref: '#/components/schemas/number01'
            - description: Low value means over-exposured face area (i.e. overbright lighting, sensor overexposure).
        illumination:
          allOf:
            - $ref: '#/components/schemas/number01'
            - description: Low value means illumination nonuniformity.
        specularity:
          allOf:
            - $ref: '#/components/schemas/number01'
            - description: Low value means low specularity.
        blurriness:
          allOf:
            - $ref: '#/components/schemas/number01'
            - description: Low value means blurred image (e.g. due to depth of field or motion blur). High value means sharp image.
      required: [blurriness, specularity, illumination, light, dark]
      example:
        light: 0.87
        dark: 0.13
        illumination: 0.1
        specularity: 0.1
        blurriness: 0.2

    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_base:
      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]
      example:
        mask:
          estimations:
            medical_mask: 0.7108324766
            missing: 0.0700698048
            occluded: 0.2190976739
          predominant_mask: "medical_mask"
          face_occlusion:
            predominant_occlusion: "correct"
            estimations:
              full: 0.1
              correct: 0.25
              clear: 0.05
              mouth: 0.2
              partially: 0.2
              chin: 0.2

    glasses_estimations:
      type: string
      enum: [no_glasses, eyeglasses, sunglasses]
      description: Glasses estimation.

    glasses:
      type: object
      description: Estimated glasses.
      properties:
        glasses:
          $ref: '#/components/schemas/glasses_estimations'
      required: [glasses]

    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]

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


    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]

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

    mouth_attributes:
      description: Mouth attributes.
      type: object
      properties:
        score:
          allOf:
            - $ref: '#/components/schemas/number01'
          description: Mouth detection confidence.
        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]

    human_tracking_frame_estimation:
      type: object
      properties:
        time_offset:
          $ref: '#/components/schemas/time_offset'
        estimated:
          type: object
          description: Track estimations.
          properties:
            face:
              type: object
              nullable: true
              properties:
                detection:
                  $ref: '#/components/schemas/human_track'
                landmarks5:
                  $ref: '#/components/schemas/landmarks5'
                head_pose:
                  $ref: '#/components/schemas/head_pose'
                ags:
                  $ref: '#/components/schemas/number01'
                warp_quality:
                  $ref: '#/components/schemas/quality'
                emotions:
                  $ref: '#/components/schemas/emotions'
                mask:
                  $ref: '#/components/schemas/masks_base'
                glasses:
                  $ref: '#/components/schemas/glasses'
                eyes:
                  $ref: '#/components/schemas/eyes_attributes'
                gaze:
                  $ref: '#/components/schemas/gaze_direction'
                mouth:
                  $ref: '#/components/schemas/mouth_attributes'
            body:
              type: object
              nullable: true
              properties:
                detection:
                  $ref: '#/components/schemas/human_track'
          required: [ face, body ]
      required: [time_offset, estimated]

    sdk_descriptor:
      type: string
      format: byte
      description: SDK descriptor (descriptor version, signature, descriptor bytes).

    extracted_sdk_descriptor:
      description: SDK descriptor.
      type: object
      properties:
        sdk_descriptor:
          $ref: '#/components/schemas/sdk_descriptor'
        score:
          allOf:
            - $ref: '#/components/schemas/number01'
            - description: Descriptor score (always 1 for body descriptor).

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

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

    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"

    basic_attributes:
      type: object
      description: Basic attributes.
      properties:
        age:
          allOf:
            - $ref: '#/components/schemas/age'
            - example: 29
        gender:
          allOf:
            - $ref: '#/components/schemas/gender'
            - example: 1
        ethnicities:
          $ref: '#/components/schemas/ethnicities'
      required: [age, gender, ethnicities]

    liveness:
      type: object
      description: Liveness prediction.
      properties:
        prediction:
          type: string
          enum: [spoof, real]
          description: Liveness prediction name
        estimations:
          type: object
          description: Liveness estimations.
          properties:
            quality:
              allOf:
                - $ref: '#/components/schemas/number01'
              description: Liveness quality score. Support in backwards compatibility, always set to 1.
              deprecated: true
            score:
              allOf:
                - $ref: '#/components/schemas/number01'
              description: Liveness prediction score.
          required: [score]
      required: [prediction, estimations]

    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]

    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 ]

    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 ]

    upper_body_attributes_base:
      type: object
      description: Upper body attributes.
      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.
          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.

                > **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: [ colors ]
          description: Upper clothing attibutes.
      required: [ headwear, sleeve, upper_clothing ]

    estimated_upper_body_attributes:
      allOf:
        - $ref: "#/components/schemas/upper_body_attributes_base"
        - properties:
            headwear:
              required: [ state, apparent_color ]
      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_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

    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

    human_tracking_body_attributes:
      description: Human body attributes.
      type: object
      properties:
        upper_body:
          $ref: "#/components/schemas/estimated_upper_body_attributes"
        lower_body:
          $ref: "#/components/schemas/lower_body_attributes_not_nullable"
        basic_attributes:
          $ref: "#/components/schemas/body_basic_attributes_not_nullable"
        accessories:
          $ref: "#/components/schemas/body_accessories_not_nullable"

    human_track_aggregated:
      type: object
      description: aggregated analytics result on a track
      properties:
        event_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: Unique analytics event ID.
        track_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: Unique human track ID.
        video_segment:
          allOf:
            - $ref: '#/components/schemas/video_segment'
            - description: video segment with event
        frames_estimations:
          type: array
          description: track frames estimations
          items:
            $ref: '#/components/schemas/human_tracking_frame_estimation'
        aggregated_estimations:
          type: object
          description: Human aggregated estimations.
          properties:
            face:
              type: object
              nullable: true
              properties:
                samples:
                  type: array
                  items:
                    $ref: '#/components/schemas/shot_info'
                  description: |
                    List of face warps from the video ranked by detection score and used for aggregated estimations
                thumbnail:
                  allOf:
                    - $ref: '#/components/schemas/shot_info'
                  description: Face warp from the video with the best detection score
                descriptor:
                  $ref: '#/components/schemas/extracted_sdk_descriptor'
                basic_attributes:
                  $ref: "#/components/schemas/basic_attributes"
                liveness:
                  $ref: "#/components/schemas/liveness"
                deepfake:
                  $ref: "#/components/schemas/deepfake"
              description: Face aggregated estimations.
            body:
              type: object
              nullable: true
              properties:
                samples:
                  type: array
                  items:
                    $ref: '#/components/schemas/shot_info'
                  description: |
                    List of body warps from the video ranked by detection score and used for aggregated estimations
                thumbnail:
                  allOf:
                    - $ref: '#/components/schemas/shot_info'
                    - description: Body warp from the video with the best detection score
                descriptor:
                  $ref: '#/components/schemas/extracted_sdk_descriptor'
                attributes:
                  allOf:
                    - $ref: "#/components/schemas/human_tracking_body_attributes"
                    - required: [basic_attributes, upper_body, lower_body, accessories]
              description: Body aggregated estimations.
          required: [body, face]
        overview:
          allOf:
            - $ref: '#/components/schemas/shot_info'
            - properties:
                detection:
                  type: object
                  properties:
                    face:
                      allOf:
                        - $ref: '#/components/schemas/human_track'
                      nullable: true
                    body:
                      allOf:
                        - $ref: '#/components/schemas/human_track'
                      nullable: true
                  required: [ face, body ]
              required: [ detection ]
          description: Shot from the video with the best detection score
      required: [ event_id, track_id, video_segment, frames_estimations, aggregated_estimations ]

    human_tracking_aggregated_result:
      type: object
      properties:
        tracking:
          type: object
          properties:
            events:
              type: array
              items:
                $ref: '#/components/schemas/human_track_aggregated'
            track_count:
              type: integer
              minimum: 0
              description: Track count.
          required: [ events, track_count ]
      required: [ tracking ]

    human_tracking_analytics_result_videosdk:
      type: object
      properties:
        name:
          type: string
          description: video analytics name
          enum:
            - human_tracking
        result:
          $ref: '#/components/schemas/human_tracking_aggregated_result'
      required: [ name, result ]

    people_count_analytics_result_videosdk:
      type: object
      properties:
        name:
          type: string
          description: video analytics name
          enum:
            - people_count
        result:
          $ref: '#/components/schemas/people_count_analytics_estimation'
      required: [ name, result ]


    message_from_ws_abstract:
      allOf:
      - $ref: '#/components/schemas/base_message_from_ws'
      - properties:
          analytics_results:
            type: object
            description: |
              Analytics results.
              To get schema and description of analytics ws event, it is possible to get it
              using [get analytic documentation request](#tag/analytics/operation/getAnalyticDoc)
            properties:
              <analytics_name>:
                description: Analytics results.
                oneOf:
                - $ref: '#/components/schemas/error_stream_obj'
                - type: object
                  description: Event from websocket.
                  additionalProperties: true
        required: [stream_status, error]

    orientation_strategy:
      type: string
      default: static
      description: |
        Rotation angle strategy:
        
        - `static` - use angle specified by user.
        - `video_info` - use angle from video information.

    angle:
      type: integer
      enum: [0, 90, 180, 270]

    video_orientation_static:
      type: object
      description: Video orientation info.
      nullable: false
      properties:
        orientation_strategy:
          allOf:
          - $ref: '#/components/schemas/orientation_strategy'
          - enum: ["static"]
        angle:
          allOf:
          - $ref: '#/components/schemas/angle'
          - description: angle to rotate the video before analytics
          - default: 0

    video_orientation_video_info:
      type: object
      description: Video orientation info.
      nullable: false
      properties:
        orientation_strategy:
          allOf:
          - $ref: '#/components/schemas/orientation_strategy'
          - enum: ["video_info"]
      required: [ "orientation_strategy" ]

    video_orientation:
      oneOf:
        - $ref: '#/components/schemas/video_orientation_static'
        - $ref: '#/components/schemas/video_orientation_video_info'

    video_pts:
      type: object
      description: Video timestamp settings.
      nullable: false
      properties:
        start_time:
          type: number
          min: 0
          default: null
          nullable: true
          description: custom video start time
      required: [start_time]

    decoder_error_handling:
      type: object
      description: Video decoder error handling parameters.
      nullable: false
      properties:
        action:
          type: string
          enum: [ fail, stop]
          default: fail
          description: |
            Error handling action.

            | | behavior when a decoding error occurs |
            |-|---------------------------------------|
            | fail | stop processsing the video and fail the request |
            | stop | stop processing the video and generate a response based on the part of the video processed before the error occurred |
      required: [ action ]

    task_callback_basic_authorization:
      type: object
      properties:
        type:
          type: string
          description: Authorization type.
          enum: [basic]
        login:
          type: string
          maxLength: 128
          description: Login.
        password:
          type: string
          maxLength: 128
          description: Password.
      required: [ type, login, password]
      description: Callback basic authorization parameters.

    task_http_callback:
      type: object
      properties:
        type:
          type: string
          enum: [http]
        authorization:
          $ref: '#/components/schemas/task_callback_basic_authorization'
        url:
          type: string
          description: Request URL.
          format: uri-reference
        params:
          type: object
          properties:
            timeout:
              type: integer
              default: 60
              description: Callback request timeout.
            content_type:
              type: string
              default: application/json
              enum: [application/json, application/msgpack]
              description: Callback request content type.
            headers:
              type: object
              description: Callback request headers.
              additionalProperties: true
          description: Callback request parameters.
        enable:
          allOf:
            - $ref: '#/components/schemas/int01'
            - description: Whether callback enabled or not.
            - default: 1
      required: [ type, url ]

    http_callback_required:
      allOf:
        - $ref: '#/components/schemas/task_http_callback'
        - required: [type, url, params, filters, enable]

    telegram_callback:
      type: object
      properties:
        type:
          type: string
          enum: [ telegram ]
        chat_id:
          type: integer
          description: |
            Telegram chat id where callbacks will be sent.

            Messages can be delivered to users or channels using their ids. 
            For detailed information on where to find these ids, please refer to https://core.telegram.org/bots/api.
        token:
          type: string
          description: |
            Telegram authorization token. 
            For details information see <a href="https://core.telegram.org/bots/features#botfather">botfather</a>.
        params:
          type: object
          description: Callback request parameters
          properties:
            timeout:
              type: integer
              default: 60
              description: Callback request timeout.
        enable:
          allOf:
            - $ref: '#/components/schemas/int01'
            - description: Whether callback enabled or not
            - default: 1
      required: [ type, chat_id, token ]

    task_callback:
      oneOf:
        - $ref: '#/components/schemas/task_http_callback'
        - $ref: '#/components/schemas/telegram_callback'
      discriminator:
        propertyName: "type"
        mapping:
          http: '#/components/schemas/task_http_callback'
          telegram: '#/components/schemas/telegram_callback'

    video_task_callbacks:
      type: array
      items:
        $ref: '#/components/schemas/task_callback'
      description: |
        Callbacks for sending tasks id and status to third party system. Callbacks are executed after task status changed.
        
        **Sample Output for successful task**
        ```
        {
          "task_id": 00000000-0000-4000-a000-000000658854,  
          "status": "done",  
          "result_url": "http://127.0.0.1:5000/6/objects/00000000-0000-4000-a000-000000658854"
        }
        ```
        
        ** Sample Output for failed task **
        ```
        {
        'task_id': '015940f7-63f5-4576-92d1-c745eb058aa7', 
        'status': 'failed'
        'result_url': 'http://127.0.0.1:5000/6/objects/896824ca-d73d-4f97-a2af-3bc03d82423d', 
        }
        ```
      example:
        $ref: "#/components/schemas/task_callbacks_example"

    task_callbacks_example:
      - type: http
        enable: 1
        authorization:
          type: basic
          login: login
          password: password
        url: http://callback.url
        params:
          timeout: 60
          content_type: "application/json"
          headers: { }
      - type: telegram
        enable: 1
        token: 1111111111:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
        chat_id: 111111111
        params:
          timeout: 60

    notification_policy:
      type: object
      description: tasks processing notification policy
      properties:
        enable:
          allOf:
            - $ref: '#/components/schemas/int01'
            - description: Whether callbacks enabled or not
            - default: 0
        task_callbacks:
          $ref: '#/components/schemas/video_task_callbacks'

    deferred_task:
      type: object
      properties:
        enable:
          allOf:
            - $ref: '#/components/schemas/int01'
            - default: 0
          description: Whether to enable deferred task or not
        storage_policy:
          type: object
          properties:
            storage_type:
              type: string
              enum: [ luna_image_store ]
              default: "luna_image_store"
              description: Task result storage type
            ttl:
              type: integer
              enum: [-1, 1, 2, 3, 4, 5, 6, 7, 14, 30, 60, 90, 180, 365]
              default: 7
              description: Task result ttl in days. `-1` - Task result kept infinitely.
          description: Task result storage settings
        notification_callbacks:
          $ref: '#/components/schemas/notification_policy'
      description: | 
        Deferred task setting. If enabled analytics will run in background. 
        Task result and status can be received by [/1/video/tasks/{task_id}](#tag/video-tasks/operation/getVideoTask)

    video_fps:
      type: number
      format: float
      minimum: 0.0
      exclusiveMinimum: 0.0
      nullable: true
      description: Video decoder fps.
      example: 30.0

    video_analytics_params:
      type: object
      properties:
        deferred_task:
          $ref: '#/components/schemas/deferred_task'
        video:
          type: object
          properties:
            url:
              type: string
              example: "https://example.com/"
              description: Video URL.
            orientation:
              $ref: '#/components/schemas/video_orientation'
            pts:
              $ref: '#/components/schemas/video_pts'
            fps:
              $ref: '#/components/schemas/video_fps'
            error_handling:
              $ref: '#/components/schemas/decoder_error_handling'
          required: [ url ]
          description: Video information.
        analytics:
          type: array
          items:
            discriminator:
              propertyName: name
              mapping:
                people_count: '#/components/schemas/people_count_analytics'
                human_tracking: '#/components/schemas/human_tracking_analytics'
            anyOf:
              - $ref: '#/components/schemas/people_count_analytics'
              - $ref: '#/components/schemas/human_tracking_analytics'
          description: A list of parameters for comprehensive video analytics.
      description: Video URL and a list of parameters required for video analysis.
      required: [ video, analytics ]

    aggregation_count:
      type: integer
      minimum: 0
      example: 13
      description: Max number of bestshots an attribute estimation is required to be based on.

    human_tracking_parameters_videosdk:
      type: object
      properties:
        roi:
          $ref: '#/components/schemas/roi'
        rate:
          allOf:
            - $ref: '#/components/schemas/rate'
            - default:
                unit: frame
                period: 1
        probe_count:
          $ref: '#/components/schemas/probe_count'
        image_retain_policy:
          $ref: '#/components/schemas/image_retain_policy_non_ttl'
        tracking:
          type: object
          properties:
            detector_type:
              type: string
              enum: [ face, body, human ]
              default: face
              description: |
                Human tracking detector type.

                | detector type | tracking |
                |---------------|----------|
                | face  | based on faces |
                | body  | based on bodies |
                | human | based on both faces and bodies |

                **Detector type must be compatible with selected targets**
            body_reid:
              allOf:
                - $ref: '#/components/schemas/int01'
                - default: 0
              description: |
                Whether to use body re-identification.

                ReId feature is used to increase tracking accuracy by merging different tracks of one human. 
                Significantly increases estimation time.
          description: Human tracking configuration.
        face_samples:
          type: object
          properties:
            count:
              allOf:
                - $ref: '#/components/schemas/aggregation_count'
              default: 5
            filters:
              type: object
              properties:
                score:
                  allOf:
                    - $ref: '#/components/schemas/number01'
                  default: 0.6
                  description: A sample score threshold. The score is determined by `ags`.
                head_pitch:
                  allOf:
                    - $ref: '#/components/schemas/int090'
                  default: 15
                  description: Head pitch absolute angle threshold.
                head_roll:
                  allOf:
                    - $ref: '#/components/schemas/int090'
                  default: 15
                  description: Head roll absolute angle threshold.
                head_yaw:
                  allOf:
                    - $ref: '#/components/schemas/int090'
                  default: 15
                  description: Head yaw absolute angle threshold.
                droi:
                  allOf:
                    - $ref: '#/components/schemas/droi'
                  description: |
                    Region of interest on a frame to apply filter for detections.
                    Only detections centered in this region can be selected as samples.
                    Boundaries of the region area are described by a combination of poligons defined by vertex coordinates.
              description: Face sample filters.
          description: Configuration for choosing detections for face attributes estimation.
        body_samples:
          type: object
          properties:
            count:
              allOf:
                - $ref: '#/components/schemas/aggregation_count'
              default: 5
            filters:
              type: object
              properties:
                score:
                  allOf:
                    - $ref: '#/components/schemas/number01'
                  default: 0.3
                  description: A sample score threshold. The score is determined by detection `score`.
                droi:
                  allOf:
                    - $ref: '#/components/schemas/droi'
                  description: |
                    Region of interest on a frame to apply filter for detections.
                    Only detections centered in this region can be selected as samples.
                    Boundaries of the region area are described by a combination of poligons defined by vertex coordinates.
              description: Body sample filters.
          description: Configuration for choosing detections for body attributes estimation.

    human_tracking_analytics:
      type: object
      properties:
        name:
          type: string
          enum:
            - people_count
            - human_tracking
          description: analytics name.
        targets:
          type: array
          items:
            type: string
            minItems: 1
            enum:
              - face_detection
              - landmarks5
              - head_pose
              - ags
              - warp_quality
              - emotions
              - glasses
              - eyes
              - gaze
              - mouth
              - mask
              - aggregated_liveness
              - aggregated_deepfake
              - aggregated_face_samples
              - aggregated_face_thumbnail
              - aggregated_face_basic_attributes
              - aggregated_face_descriptor
              - body_detection
              - aggregated_body_samples
              - aggregated_body_thumbnail
              - aggregated_body_attributes
              - aggregated_body_descriptor
              - overview
          default: [ face_detection ]
          description: Estimations to perform on the video
        parameters:
          $ref: '#/components/schemas/human_tracking_parameters_videosdk'
      required: [ name ]

    video_analytics_results:
      type: object
      properties:
        video_data:
          $ref: '#/components/schemas/analytics_results_video_data'
        analytics:
          type: array
          discriminator:
            propertyName: name
            mapping:
              people_count: '#/components/schemas/people_count_analytics_result_videosdk'
              human_tracking: '#/components/schemas/human_tracking_analytics_result_videosdk'
          items:
            oneOf:
              - $ref: '#/components/schemas/people_count_analytics_result_videosdk'
              - $ref: '#/components/schemas/human_tracking_analytics_result_videosdk'
      required: [video_data, analytics]

    analytics_results_video_data:
      type: object
      description: video metadata
      properties:
        frames_count:
          type: integer
          minimum: 0
          description: frames count
        frame_rate:
          type: number
          description: frame rate
        duration:
          type: number
          description: video duration
        processed_parts:
          type: array
          description: processed video segments
          items:
            type: object
            description: video segment
            properties:
              start_offset:
                type: number
                minimum: 0
                description: start segment time offset
              end_offset:
                type: number
                minimum: 0
                description: end segment time offset
        error_count:
          type: integer
          minimum: 0
          description: number of decoding errors occurred
        rotation:
          allOf:
            - $ref: '#/components/schemas/angle'
            - description: |
                Video rotation angle. 
                    
                If `orientation_strategy` specified as `static` so `rotation` will be equal request specified angle.
                    
                If `orientation_strategy` specified as `video_info` so `rotation` will get video rotation angle from
                video info. If video has different rotation angles on different frames, the last frame rotation 
                will returns.

    video_analytics_results_msgpack:
      type: object
      properties:
        video_data:
          $ref: '#/components/schemas/analytics_results_video_data'
        analytics:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/people_count_analytics_result_videosdk_msgpack'
              - $ref: '#/components/schemas/human_tracking_analytics_result_videosdk_msgpack'
      required: [video_data, analytics]

    people_count_analytics:
      type: object
      properties:
        name:
          type: string
          enum:
          - people_count
          description: analytics name.
        targets:
          type: array
          items:
            type: string
            enum:
              - coordinates
              - overview
          default: []
          description: |
            Estimations to perform on the video. 
            - `overview` to receive aggregated frames overview, 
            - `coordinates` to add `people_coordinates` parameter to frames estimations.
            - An empty list to perform base analysis.
        parameters:
          $ref: '#/components/schemas/people_count_parameters_videosdk'
      required: [ name ]

    people_count_analytics_estimation:
      type: object
      properties:
        crowd:
          $ref: '#/components/schemas/people_count_analytics_aggregated'
      required: [ crowd ]

    people_count_analytics_aggregated:
      type: object
      properties:
        events:
          type: array
          items:
            $ref: '#/components/schemas/people_count_frame_aggregated'
      required: [ events ]

    people_count_frame_aggregated:
      type: object
      properties:
        event_id:
          $ref: '#/components/schemas/analytic_event_id'
        track_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: Unique crowd track ID.
        people_count:
          type: integer
          minimum: 0
          description: max people count during event
        video_segment:
          allOf:
            - $ref: '#/components/schemas/video_segment'
            - description: video segment with event
        frames_estimations:
          type: array
          items:
            $ref: '#/components/schemas/people_count_frame_estimation'
        overview:
          allOf:
            - $ref: '#/components/schemas/shot_info_with_coordinates'
            - description: Shot from the video where max people count was detected
      description: aggregated result for frames assigned to event
      required: [ event_id, track_id, people_count, video_segment, frames_estimations ]

    shot_info_with_coordinates:
      type: object
      properties:
        time_offset:
          $ref: '#/components/schemas/time_offset'
        image:
          $ref: '#/components/schemas/shot'
        people_coordinates:
          $ref: '#/components/schemas/rescaled_people_coordinates'
      required: [ time_offset, image, people_coordinates ]

    rescaled_people_coordinates:
      type: array
      description: People coordinates estimation
      items:
        type: array
        items:
          type: integer
        minItems: 2
        maxItems: 2
        description: Human x, y coordinates rescaled to original frame
      example: [[530, 201], [272, 191]]

    shot:
      type: string
      format: byte
      description: Shot from a video

    people_count_frame_estimation:
      type: object
      properties:
        people_count:
          type: integer
          minimum: 0
          description: people count on a frame
        time_offset:
          $ref: '#/components/schemas/time_offset'
        people_coordinates:
          $ref: '#/components/schemas/people_coordinates'
      required: [ people_count, time_offset ]

    analytic_event_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - description: unique analytic event id

    video_segment:
      type: object
      properties:
        start_time_offset:
          type: number
          example: 0.123
          description: start video segment offset(seconds)
        end_time_offset:
          type: number
          example: 1.234
          description: eng video segment offset(seconds)
      required: [ start_time_offset, end_time_offset ]

    people_count_analytics_result_videosdk_msgpack:
      allOf:
        - properties:
            result:
              properties:
                crowd:
                  properties:
                    events:
                      items:
                        properties:
                          overview:
                            properties:
                              image:
                                format: binary
        - $ref: '#/components/schemas/people_count_analytics_result_videosdk'

    human_tracking_analytics_result_videosdk_msgpack:
      allOf:
        - properties:
            result:
              properties:
                tracking:
                  properties:
                    events:
                      items:
                        properties:
                          aggregated_estimations:
                            properties:
                              face:
                                properties:
                                  samples:
                                    items:
                                      properties:
                                        image:
                                          format: binary
                                  thumbnail:
                                    properties:
                                      image:
                                        format: binary
                                  descriptor:
                                    properties:
                                      sdk_descriptor:
                                        format: binary
                              body:
                                properties:
                                  samples:
                                    items:
                                      properties:
                                        image:
                                          format: binary
                                  thumbnail:
                                    properties:
                                      image:
                                        format: binary
                                  descriptor:
                                    properties:
                                      sdk_descriptor:
                                        format: binary
                          overview:
                            properties:
                              image:
                                format: binary
        - $ref: '#/components/schemas/human_tracking_analytics_result_videosdk'

    video_task_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - description: | 
            Video analytics task id. Task can be accessed by id until `deferred_task.storage_policy.ttl` is not exceeded

    video_analytics_task_response:
      type: object
      properties:
        task_id:
          $ref: '#/components/schemas/video_task_id'
      required: [ task_id ]

    video_analytics_response:
      oneOf:
        - $ref: '#/components/schemas/video_analytics_results'
        - $ref: '#/components/schemas/video_analytics_task_response'

    video_analytics_response_msgpack:
      oneOf:
        - $ref: '#/components/schemas/video_analytics_results_msgpack'
        - $ref: '#/components/schemas/video_analytics_task_response'

    result_url:
      type: string
      description: | 
        Url to video task result. Returned when task processing is finished.
        
        **Result content**
        ```
        {
            "request": ... # original user request
            "response" ... # successful analytic result or an error
        }
        ```

    video_task_response:
      type: object
      properties:
        task_id:
          $ref: '#/components/schemas/video_task_id'
        status:
          type: integer
          enum: [ 0, 1, 2, 3, ]
          description: |
            
            Video task status
            
            | task status | value |
            |-----------------|---|
            | pending         | 0 |
            | in progress     | 1 |
            | done            | 2 |
            | failed          | 3 |
        progress:
          type: number
          nullable: true
          minimum: 0
          maximum: 1
          description: Video task progress, `null` if progress calculation isn`t done yet or not available
          example: 0.42
        result_url:
          $ref: "#/components/schemas/result_url"
      required: [ task_id, status, progress ]

    analytic_index:
      type: integer
      minimum: 0
      description: Analytics of interest index.
  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'

    timeout_error:
      description: Timeout error.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'
          examples:
            request_timeout:
              value:
                error_code: 43009
                desc: Timeout error
                detail: "Failed to open video by url http://127.0.0.1:64434/vide3245o.mkv, status code: 504, Request timeout"
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-43009"
            connect_timeout:
              value:
                error_code: 43009
                desc: Timeout error
                detail: "Failed to open video by url http://127.0.0.1:64434/vide3245o.mkv, status code: 504, Connect timeout"
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-43009"
            sock_connect_timeout:
              value:
                error_code: 43009
                desc: Timeout error
                detail: "Failed to open video by url http://127.0.0.1:64434/vide3245o.mkv, status code: 504, Socket connect timeout"
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-43009"
            sock_read_timeout:
              value:
                error_code: 43009
                desc: Timeout error
                detail: "Failed to open video by url http://127.0.0.1:64434/vide3245o.mkv, status code: 504, Socket read timeout"
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-43009"
paths:
  /2/videosdk:
    post:
      tags: [videosdk]
      summary: video analytics
      description: Request for video analysis based on the specified analytics parameters eg facial estimations.
      operationId: videosdk
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - in: header
          name: Content-Type
          schema:
            type: string
            enum:
            - application/json
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/video_analytics_params'
        required: true

      responses:
        200:
          description: Estimated.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json_or_msgpack_content'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/video_analytics_response'
            application/msgpack:
              schema:
                $ref: '#/components/schemas/video_analytics_response_msgpack'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_content_type:
                  value:
                    error_code: 12017
                    desc: Bad/incomplete input data
                    detail: Bad content type
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12017"
        403:
          description: Access to this resource on the server is denied.
          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:
                one_rect_available:
                  value:
                    error_code: 11045
                    desc: Forbidden
                    detail: Only one detection rect for each image available at the moment
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11045"
                fsdk_liveness_disabled:
                  value:
                    error_code: 11055
                    desc: Forbidden
                    detail: "License problem: Liveness v.2 feature disabled"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11055"
                liveness_disabled:
                  value:
                    error_code: 11055
                    desc: Forbidden
                    detail: "License problem: Liveness feature disabled"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11055"
                licence_expired:
                  value:
                    error_code: 11055
                    desc: Forbidden
                    detail: "License problem: License expired"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11055"
                external_agent:
                  value:
                    error_code: 45004
                    desc: Forbidden
                    detail: "Luna Video Agent service is launched in an external mode"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-45004"
        500:
          $ref: '#/components/responses/internal_server_error'
        504:
          $ref: '#/components/responses/timeout_error'
  /2/video/tasks/{task_id}:
    parameters:
      - in: path
        name: task_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: task ID.

    get:
      tags:
        - video tasks
      summary: get task
      description: Get video task by ID.
      operationId: getVideoTask
      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/video_task_response'
        404:
          description: Task not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 44001
                desc: Object not found
                detail: Task with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44001
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/ws:
    get:
      tags:
      - ws
      summary: ws events handshake
      description: |
        Ws events handshake. The resource is designed to receive realtime events from analytics.
        > ### 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/stream_id'
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/analytic_index'

      responses:
        101:
          description: Success handshake.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/message_from_ws_abstract'
        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 'stream_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Stream not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 44001
                desc: Object not found
                detail: Stream with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44001
        500:
          $ref: '#/components/responses/internal_server_error'
      x-codeSamples:
        - lang: python
          label: async with websockets library
          source: |
            import asyncio
            import websockets

            async def main():
                uri = "ws://127.0.0.1:5240/1/ws?stream_id=70c75b04-1ec8-4aa1-930c-ddad9e47b54b"  # Note filtering by gender!
                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:5240/1/ws?stream_id=70c75b04-1ec8-4aa1-930c-ddad9e47b54b"
  /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:
    parameters:
      - $ref: '#/components/parameters/Accept'
    get:
      tags:
        - documents
      summary: get development manual
      description: |
        Get sphinx documentation - *Development Manual*. After the request you will be redirected to the page `/docs/dev/index.html`
      operationId: getDevManual

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/text_html'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            text/html:
              schema:
                type: string
                description: html format documentation
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/config:
    get:
      tags:
        - config
      summary: get service configuration
      description: Get service configuration. Passwords and tokens will be hidden in the response.
      operationId: getConfig

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/accept_config_handler'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/config_accept_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                description: json format configuration
              example:
                INFLUX_MONITORING:
                  SEND_DATA_FOR_MONITORING: 0
                  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
                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'
  /healthcheck:
    get:
      tags:
      - health
      summary: get health
      description: get health of service
      operationId: healthcheck
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/include_luna_services'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/health_ok'
        500:
          $ref: '#/components/responses/internal_server_error'
        502:
          description: Unhealthy
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/health_errors'
  /version:
    get:
      tags:
      - version

      summary: get version
      description: get service version
      operationId: getVersion

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/version'
        500:
          $ref: '#/components/responses/internal_server_error'
