openapi: 3.0.0
info:
  version: 'v.1.21.0'
  title: 'luna-video-manager API'
  description: |
     'VisionLabs luna-video-manager'

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.

    json_or_msgpack:
      schema:
        type: string
        enum:
        - application/json
        - application/msgpack
      required: true
      description: The content type of the response body.

    config_accept_content_type:
      schema:
        type: string
        enum:
          - application/json
          - text/plain
      required: false
      description: The content type of the response body.
  parameters:
    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

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

    event_source_groups:
      in: query
      name: event_source_groups
      schema:
        type: string
      description: Comma-separated list of source groups. Each stream from result will contain one of the given event source groups.
      example: "group-1,group-2"

    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
          - application/msgpack
      description: Preferred response content type

    accept_html:
      in: header
      name: Accept
      schema:
        type: string
        enum:
          - text/html
          - application/x-yaml
      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.

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

    luna_account_id_header_required:
      in: header
      schema:
        $ref: '#/components/schemas/account_id'
      description: Account ID.
      name: Luna-Account-Id
      required: true

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

    stream_ids:
      in: query
      name: stream_ids
      schema:
        type: array
        items:
          $ref: '#/components/schemas/stream_id'
      explode: false
      description: Stream ID filter. Only streams with the specified ids will be returned in the response.
      example: 'ae09126e-70a6-49c7-923f-df2320f08639,68b363eb-600a-4e72-afb3-8c4196e385ce'

    analytic_ids:
      in: query
      name: analytic_ids
      schema:
        type: array
        items:
          $ref: '#/components/schemas/analytic_id'
      explode: false
      description: Analytics ID filter. Only analytics with the specified ids will be returned in the response.
      example: 'ae09126e-80a9-49c7-923f-df2320f08639,68b363eb-600a-4e72-afb3-8c4196e385ce'

    agent_id:
      in: path
      name: agent_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the agent (`agent_id` received in the ["register agent"](#operation/registerAgent) request).

    agent_id_query:
      in: query
      name: agent_id
      schema:
        $ref: '#/components/schemas/uuid'
      description: Agent ID filter. Only streams associated with the specified id will be returned in the response.

    agent_ids:
      in: query
      name: agent_ids
      schema:
        type: array
        items:
          $ref: '#/components/schemas/agent_id'
      explode: false
      description: Agent ID filter. Only agents with the specified ids will be returned in the response.
      example: 'ae09126e-80a9-49c7-923f-df2320f08639,68b363eb-600a-4e72-afb3-8c4196e385ce'

    stream_names:
      in: query
      name: names
      schema:
        type: array
        items:
          $ref: '#/components/schemas/stream_name'
      explode: false
      description: Stream name filter. Only streams with the specified names will be returned in the response.
      example: 'name1,name2'

    agent_names:
      in: query
      name: names
      schema:
        type: array
        items:
          $ref: '#/components/schemas/agent_name'
      explode: false
      description: Agent name filter. Only agents with the specified names will be returned in the response.
      example: 'name1,name2'

    analytic_names:
      in: query
      name: names
      schema:
        type: array
        items:
          $ref: '#/components/schemas/analytic_name'
      explode: false
      description: Analytic name filter. Only streams with the specified names will be returned in the response.
      example: 'name1,name2'

    stream_reference:
      in: query
      name: reference
      schema:
        $ref: '#/components/schemas/stream_reference'
      description: Stream reference filter. Only streams with the specified reference will be returned in the response.

    stream_statuses:
      in: query
      name: statuses
      schema:
        type: array
        items:
          $ref: '#/components/schemas/stream_status'
      explode: false
      description: Stream status filter - comma-separated list of status values. Only streams with the specified statuses will be returned in the response.
      example: '1,2'

    create_time__lt:
      in: query
      name: create_time__lt
      schema:
        $ref: '#/components/schemas/time'
      description: Entity create time upper excluding bound filter in RFC 3339 format. Only entities with the creation time lower than the specified boundary will be returned in the response.
      example: "2021-09-21T19:11:41.674Z"

    create_time__gte:
      in: query
      name: create_time__gte
      schema:
        $ref: '#/components/schemas/time'
      description: Entity create time lower including bound filter in RFC 3339 format. Only entities with the creation time greater than or equal to the specified boundary will be returned in the response.
      example: "2021-09-21T11:11:41.674Z"

    stream_id__gte:
      in: query
      name: stream_id__gte
      schema:
        $ref: '#/components/schemas/stream_id'
      description: Stream id lower included bound.
      example: 'ae09126e-70a6-49c7-923f-df2320f08639'

    stream_id__lt:
      in: query
      name: stream_id__lt
      schema:
        $ref: '#/components/schemas/stream_id'
      description: Stream id upper excluded bound.
      example: 'ae09126e-70a6-49c7-923f-df2320f08639'

    analytic_id__gte:
      in: query
      name: analytic_id__gte
      schema:
        $ref: '#/components/schemas/analytic_id'
      description: Analytic id lower included bound.
      example: 'ae09126e-70a6-49c7-923f-df2320f08639'

    analytic_id__lt:
      in: query
      name: analytic_id__lt
      schema:
        $ref: '#/components/schemas/analytic_id'
      description: Analytic id upper excluded bound.
      example: 'ae09126e-70a6-49c7-923f-df2320f08639'

    agent_id__gte:
      in: query
      name: agent_id__gte
      schema:
        $ref: '#/components/schemas/agent_id'
      description: Agent id lower included bound.
      example: 'ae09126e-70a6-49c7-923f-df2320f08639'

    agent_id__lt:
      in: query
      name: agent_id__lt
      schema:
        $ref: '#/components/schemas/agent_id'
      description: Agent id upper excluded bound.
      example: 'ae09126e-70a6-49c7-923f-df2320f08639'

    group_name:
      in: query
      name: group_name
      schema:
        $ref: '#/components/schemas/group_name'
      description: Group name filter. Only groups with the specified names will be returned in the response.
      example: "group1"

    group_id:
      in: query
      name: group_id
      schema:
        $ref: '#/components/schemas/group_id'
      description: Group id filter. Only streams belonging to the specified group id will be returned in the response.
      example: "0a06acd1-dd2a-4630-ba5e-95423b1e9601"

    group_names:
      in: query
      name: group_names
      schema:
        type: array
        items:
          $ref: '#/components/schemas/group_name'
      description: Group names.
      example: "group1,group2"

    group_ids:
      in: query
      name: group_ids
      schema:
        type: array
        items:
          $ref: '#/components/schemas/group_id'
      explode: false
      description: Group IDs.
      example: 'ae09126e-70a6-49c7-923f-df2320f08639,68b363eb-600a-4e72-afb3-8c4196e385ce'

    with_streams:
      in: query
      name: with_streams
      schema:
        type: integer
        enum: [0, 1]
        default: 0
      description: Whether to delete the group will all its streams.

    log_time__lt:
      in: query
      name: log_time__lt
      schema:
        $ref: '#/components/schemas/time'
      description: Stream log record time upper excluding bound filter in RFC 3339 format. Only stream logs with the record time lower than the specified boundary will be returned in the response.
      example: "2021-09-21T19:11:41.674Z"

    log_time__gte:
      in: query
      name: log_time__gte
      schema:
        $ref: '#/components/schemas/time'
      description: Stream log record time lower including bound filter in RFC 3339 format. Only stream log with the record time greater than or equal to the specified boundary will be returned in the response.
      example: "2021-09-21T11:11:41.674Z"

    log_time__lt_deleting:
      in: query
      name: log_time__lt
      schema:
        $ref: '#/components/schemas/time'
      description: Stream log record time upper excluding bound filter in RFC 3339 format. Only stream logs with the record time lower than the specified boundary will be deleted.
      example: "2021-09-21T19:11:41.674Z"

    log_targets:
      in: query
      name: targets
      schema:
        type: array
        items:
          type: string
          enum: [ stream_id, status, error, log_time, last_processed_frame_time, analytic_index ]
          description: Stream log target.
        example: [ status ]
        default: [ stream_id, status, error, log_time, last_processed_frame_time, analytic_index ]
      description: List of comma-separated stream logs targets.

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

        By default, the results will be sorted in order of stream appearance in the database (may not match stream `create_time`).
        If "desc" is set, the newest streams will be shown first. If "asc" is set, the oldest streams will be shown first.

        But if some stream ID range filters specified (`<entity>_id__gte` or `<entity>_id__lt`), the results will be sorted by ID.

    order_column:
      in: query
      name: order_column
      schema:
        type: string
        enum: ["create_time", "name"]
      description: |
        The sort column.
        
        > **WARNING**: if some stream ID range filters specified (`stream_id__gte` or `stream_id__lt`), the results will be sorted by stream ID.

    page:
      in: query
      name: page
      schema:
        type: integer
        minimum: 1
        default: 1
      description: Page number.

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

    patch_stream_action:
      in: query
      name: action
      schema:
        type: string
        enum: [stop, resume]
      required: true
      description: |
        stop - stop stream processing, stream status will be switched to `stop`
        resume - resume stream processing, stream status will be switched to `pending`

    path_stream_id:
      in: path
      name: stream_id
      schema:
        $ref: '#/components/schemas/uuid'
      required: true
      description: ID of the stream (`stream_id` received in the ["create stream"](#operation/createStream) request).

    restream_quality:
      in: query
      name: quality
      schema:
        $ref: '#/components/schemas/restream_quality'
      description: Restream quality filter.
      example: 720
      required: false

    splittable:
      in: query
      name: splittable
      schema:
        allOf:
          - $ref: '#/components/schemas/splittable_base'
          - enum: [0, 1]
      example: 1
      required: false

    analytic_index:
      in: query
      name: analytic_index
      schema:
        allOf:
          - $ref: '#/components/schemas/analytic_index'
          - default: 0
      required: false

    path_analytic_index:
      in: path
      name: analytic_idx
      schema:
        $ref: '#/components/schemas/analytic_index'
      required: true

    analytic_indexes:
      in: query
      name: analytic_indexes
      schema:
        type: string
      description: Comma-separated list of analytics indexes. Each index from result will contain one of the given indexes.
      example: 0,1

    schedule_id:
      in: path
      name: schedule_id
      schema:
        $ref: '#/components/schemas/schedule_id'
      required: true
      description: Schedule template id.

    schedule_ids:
      in: query
      name: schedule_ids
      schema:
        type: string
      description: Comma-separated list of template schedule ids. Each index from result will contain one of the given indexes.

    intervals_idx:
      in: path
      name: intervals_idx
      schema:
        $ref: '#/components/schemas/intervals_idx'
      required: true
      description: Index of interval list.

    merged:
      in: query
      name: merged
      schema:
        type: integer
        enum: [0, 1]
        default: 0
      required: false
      description: Whether return merged intervals or list of lists with intervals.

    stream_targets:
      in: query
      name: targets
      schema:
        type: string
        default: "stream_id,account_id,name,description,data,location,source,version,create_time,last_error,groups,status,splittable,analytics,notification_policy"
      description: |
        Comma-separated list of stream target fields. Available targets: `stream_id`, `account_id`, `name`,
        `description`, `data`, `location`, `source`, `event_source_group`, `version`, `create_time`, `last_error`, `groups`, `status`,
        `splittable`, `analytics`, `notification_policy`

        **WARNING**: If `enriched` is set to `0`, this parameter will be ignored.
      example:
        "data,notification_policy"

    enriched:
      in: query
      name: enriched
      schema:
        type: integer
        enum: [ 0, 1 ]
        default: 1
      example: 1
      required: false
      description: |
        Whether to return stream assembled from group settings (if stream linked to group(s)).
        
        If enriched is set to `0`, only `stream_id` and settings/analytics specified during stream creation request
        will be returned.

    streams_update:
      in: query
      name: streams_update
      schema:
        type: integer
        enum: [ 0, 1 ]
        default: 1
      example: 1
      required: false
      description: |
        Whether to update existing streams which linked to group.
        
        **WARNING**: If streams linked to group which has been updated using this request with `streams_update` parameter
        set to 1, versions of streams will be updated.

        **WARNING**: Only streams which have status `pending`, `in_progress`, `restart`, `paused` will be updates 
        if `streams_update` set to 1

    check_agent:
      in: query
      name: check_agent
      schema:
        type: integer
        enum: [ 0, 1 ]
        default: 1
      example: 1
      description: |
        Whether to check existence of agent (or agents for splittable streams) which is (are) applicable for all
        specified analytics. 
        
        If set to `0` and no such agent(s) are available, stream will have in pending status until such agent(s) appears.
        
        In all cases if stream is created but all suitable agents have no free slots, stream will have pending status
        until such agent(s) appears.
  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

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

    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

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

    uuid:
      type: string
      format: uuid
      pattern: '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$'
      example: "557d54ec-29ad-4f3c-93b4-c9092ef12515"

    account_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: Account ID for authentication in the LUNA PLATFORM.

    analytics_account_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - nullable: true
        - description: |
            Account ID for authentication in the LUNA PLATFORM. If analytics is created by internal agent and available
            for all users, it will be **null*.

    stream_name:
      type: string
      maxLength: 128
      default: "stream"
      example: "stream"

    stream_description:
      type: string
      maxLength: 512
      default: ""

    analytic_name:
      allOf:
        - $ref: '#/components/schemas/string36'
      pattern: '^[a-zA-Z0-9_\-]{1,36}$'
      description: Analytic name.
      example: some name

    agent_name:
      type: string
      pattern: '^[a-zA-Z0-9_\-]{3,128}$'
      minLength: 3
      maxLength: 128
      description: Agent name.
      example: some name

    stream_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - example: 426542d6-5509-4e5b-8a01-e2abd5c0a8c6
      description: Stream ID.

    analytic_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - example: 426542d6-5509-4e5b-8a01-e2abd5c0a8c6
      description: Analytic ID.

    agent_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - example: 426542d6-5509-4e5b-8a01-e2abd5c0a8c6
      description: Agent ID.

    string512_default:
      type: string
      maxLength: 512
      default: ""

    string36:
      type: string
      maxLength: 36

    string36_nullable:
      type: string
      maxLength: 36
      nullable: true

    stream_to_be_created_with_group_name:
      title: group link by group name
      allOf:
        - $ref: '#/components/schemas/stream_to_be_created_without_default'
        - properties:
            group_name:
              $ref: '#/components/schemas/group_name'
        - required: [data, group_name]

    stream_to_be_created_with_group_id:
      title: group link by group id
      allOf:
        - $ref: '#/components/schemas/stream_to_be_created_without_default'
        - properties:
            group_id:
              $ref: '#/components/schemas/group_id'
        - required: [data, group_id]

    _stream_to_be_created_with_group:
      anyOf:
        - $ref: '#/components/schemas/stream_to_be_created_with_group_name'
        - $ref: '#/components/schemas/stream_to_be_created_with_group_id'

    stream_to_be_created_with_group:
      allOf:
        - title: Stream linked to group
        - $ref: '#/components/schemas/_stream_to_be_created_with_group'

    stream_to_be_created_without_group:
      allOf:
        - title: Stream not linked to group
        - $ref: '#/components/schemas/stream_to_be_created_with_default'

    stream_to_be_created:
      anyOf:
        - $ref: '#/components/schemas/stream_to_be_created_without_group'
        - $ref: '#/components/schemas/stream_to_be_created_with_group'

    group_name:
      type: string
      pattern: '^[a-zA-Z0-9_\-]{1,128}$'
      description: Stream group name.
      example: "hd_stream_2"

    group_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - example: 426542d6-5509-4e5b-8a01-e2abd5c0a8c6
      description: Stream group ID.

    group_description:
      type: string
      description: Stream group description.
      maxLength: 256


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

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

    geo_position_without_default:
      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.
      example:
        longitude: 36.616
        latitude: 55.752

    geo_position:
      allOf:
        - $ref: '#/components/schemas/geo_position_without_default'
        - required: [longitude, latitude]

    geo_position_with_default:
      allOf:
        - $ref: '#/components/schemas/geo_position_without_default'
        - required: [ longitude, latitude ]
      default: null

    label:
      type: string
      maxLength: 36
      description: >
        Unique label for the analytics item within its group. 
        If not provided, it will be automatically generated as `analytics_0`, `analytics_1`, etc.
      example: label_0

    stream_label:
      type: string
      maxLength: 36
      description: Unique label for the analytics item within its stream. Use for merge analytics from group.
      example: label_0

    analytics_group_with_schedules:
      type: array
      minItems: 1
      items:
        allOf:
          - $ref: '#/components/schemas/analytics_with_schedules/items'
          - type: object
            properties:
              label:
                $ref: '#/components/schemas/label'

    analytics_group_response:
      type: array
      items:
        type: object
        properties:
          analytic_name:
            $ref: '#/components/schemas/analytic_name'
          parameters:
            $ref: '#/components/schemas/analytic_parameters'
          label:
            $ref: '#/components/schemas/label'
          intervals:
            $ref: '#/components/schemas/intervals'
        required: [analytic_name, parameters, label, intervals]

    location_to_be_created_without_default:
      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_without_default'
      description: Stream location parameters.

    location_to_be_created_with_default:
      allOf:
        - $ref: '#/components/schemas/location_to_be_created_without_default'
        - type: object
          properties:
            geo_position:
              $ref: '#/components/schemas/geo_position_with_default'
      default:
        city: null
        area: null
        district: null
        street: null
        house_number: null
        geo_position: null

      example:
        city: Moscow
        area: Central
        district: Basmanny
        street: Podsosensky lane
        house_number: 23 bldg.3
        geo_position:
          longitude: 36.616
          latitude: 55.752

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

    event_source_group:
      description: Additional information about stream source.
      type: string
      pattern: ^[a-zA-Z0-9_\-]+$
      maxLength: 256
      example: "group-123"

    event_source_group_nullable:
      allOf:
        - $ref: '#/components/schemas/event_source_group'
        - nullable: true

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

    source_nullable:
      allOf:
        - $ref: '#/components/schemas/source'
        - nullable: true

    autorestart_restart_without_default:
      type: integer
      enum: [ 0, 1 ]
      description: Whether to allow autorestart.

    autorestart_attempt_count_without_default:
      type: integer
      minimum: 1
      description: Stream autorestart attempt count.

    autorestart_delay_without_default:
      type: integer
      minimum: 1
      description: |
        Stream autorestart delay, in seconds.
        
        Success or failure stream autorestart determines by last stream status received in *delay* seconds after *last_attempt_time*.
        
        For more information about autorestart see *Streams automatic restart* chapter of development manual.

    stream_autorestart_without_default:
      type: object
      properties:
        restart:
          $ref: '#/components/schemas/autorestart_restart_without_default'
        attempt_count:
          $ref: '#/components/schemas/autorestart_attempt_count_without_default'
        delay:
          $ref: '#/components/schemas/autorestart_delay_without_default'
      description: Stream autorestart parameters.

    stream_autorestart:
      type: object
      properties:
        restart:
          $ref: '#/components/schemas/autorestart_restart_without_default'
        attempt_count:
          $ref: '#/components/schemas/autorestart_attempt_count_without_default'
        delay:
          $ref: '#/components/schemas/autorestart_delay_without_default'
      description: Stream autorestart parameters.

    stream_reference:
      type: string
      maxLength: 2083
      description: path to stream source (stream or videofile)
      example: https://upload.wikimedia.org/wikipedia/commons/2xQ2gprbMUePw1s9gw9fvA==

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

    rotation_without_default:
      type: integer
      enum: [ 0, 90, 180, 270 ]
      description: |
        Angle of camera frame rotation.
        
        Note that user-defined rotation angle will be ignored in the case of *video_info* *orientation_strategy*.

    start_time_without_default:
      type: number
      min: 0
      nullable: false
      description: custom video start time

    video_pts:
      type: object
      description: Video timestamp settings.
      nullable: false
      properties:
        start_time:
          $ref: '#/components/schemas/start_time_without_default'
      required: [start_time]

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

    schedule_to_create:
      oneOf:
        - type: object
          properties:
            schedule_id:
              $ref: '#/components/schemas/schedule_id'
          required: [schedule_id]
        - type: object
          properties:
            intervals:
              $ref: '#/components/schemas/intervals'
          required: [intervals]

    schedule_to_replace_by_id:
      type: object
      properties:
        schedule_id:
          $ref: '#/components/schemas/schedule_id'
      required: [schedule_id]

    schedule_to_replace_by_intervals:
      type: object
      properties:
        intervals:
          $ref: '#/components/schemas/intervals'
      required: [intervals]

    schedule_to_replace:
      oneOf:
        - $ref: '#/components/schemas/schedule_to_replace_by_id'
        - $ref: '#/components/schemas/schedule_to_replace_by_intervals'

    analytics_schedules:
      type: array
      description: |
        Analytics schedules allow to set working intervals for each stream analytics. If Stream is *in_progress* but
        turned off by schedule, the *agent* slot will be reserved all time while stream in *in_progress*.
        
        Analytics working intervals can be specified in two ways or their combinations:
        
        - using [previously created *schedule*](#tag/schedule-template/operation/createScheduleTemplate) by specifying it's id
        - specifying intervals (can be calculated using [intervals calculation request](#tag/schedule-template/operation/calcIntervals))
        
        If more than one working intervals lists specified, it will be merged into one final intervals group, to
        see non merged and merged final working intervals, us [get stream analytics working intervals request](#tag/streams-schedules/operation/getStreamSchedules)
        with specifying *merged* query parameter.
        
        If working intervals not specified, the analytics will be work all time stream processing works.

        **WARNING**: Available only for *stream*, not available for `videofile`.

        **WARNING**: If all stream analytics processing are *on pause* and in this time stream ends or became unavailable,
        no errors or warning will appears before at least one of stream analytics reach the next work interval.
      items:
        $ref: '#/components/schemas/schedule_to_create'
      minItems: 1
      maxItems: 64

    analytics_base:
      type: object
      properties:
        analytic_name:
          $ref: '#/components/schemas/analytic_name'
        parameters:
          $ref: '#/components/schemas/analytic_parameters'
      required: [analytic_name]

    analytics_with_schedules:
      type: array
      description: |
        Analytics.
        **WARNING**: May be missing only if created with group and group contains analytics
      minItems: 1
      items:
        allOf:
          - $ref: '#/components/schemas/analytics_base'
          - properties:
              schedules:
                $ref: '#/components/schemas/analytics_schedules'

    analytics_with_schedules_labeled:
      allOf:
        - $ref: '#/components/schemas/analytics_with_schedules'
        - type: array
          items:
            type: object
            properties:
              label:
                $ref: '#/components/schemas/stream_label'
        - example:
            - analytic_name: people_count

    intervals_obj_base:
      type: object
      description: Analytics working intervals and its' version.
      properties:
        intervals:
          $ref: '#/components/schemas/simple_intervals'
        intervals_version:
          $ref: '#/components/schemas/intervals_version'
      required: [intervals, intervals_version]

    intervals_obj_with_indexes:
      type: array
      items:
        allOf:
          - $ref: '#/components/schemas/intervals_obj_base'
          - properties:
              analytic_idx:
                $ref: '#/components/schemas/analytic_index'
        required: [intervals, intervals_version, analytic_idx]

    analytics_with_intervals:
      allOf:
        - $ref: '#/components/schemas/analytics_base'
        - properties:
            intervals:
              $ref: '#/components/schemas/intervals_obj_base'

    analytics:
      type: array
      description: list of analytics with its parameters
      items:
        $ref: '#/components/schemas/analytics_base'
      minItems: 1

    analytics_with_intervals_list:
      type: array
      description: list of analytics with its parameters
      items:
        $ref: '#/components/schemas/analytics_with_intervals'
      minItems: 1

    simple_intervals:
      type: array
      description: Array of sorted integers(timestamps), where odd elements are intervals starts, even elements are intervals ends.
      minItems: 2
      items:
        type: integer
        minimum: 0

    analytics_response:
      allOf:
        - $ref: '#/components/schemas/analytics_with_intervals_list'
      type: array
      items:
        type: object
        properties:
          idx:
            $ref: '#/components/schemas/analytic_index'
        required: [analytic_name, parameters, idx]

    splittable_base:
      type: integer
      description: |
        Allow to distribute stream processing to more than one agent in case when no one agent support all specified
        analytics set. All splittable stream parts will be processed (including logs, autorestart, etc) as separate 
        stream, see developers documentation for details.

    splittable_without_default:
      allOf:
        - $ref: '#/components/schemas/splittable_base'
        - enum: [0, 1]

    _retry:
      type: object
      nullable: true
      properties:
        delay:
          type: integer
          minimum: 1
          description: The time in milliseconds between attempts to reconnect to the stream source.
        attempt_count:
          type: integer
          minimum: 0
          maximum: 65535
          description:
            The number of attempts to reconnect to the stream source. 
            If the value is 0, no retries will be made.

    eof_retry_without_default:
      allOf:
      - $ref: '#/components/schemas/_retry'
      - description: |
          Parameters for repeated attempts in case of the end of the stream source (EOF).

          **WARNING**: Can't be set for type `videofile`.

    decode_retry_without_default:
      allOf:
      - $ref: '#/components/schemas/_retry'
      - description: |
          Parameters for repeated attempts in case of stream decoding error.

          **WARNING**: Can't be set for type `videofile`.

    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.
      description: Callback basic authorization parameters.
      required: [type, login, password]

    http_callback:
      type: object
      properties:
        type:
          type: string
          enum: [ http ]
        authorization:
          $ref: '#/components/schemas/callback_basic_authorization'
        url:
          type: string
          description: Request URL.
          format: uri-reference
        params:
          type: object
          properties:
            timeout:
              type: integer
              description: Callback request timeout.
              default: 60
            content_type:
              type: string
              enum: [ application/json, application/msgpack ]
              description: Callback request content type.
              default: application/json
            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]

    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
              description: Callback request timeout.
              default: 60
        enable:
          allOf:
            - $ref: '#/components/schemas/int01'
            - description: Whether callback enabled or not
            - default: 1
      required: [type, chat_id, token]

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

    stream_callbacks:
      type: array
      items:
        $ref: '#/components/schemas/stream_callback'
      default: []
      description: |
        Callbacks for sending stream id and status to third party system. Callbacks are executed after stream status changed.

        **Sample Output for successful stream processing**
        ```
        {
          "stream_id": '00000000-0000-4000-a000-000000658854',  
          "status": "done",  
        }
        ```

        **Sample Output for failed stream processing**
        ```
        {
        'stream_id': '015940f7-63f5-4576-92d1-c745eb058aa7', 
        'status': 'failure'
        }
        ```
        
        
        **Sample Output for stream processing stopped by user**
        ```
        {
        'stream_id': '015940f7-63f5-4576-92d1-c745eb058aa7', 
        'status': 'stop'
        }
        ```
      example:
        $ref: "#/components/schemas/stream_callbacks_example"

    stream_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_enable:
      allOf:
        - $ref: '#/components/schemas/int01'
        - description: Whether callbacks enabled or not

    notification_policy_without_default:
      type: object
      description: stream processing notification policy
      properties:
        enable:
          $ref: '#/components/schemas/notification_policy_enable'
        stream_callbacks:
          $ref: '#/components/schemas/stream_callbacks'

    notification_policy:
      type: object
      description: stream processing notification policy
      properties:
        enable:
          $ref: '#/components/schemas/notification_policy_enable'
        stream_callbacks:
          $ref: '#/components/schemas/stream_callbacks'

    notification_policy_required:
      allOf:
        - $ref: '#/components/schemas/notification_policy'
        - required: [ enable, stream_callbacks ]

    stream_to_be_created_except_notification_policy:
      type: object
      properties:
        name:
          allOf:
            - $ref: '#/components/schemas/stream_name'
          description: Stream name.
        description:
          allOf:
            - $ref: '#/components/schemas/stream_description'
          description: Stream description.
          default: ""
        data:
          anyOf:
          - $ref: '#/components/schemas/stream_data_orientation_static_without_default'
          - $ref: '#/components/schemas/stream_data_orientation_video_info_without_default'
        location:
          $ref: '#/components/schemas/location_to_be_created_without_default'
        event_source_group:
          $ref: '#/components/schemas/event_source_group'
        source:
          $ref: '#/components/schemas/source'
        autorestart:
          $ref: '#/components/schemas/stream_autorestart'
        analytics:
          $ref: '#/components/schemas/analytics_with_schedules_labeled'
        splittable:
          $ref: '#/components/schemas/splittable_without_default'
      required: [ data ]

    stream_to_be_created_without_default:
      allOf:
        - $ref: '#/components/schemas/stream_to_be_created_except_notification_policy'
        - properties:
            notification_policy:
              $ref: '#/components/schemas/notification_policy_without_default'

    stream_to_be_created_with_default:
      allOf:
      - $ref: '#/components/schemas/stream_to_be_created_except_notification_policy'
      - required: [data, analytics]
      - properties:
          data:
            properties:
              downloadable:
                default: false
              timestamp_source:
                default: auto
              pts:
                properties:
                  start_time:
                    default: 0
              timeout:
                default: 3000
              rotation:
                default: 0
              orientation_strategy:
                default: static
              behavior_parameters:
                properties:
                  eof_retry:
                    properties:
                      delay:
                        default: 100
                      attempt_count:
                        default: 10
                  decode_error_retry:
                    properties:
                      delay:
                        default: 100
                      attempt_count:
                        default: 10
          location:
            properties:
              geo_position:
                required: [latitude, longitude]
          autorestart:
            properties:
              restart:
                default: 0
              attempt_count:
                default: 10
              delay:
                default: 60
          notification_policy:
            $ref: '#/components/schemas/notification_policy'

    downloadable_without_default:
      type: boolean
      description: Whether to download reference via HTTP `GET` request before processing.

    timestamp_source_without_default:
      type: string
      enum: [auto, pts, server, frame_rate, dts]
      description: |
        Timestamp source:
        
        `pts/dts` - video labels | only when labels exist
        
        `server` - server time | only for stream
        
        `frame_rate` - video file
        
        `auto` - `pts` if video/stream contains correct `pts`, otherwise `server` for stream or `frame_rate` for video file.

        Correct `pts` for video file means time from video label differs to video start less than `-10**5`s.

        Correct `pts` for stream means time from stream differs to server time less than 1 day.

    stream_read_timeout_without_default:
      type: integer
      nullable: true
      description: |
        Stream [read timeout](https://ffmpeg.org/ffmpeg-protocols.html) for `stream` in ms.

        [Total timeout](http://docs.aiohttp.org/en/stable/client_reference.html) for `videofile` download.
        
        The default one from config will be used if not specified (from 
        `LUNA_VIDEO_AGENT_VIDEO_SETTINGS`/`LUNA_VIDEO_AGENT_VIDEO_SETTINGS` setting).

        **WARNING**: The default value is *null* for `videofile`.
      minimum: 100
      maximum: 2147483647

    ffmpeg_kwargs:
      type: object
      additionalProperties: true
      nullable: true
      description: |
        Additional kwargs for *ffmpeg* decoder. 
        
        > **NOTE** If source reference is *rtsp* stream and to *rtsp_transport*
        specified, the *tcp* *rtsp_transport* will be selected as default. 
        
        To see possible arguments and values, see [*ffmpeg* documentation](https://ffmpeg.org/documentation.html).
        
        > **WARNING** these parameters will only passed to *ffmpeg* without any validation, if any error occurred
        during parameters processing, it will be available in [streams logs](#tag/streams-logs).

    behavior_parameters_without_default:
      type: object
      nullable: true
      properties:
        eof_retry:
          $ref: '#/components/schemas/eof_retry_without_default'
        decode_error_retry:
          $ref: '#/components/schemas/decode_retry_without_default'
      description: |
        Additional parameters for changing the stream processing behavior.

    group_data_base:
      type: object
      properties:
        downloadable:
          $ref: '#/components/schemas/downloadable_without_default'
        timestamp_source:
          $ref: '#/components/schemas/timestamp_source_without_default'
        pts:
          $ref: '#/components/schemas/video_pts'
        fps:
          $ref: '#/components/schemas/video_fps'
        timeout:
          $ref: '#/components/schemas/stream_read_timeout_without_default'
        orientation_strategy:
          $ref: '#/components/schemas/orientation_strategy_without_default'
        ffmpeg_kwargs:
          $ref: '#/components/schemas/ffmpeg_kwargs'
        behavior_parameters:
          $ref: '#/components/schemas/behavior_parameters_without_default'

    stream_data_base_without_default:
      type: object
      properties:
        type:
          type: string
          enum: ["stream", "videofile"]
          description: |
            Type - `stream` or `videofile`.

            > **WARNING** combining type `stream` with a reference to an actual
            video file may lead to unexpected behaviour. As a mitigation measure,
            `behavior_parameters.eof_retry.attempt_count` can be set to zero.

        reference:
          $ref: '#/components/schemas/stream_reference'
        downloadable:
          $ref: '#/components/schemas/downloadable_without_default'
        timestamp_source:
          $ref: '#/components/schemas/timestamp_source_without_default'
        pts:
          $ref: '#/components/schemas/video_pts'
        fps:
          $ref: '#/components/schemas/video_fps'
        timeout:
          $ref: '#/components/schemas/stream_read_timeout_without_default'
        orientation_strategy:
          $ref: '#/components/schemas/orientation_strategy_without_default'
        ffmpeg_kwargs:
          $ref: '#/components/schemas/ffmpeg_kwargs'
        behavior_parameters:
          $ref: '#/components/schemas/behavior_parameters_without_default'
      required: [ type, reference ]

    stream_data_base_with_default:
      allOf:
        - $ref: '#/components/schemas/stream_data_base_without_default'
        - properties:
            downloadable:
              $ref: '#/components/schemas/downloadable_without_default'

    _stream_data_orientation_static_without_default:
      allOf:
        - $ref: '#/components/schemas/stream_data_base_without_default'
        - properties:
            orientation_strategy:
              allOf:
                - $ref: '#/components/schemas/orientation_strategy_without_default'
                - enum: ["static"]
            rotation:
              $ref: '#/components/schemas/rotation_without_default'

    stream_data_orientation_static_without_default:
      allOf:
        - title: stream data with static orientation strategy
        - $ref: '#/components/schemas/_stream_data_orientation_static_without_default'

    _stream_data_orientation_video_info_without_default:
      allOf:
        - $ref: '#/components/schemas/stream_data_base_without_default'
        - properties:
            orientation_strategy:
              allOf:
                - $ref: '#/components/schemas/orientation_strategy_without_default'
                - enum: ["video_info"]

    stream_data_orientation_video_info_without_default:
      allOf:
        - title: stream data with video-info orientation strategy
        - $ref: '#/components/schemas/_stream_data_orientation_video_info_without_default'

    stream_data_orientation_static_with_default:
      allOf:
        - $ref: '#/components/schemas/stream_data_base_with_default'
        - properties:
            orientation_strategy:
              allOf:
                - $ref: '#/components/schemas/orientation_strategy_without_default'
                - enum: ["static"]
                - default: static
            rotation:
              allOf:
              - $ref: '#/components/schemas/rotation_without_default'
              default: 0

    stream_data_orientation_video_info_with_default:
      allOf:
        - $ref: '#/components/schemas/stream_data_base_with_default'
        - properties:
            orientation_strategy:
              allOf:
                - $ref: '#/components/schemas/orientation_strategy_without_default'
                - enum: ["video_info"]
                - default: static

    group_orientation_static:
      allOf:
        - $ref: '#/components/schemas/group_data_base'
        - properties:
            orientation_strategy:
              allOf:
                - $ref: '#/components/schemas/orientation_strategy_without_default'
                - enum: ["static"]
            rotation:
              $ref: '#/components/schemas/rotation_without_default'

    group_orientation_video_info:
      allOf:
        - $ref: '#/components/schemas/group_data_base'
        - properties:
            orientation_strategy:
              allOf:
                - $ref: '#/components/schemas/orientation_strategy_without_default'
                - enum: ["video_info"]

    stream_data:
      anyOf:
        - $ref: '#/components/schemas/stream_data_orientation_static_with_default'
        - $ref: '#/components/schemas/stream_data_orientation_video_info_with_default'
      discriminator:
        propertyName: "orientation_strategy"
        mapping:
          static: '#/components/schemas/stream_data_orientation_static_with_default'
          video_info: '#/components/schemas/stream_data_orientation_video_info_with_default'

    group_data:
      anyOf:
        - $ref: '#/components/schemas/group_orientation_static'
        - $ref: '#/components/schemas/group_orientation_video_info'
      discriminator:
        propertyName: "orientation_strategy"
        mapping:
          static: '#/components/schemas/group_orientation_static'
          video_info: '#/components/schemas/group_orientation_video_info'

    group_version:
      type: integer
      minimum: 1
      description: Group version. Increased when group data is updated via PUT /groups/{group_id} method.

    stream_version:
      type: integer
      minimum: 1
      description: Stream version. Increased when stream data is updated via PUT /streams/{stream_id} method.

    stream_status:
      type: integer
      description: |
        stream status
        | Status name  | Value | Description                                                              | 
        |--------------|-------|--------------------------------------------------------------------------|
        | pending      | 0     | Stream is waiting for processing.                                        |
        | in_progress  | 1     | Stream processing is in progress.                                        |
        | done         | 2     | Stream processing is completed.                                          |
        | restart      | 3     | Stream processing is restarted by server.                                |
        | failure      | 4     | Stream processing is failed.                                             |
        | stop         | 5     | Stream processing is stopped by user.                                    |
        | unknown      | 6     | Splittable stream has different statuses on each agent                   |
        | handler_lost | 7     | stream processing handler is lost, needs to be passed to another handler |
        | paused       | 8     | stream processing is paused due to schedule                              |

        > **WARNING**: Stream status list may be expanded in the future.

        > **NOTE**: Splittable stream status is a general status of all its parts.
      enum: [0,1,2,3,4,5,6,7,8]

    feedback_stream_status:
      type: integer
      description: |
        stream status
        | Status name  | Value | Description                                 | 
        |--------------|-------|---------------------------------------------|
        | in_progress  | 1     | Stream processing is in progress.           |
        | done         | 2     | Stream processing is completed.             |
        | failure      | 4     | Stream processing is failed.                |
        | stop         | 5     | Stream processing is stopped.               |
        | paused       | 8     | stream processing is paused due to schedule |

        > **WARNING**: Stream status list may be expanded in the future.
      enum: [1,2,4,5,8]

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

    stream_autorestart_response:
      allOf:
        - $ref: '#/components/schemas/stream_autorestart'
        - properties:
            current_attempt:
              type: integer
              minimum: 0
              nullable: true
              description: Stream autorestart current attempt number | zero means no attempt was made
            last_attempt_time:
              allOf:
                - $ref: '#/components/schemas/time'
              nullable: true
              description: Last autorestart attempt time | null means no attempt was made.
            status:
              type: string
              nullable: false
              enum: [ disabled, enabled, in_progress, failed, denied ]
              description: |
                Stream autorestart status.
                
                | status   | description |
                |-------------|------------------------------------------|
                | disabled    | stream autorestart is disabled by user   |
                | enabled     | stream autorestart is enabled            |
                | in_progress | autorestart in progress                  |
                | failed      | autorestart failed                       |
                | denied      | autorestart is denied due to fatal error |

                > **WARNING**: Stream autorestart status list may be expanded in the future.

      description: Stream autorestart parameters and status.

    stream_error:
      type: string
      nullable: True
      description: |
        Stream processing error description.
        
        > **WARNING**: Fatal error prevent stream autorestart. Currently, fatal error is considered "validation error" and "invalid rectangle".

        See [developer manual](#operation/getDevManual) for more information.
      example: null

    stream_response:
      type: object
      properties:
        stream_id:
          $ref: '#/components/schemas/stream_id'
        account_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: Stream account ID.
        name:
          $ref: '#/components/schemas/stream_name'
        description:
          allOf:
            - $ref: '#/components/schemas/stream_description'
          description: Stream description.
          example: some description
        data:
          $ref: '#/components/schemas/stream_data'
        location:
          $ref: '#/components/schemas/location'
        event_source_group:
          $ref: '#/components/schemas/event_source_group_nullable'
        source:
          $ref: '#/components/schemas/source_nullable'
        version:
          $ref: '#/components/schemas/stream_version'
        create_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: Stream create time.
        last_error:
          $ref: '#/components/schemas/stream_error'
        groups:
          type: array
          items:
            $ref: '#/components/schemas/group_name'
          description: List of groups the stream belongs to.
        status:
          $ref: '#/components/schemas/stream_status'
        splittable:
          $ref: '#/components/schemas/splittable_without_default'
        analytics:
          type: array
          minItems: 1
          items:
            type: object
            properties:
              analytic_name:
                $ref: '#/components/schemas/analytic_name'
              parameters:
                $ref: '#/components/schemas/analytic_parameters'
              autorestart:
                $ref: '#/components/schemas/stream_autorestart_response'
              status:
                $ref: '#/components/schemas/stream_status'
              label:
                $ref: '#/components/schemas/stream_label'
        notification_policy:
          $ref: '#/components/schemas/notification_policy_required'

    streams_to_be_deleted:
      type: object
      properties:
        stream_ids:
          description: Stream ID filter.
          type: array
          items:
            $ref: '#/components/schemas/stream_id'
          maxItems: 1000
      required: [stream_ids]

    count:
      type: integer
      minimum: 0
      example: 1

    analytic_documentation:
      type: string
      description: Binary analytic documentation encoded in base64.
      default: ""

    validation_schema:
      type: object
      description: |
        Analytic parameters json validation schema.
        
        Specified schema will be used for analytic parameters validation during stream creation request, if
        no validation schema is specified, validation will not performed. Validation schema must be presented
        as jsonschema (see <a href="https://json-schema.org/specification">json schema specification</a> for details)
      additionalProperties: true

    analytic_version:
      type: integer
      minimum: 1
      default: 1

    default_parameters:
      type: object
      description: Default parameters for the video analytic.
      additionalProperties: true

    analytic_parameters:
      allOf:
        - $ref: '#/components/schemas/default_parameters'
      description: |
        Analytic parameters for stream processing.
        
        There are default analytic parameters which will be applied for stream processing if no one specified here.
        
        To list available analytics it is possible to use [get analytics request](#tag/analytics/operation/getAnalytics).
        
        To get schema and description of acceptable parameters for this or that analytics, it is possible to get it
        using [get analytic documentation request](#tag/analytics/operation/getAnalyticDoc)
        
        Specified parameters will be validation using analytic `validation_schema` if exists. 

    analytic_to_be_patched:
      type: object
      properties:
        analytic_name:
          $ref: '#/components/schemas/analytic_name'
        description:
          allOf:
            - $ref: '#/components/schemas/string512_default'
          description: Analytic description.
          default: ""
        documentation:
          $ref: '#/components/schemas/analytic_documentation'
        validation_schema:
          $ref: '#/components/schemas/validation_schema'
        analytic_version:
          $ref: '#/components/schemas/analytic_version'
        default_parameters:
          $ref: '#/components/schemas/default_parameters'
        host:
          type: string
          description: Agent, which initiate analytics registration, origin host.

    analytic_to_be_created:
      allOf:
        - $ref: '#/components/schemas/analytic_to_be_patched'
      required: [analytic_name]

    agent_max_stream_count:
      type: integer
      minimum: 1
      description: Max streams count for agent
      example: 10

    agent_active_streams_count:
      type: integer
      minimum: 0
      description: Active streams count for agent
      example: 5

    agent_status:
      type: integer
      enum: [ 0, 1 ]
      default: 1
      description: |
        Agent status.

        | Value | Description         |
        |-------|---------------------|
        |   0   | Agent is not ready. |
        |   1   | Agent is ready.     |

        > **WARNING**: Agent status list may be expanded in the future.

    analytic_names:
      type: array
      description: Analytics list.
      items:
        $ref: '#/components/schemas/analytic_name'
      minItems: 1

    agent_port:
      type: integer
      minimum: 1
      maximum: 65535
      description: agent listening port

    agent_group:
      oneOf:
        - type: object
          properties:
            group_id:
              $ref: '#/components/schemas/group_id'
          required: [group_id]
          additionalProperties: true
        - type: object
          properties:
            group_name:
              $ref: '#/components/schemas/group_name'
          required: [group_name]
          additionalProperties: true

    agent_group_response:
      type: object
      properties:
        group_id:
          $ref: '#/components/schemas/group_id'
      required: [group_id]

    agent_groups:
      type: array
      minItems: 0
      maxItems: 50
      description: Streams groups are associated with for agent processing.
      items:
        $ref: '#/components/schemas/agent_group'

    agent_groups_response:
      type: array
      minItems: 0
      maxItems: 50
      description: Streams groups are associated with for agent processing.
      items:
        $ref: '#/components/schemas/agent_group_response'

    agent_base:
      type: object
      properties:
        name:
          $ref: '#/components/schemas/agent_name'
        description:
          allOf:
            - $ref: '#/components/schemas/string512_default'
          description: Analytic description.
          default: ""
        max_stream_count:
          $ref: '#/components/schemas/agent_max_stream_count'
        analytic_names:
          $ref: '#/components/schemas/analytic_names'
        port:
          $ref: '#/components/schemas/agent_port'
        api_version:
          type: integer
          minimum: 1
          description: agent api version
        host:
          type: string
          description: agent origin host
      required: [name, max_stream_count, analytic_names, port, api_version]

    agent_to_be_created:
      allOf:
        - $ref: '#/components/schemas/agent_base'
      type: object
      properties:
        agent_groups:
          $ref: '#/components/schemas/agent_groups'
      additionalProperties: true
      required: [name, max_stream_count, analytic_names, port, api_version]

    agent_to_get:
      allOf:
        - $ref: '#/components/schemas/agent_base'
      type: object
      properties:
        agent_id:
          $ref: '#/components/schemas/agent_id'
        status:
          $ref: '#/components/schemas/agent_status'
        active_stream_count:
          $ref: '#/components/schemas/agent_active_streams_count'
        create_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: Agent create time.
        last_update_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: Agent last update time.
        analytic_names:
          $ref: '#/components/schemas/analytic_names'
        host:
          type: string
          description: Agent host.
          nullable: false
          example: 10.0.10.10
        external:
          allOf:
            - $ref: '#/components/schemas/int01'
            - description: Whether agent is external or not
        agent_groups:
          $ref: '#/components/schemas/agent_groups_response'
      required: [agent_id, status, name, description, max_stream_count, active_stream_count, create_time, last_update_time, analytic_names, port, api_version, host, external, agent_groups]

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

    intervals_version:
      type: integer
      minimum: 0
      example: 1
      description: Stream analytics schedule intervals version.

    post_streams_processing_feedback_request:
      description: Streams info object.
      type: object
      properties:
        streams:
          description: Array of stream info.
          type: array
          minItems: 0
          items:
            description: Stream info from the processor.
            type: object
            properties:
              stream_id:
                $ref: '#/components/schemas/stream_id'
              status:
                $ref: '#/components/schemas/feedback_stream_status'
              error:
                $ref: '#/components/schemas/stream_error'
              version:
                $ref: '#/components/schemas/stream_version'
              time:
                $ref: '#/components/schemas/feedback_time'
              last_processed_frame_time:
                $ref: '#/components/schemas/last_processed_frame_time'
              analytic_indexes:
                type: array
                description: |
                  Analytics of interest indexes. Analytics index corresponds the index of analytics from
                  [create stream](#tag/streams/operation/createStream)
                  or [get stream(s)](#tag/streams/operation/getStreams) requests.
                items:
                  $ref: '#/components/schemas/analytic_index'
                minItems: 1
              analytics_intervals:
                type: array
                items:
                  type: object
                  description: Analytics working intervals.
                  properties:
                    analytic_idx:
                      $ref: '#/components/schemas/analytic_index'
                    intervals_version:
                      $ref: '#/components/schemas/intervals_version'
                  required: [analytic_idx, intervals_version]
            required: [ error, stream_id, status, version, time, last_processed_frame_time, analytic_indexes ]
      required: [streams]

    streams_feedback_response:
      description: Feedback response.
      type: object
      properties:
        streams:
          description: Array of streams info
          type: array
          minItems: 1
          items:
            type: object
            properties:
              stream_id:
                $ref: '#/components/schemas/stream_id'
              version:
                $ref: '#/components/schemas/stream_version'
              action:
                type: string
                enum: ["stop", "continue"]
                description: Action that's need to be performed with stream - stop processing or continue processing.
              new_analytics_intervals:
                $ref: '#/components/schemas/intervals_obj_with_indexes'
            required: [stream_id, version, action]
      required: [streams]

    analytics_availability:
      type: object
      description: Analytics availability.
      properties:
        available:
          type: boolean
          description: |
            Whether there is at least one agent registered in the system that is capable of working with this analytics
            at the moment (regardless of the availability of free slots for such agent(s)).
      required: [available]

    analytic_response:
      type: object
      properties:
        analytic_id:
          $ref: '#/components/schemas/analytic_id'
        analytic_name:
          $ref: '#/components/schemas/analytic_name'
        description:
          allOf:
            - $ref: '#/components/schemas/string512_default'
          description: Analytic description.
          default: ""
        analytic_version:
          $ref: '#/components/schemas/analytic_version'
        default_parameters:
          $ref: '#/components/schemas/default_parameters'
        create_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: Analytic create time.
        last_update_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: Analytic last update time.
        validation_schema:
          allOf:
            - $ref: '#/components/schemas/validation_schema'
          nullable: true
        account_id:
          $ref: '#/components/schemas/analytics_account_id'
        availability:
          $ref: '#/components/schemas/analytics_availability'
      required: [analytic_id, analytic_name, description, analytic_version, default_parameters, create_time,
                 last_update_time, validation_schema, account_id, availability]

    analytics_to_be_deleted:
      type: object
      properties:
        analytic_ids:
          description: Analytic ID filter.
          type: array
          items:
            $ref: '#/components/schemas/analytic_id'
          maxItems: 1000
      required: [analytic_ids]

    agents_to_be_deleted:
      type: object
      properties:
        agent_ids:
          description: Agent ID filter.
          type: array
          items:
            $ref: '#/components/schemas/agent_id'
          maxItems: 1000
      required: [agent_ids]

    group_stream_settings:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/group_data'
        location:
          $ref: '#/components/schemas/location_to_be_created_without_default'
        autorestart:
          $ref: '#/components/schemas/stream_autorestart_without_default'
        notification_policy:
          $ref: '#/components/schemas/notification_policy_without_default'
      description: Settings for group streams.

    create_group:
      type: object
      properties:
        group_name:
          $ref: '#/components/schemas/group_name'
        description:
          allOf:
            - $ref: '#/components/schemas/group_description'
          default: ""
        stream_settings:
          $ref: '#/components/schemas/group_stream_settings'
        analytics:
          $ref: '#/components/schemas/analytics_group_with_schedules'
      required: [ group_name ]

    create_group_response:
      type: object
      properties:
        group_id:
          $ref: '#/components/schemas/group_id'
        url:
          type: string
          format: uri-reference
      required: [ url, group_id ]

    replace_group_response:
      type: object
      properties:
        group_id:
          $ref: '#/components/schemas/group_id'
        url:
          type: string
          format: uri-reference
          description: Relative URL of the created/replaced group.
          example: /2/groups/b5d6fd45-fcca-453d-ac05-3e594054b813
        version:
          $ref: '#/components/schemas/group_version'
          example: 2
        streams:
          allOf:
          - $ref: '#/components/schemas/updated_streams_list'
          description: Streams which were updated after group replacement.
      required: [ url, group_id, version ]

    group_response:
      type: object
      properties:
        group_name:
          $ref: '#/components/schemas/group_name'
        group_id:
          $ref: '#/components/schemas/group_id'
        account_id:
          $ref: '#/components/schemas/account_id'
        description:
          $ref: '#/components/schemas/group_description'
        create_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: Group create time.
        stream_settings:
          allOf:
            - $ref: '#/components/schemas/group_stream_settings'
            - nullable: true
        analytics:
          $ref: '#/components/schemas/analytics_group_response'
        version:
          $ref: '#/components/schemas/group_version'
      required: [ account_id, group_name, group_id, description, create_time, version]

    groups_count:
      type: object
      properties:
        groups_count:
          type: integer
          description: Count of groups.
      required: [ groups_count ]
      example:
        groups_count: 7

    update_group:
      type: object
      properties:
        description:
          allOf:
            - $ref: '#/components/schemas/group_description'
      required: [ description ]
      example:
        description: "old stream group"

    linker:
      type: object
      properties:
        action:
          description: "Action to perform: attach or detach streams to group."
          type: string
          enum: [attach, detach]
        stream_ids:
          description: Stream IDs.
          type: array
          maxItems: 1000
          items:
            $ref: '#/components/schemas/uuid'
        group_id:
          $ref: '#/components/schemas/group_id'
      required: [action, stream_ids, group_id]

    log_time:
      allOf:
      - $ref: '#/components/schemas/time'
      - description: Log record time.

    last_processed_frame_time:
      type: number
      format: float
      example: "30.58"
      nullable: true
      description: Last processed frame time since stream start. Depends on `timestamp_source` parameter from the stream's data.

    streams_logs_deleted_count:
      type: object
      properties:
        deleted_count:
          type: integer
          description: Deleted logs count.
          example: 1000
      required: [ deleted_count ]

    analytic_index:
      type: integer
      minimum: 0
      description: |
        Analytics of interest index. Analytics index corresponds the index of analytics 
        from [create stream](#tag/streams/operation/createStream)
        or [get stream(s)](#tag/streams/operation/getStreams) requests.

    streams_logs:
      type: object
      properties:
        logs:
          type: array
          description: Streams logs.
          items:
            type: object
            properties:
              stream_id:
                $ref: '#/components/schemas/stream_id'
              log_time:
                $ref: '#/components/schemas/log_time'
              last_processed_frame_time:
                $ref: '#/components/schemas/last_processed_frame_time'
              error:
                $ref: '#/components/schemas/stream_error'
              status:
                $ref: '#/components/schemas/stream_status'
              analytic_index:
                allOf:
                - $ref: '#/components/schemas/analytic_index'
                - nullable: true
            minProperties: 1
          minItems: 0
      required: [logs]

    feedback_frequency:
      type: integer
      minimum: 1
      description: Required feedback frequency

    agents_streams_response:
      type: object
      properties:
        streams:
          type: array
          description: streams to process and its meta information for agent
          items:
            type: object
            properties:
              stream_id:
                $ref: '#/components/schemas/stream_id'
              data:
                $ref: '#/components/schemas/stream_data'
              location:
                $ref: '#/components/schemas/location'
              event_source_group:
                $ref: '#/components/schemas/event_source_group'
              source:
                $ref: '#/components/schemas/source_nullable'
              analytics:
                $ref: '#/components/schemas/analytics_response'
              feedback_frequency:
                $ref: '#/components/schemas/feedback_frequency'
              version:
                $ref: '#/components/schemas/stream_version'
              account_id:
                $ref: '#/components/schemas/account_id'
              notification_policy:
                $ref: '#/components/schemas/notification_policy_required'
            required: [stream_id, data, location, source, event_source_group, analytics, feedback_frequency, version, account_id, notification_policy]
          minItems: 0
      required: [streams]

    refresh_period:
      type: integer
      minimum: 1
      example: 5
      description: |
        Period for periodic agent requests to
        <a href="#tag/agents-interaction/operation/postAgentStreams">get streams for processing</a>

    alive_period:
      type: integer
      minimum: 1
      example: 30
      description: |
        Period for case when agent connection to `Luna-Video-Manager` cannot be established and streams can stay 
        in progress. If connection was not established after this period, all streams processing must be stopped by
        agent. See developer manual for more information.

    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.

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

    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. Null means no error occurred.
        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:
              - type: object
                description: Processing error.
                properties:
                  error:
                    $ref: '#/components/schemas/error_stream'
                required: [error]
              - type: object
                description: Event from websocket.
                additionalProperties: true
      required: [stream_status, error]

    restream_type:
      type: string
      default: hls
      enum: [ "hls" ]

    restream_quality_base:
      type: integer
      multipleOf: 2
      minimum: 144
      maximum: 2160
      example: 720

    restream_quality:
      allOf:
        - $ref: '#/components/schemas/restream_quality_base'
      description: >
        Target restream quality. This parameter set the height of final stream resolution, the width will
        be calculated proportionally in accordance with the original stream resolution. The original stream quality
        will be used by default.

    restream_quality_reply:
      allOf:
        - $ref: '#/components/schemas/restream_quality_base'
      description: >
        This parameter means the height of stream resolution, the width calculated proportionally in accordance with 
        the original stream resolution.

    stream_info:
      type: object
      properties:
        url:
          type: string
          description: restream url
        type:
          allOf:
            - $ref: '#/components/schemas/restream_type'
            - default: hls
        quality:
          allOf:
            - $ref: '#/components/schemas/restream_quality_reply'
            - default: 480
        token:
          type: string
          description: jwt token for stream
      required: [ url ]

    stream_info_required:
      allOf:
        - $ref: '#/components/schemas/stream_info'
      required: [ url, type, quality, token ]

    schedule_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - description: Schedule ID.
        - example: "da16792a-72c5-4bae-bfaf-30b95aca0db5"

    cron:
      type: string
      maxLength: 128
      example: 5 4 * * *
      description: |
        The cron will be used for calculation of start time points of working intervals.
        
        The cron syntax consists of five fields:
        
        | Field           | Allowed Values        |
        |-----------------|-----------------------|
        | Minute          | 0-59                  |
        | Hour            | 0-23                  |
        | Day of month    | 1-31                  |
        | Month           | 1-12                  |
        | Day of week     | 0-6 (Sunday-Saturday) |
        
        There are special characters such as `*` (any value), `-` (range), `,` (list), and `/` (step) that can be used before each field.
        
        Expression examples:            
        
        `0 0 * * *` - runs a scheduled task at midnight (00:00) every day.
        
        `*/15 * * * *` - runs a scheduled task every 15 minutes.
        
        `30 8 * * 1-5` - runs a scheduled task at 8:30 AM every weekday (Monday to Friday).
        
        `0 0 1 * *` - runs a scheduled task at midnight (00:00) on the first day of every month.
        
        `0 3 * * 1,3,5` - runs a scheduled task at 3:00 AM every Monday, Wednesday, and Friday.
        
        For more detail about cron syntax see https://en.wikipedia.org/wiki/Cron.

    cron_timezone:
      type: string
      enum: [ utc, local ]
      description: cron timezone - utc or local
      default: local

    sch_start_time:
      allOf:
        - $ref: '#/components/schemas/time'
      description: |
        Schedule start time.
        
        Minimal value is "1970-01-01T00:00:00Z", maximal value is "2070-12-12T23:59:59Z". 

    sch_end_time:
      allOf:
        - $ref: '#/components/schemas/time'
      description: |
        Schedule end time.
        
        Minimal value is "1970-01-01T00:00:00Z", maximal value is "2070-12-12T23:59:59Z". 

    duration:
      type: integer
      minimum: 1
      description: Schedule interval duration.

    duration_type:
      type: string
      enum: [minute, hour, day]
      description: Schedule interval type.

    sch_description:
      type: string
      nullable: true
      maximum: 512
      description: Schedule template description.
      default: null

    intervals_idx:
      type: integer
      description: Index of interval in schedule.
      minimum: 0

    int_start_time:
      allOf:
        - $ref: '#/components/schemas/sch_start_time'
      description: |
        Interval start time.
        
        Minimal value is "1970-01-01T00:00:00Z", maximal value is "2070-12-12T23:59:59Z". 

    int_end_time:
      allOf:
        - $ref: '#/components/schemas/sch_end_time'
      description: |
        Interval end time.
        
        Minimal value is "1970-01-01T00:00:00Z", maximal value is "2070-12-12T23:59:59Z". 

    interval:
      type: object
      properties:
        start_time:
          $ref: '#/components/schemas/int_start_time'
        end_time:
          $ref: '#/components/schemas/int_end_time'
      required: [start_time, end_time]

    intervals:
      type: array
      description: Schedule intervals.
      items:
        $ref: '#/components/schemas/interval'

    intervals_response:
      type: object
      properties:
        intervals:
          $ref: '#/components/schemas/intervals'
      required: [intervals]

    sch_template_to_create:
      type: object
      properties:
        start_time:
          $ref: '#/components/schemas/sch_start_time'
        end_time:
          $ref: '#/components/schemas/sch_end_time'
        duration:
          $ref: '#/components/schemas/duration'
        duration_type:
          $ref: '#/components/schemas/duration_type'
        cron:
          $ref: '#/components/schemas/cron'
        cron_timezone:
          $ref: '#/components/schemas/cron_timezone'
        description:
          $ref: '#/components/schemas/sch_description'
      required: [start_time, end_time, cron, duration, duration_type]

    sch_creation_response:
      type: object
      properties:
        schedule_id:
          $ref: '#/components/schemas/schedule_id'
        intervals:
          $ref: '#/components/schemas/intervals'
      required: [schedule_id, intervals]

    sch_template_response_base_without_id:
      type: object
      properties:
        start_time:
          $ref: '#/components/schemas/sch_start_time'
        end_time:
          $ref: '#/components/schemas/sch_end_time'
        description:
          $ref: '#/components/schemas/sch_description'
        intervals:
          $ref: '#/components/schemas/intervals'
      required: [start_time, end_time, description, intervals]

    sch_template_response_base:
      allOf:
        - $ref: '#/components/schemas/sch_template_response_base_without_id'
        - properties:
            schedule_id:
              allOf:
                - $ref: '#/components/schemas/schedule_id'
              description: Id of schedule that became the original for the this one.
          required: [start_time, end_time, description, schedule_id, intervals]

    sch_template_response:
      allOf:
        - $ref: '#/components/schemas/sch_template_response_base'
        - properties:
            create_time:
              allOf:
                - $ref: '#/components/schemas/time'
              description: Schedule template creation time.
            account_id:
              $ref: '#/components/schemas/account_id'
            cron:
              $ref: '#/components/schemas/cron'
            cron_timezone:
              $ref: '#/components/schemas/cron_timezone'
            duration:
              $ref: '#/components/schemas/duration'
            duration_type:
              $ref: '#/components/schemas/duration_type'
          required: [start_time, end_time, cron, cron_timezone, description, duration, duration_type, intervals, account_id, create_time]

    sch_template_response_array:
      type: object
      properties:
        schedules:
          type: array
          items:
            $ref: '#/components/schemas/sch_template_response'
      required: [schedules]

    helpers_request:
      type: object
      properties:
        start_time:
          $ref: '#/components/schemas/sch_start_time'
        end_time:
          $ref: '#/components/schemas/sch_end_time'
        cron:
          $ref: '#/components/schemas/cron'
        cron_timezone:
          $ref: '#/components/schemas/cron_timezone'
        duration:
          $ref: '#/components/schemas/duration'
        duration_type:
          $ref: '#/components/schemas/duration_type'
      required: [start_time, end_time, cron, cron_timezone, duration, duration_type]

    intervals_nested_response:
      type: object
      properties:
        intervals:
          description: List with merged intervals or lists of lists with intervals.
          oneOf:
            - type: array
              description: List of lists with working intervals.
              items:
                type: object
                properties:
                  intervals_idx:
                    type: integer
                    minimum: 0
                    description: Intervals batch index.
                  intervals:
                    $ref: '#/components/schemas/intervals'
                required: [intervals_idx, intervals]
            - allOf:
                - $ref: '#/components/schemas/intervals'
              description: List of merged working intervals.
      required: [ intervals ]


    create_stream_response:
      type: object
      properties:
        stream_id:
          allOf:
            - $ref: '#/components/schemas/stream_id'
          description: |
            ID of the created stream.
            The ID can be used as the `stream_id` parameter in [GET](#operation/getStream) `/streams/{stream_id}`.
        url:
          type: string
          format: uri-reference
      required: [ url, stream_id ]

    create_analytic_response:
      type: object
      properties:
        analytic_id:
          allOf:
            - $ref: '#/components/schemas/analytic_id'
          description: |
            ID of the created analytic.
            The ID can be used as the `analytic_id` parameter in [GET](#operation/getAnalytic) `/analytics/{analytic_id}`.
        url:
          type: string
          format: uri-reference
      required: [ url, analytic_id ]

    create_agent_response:
      type: object
      properties:
        agent_id:
          allOf:
            - $ref: '#/components/schemas/agent_id'
          description: |
            ID of the created agent.
            The ID can be used as the `agent_id` parameter in [GET](#operation/getAgent) `/agents/{agent_id}`.
        refresh_period:
          $ref: '#/components/schemas/refresh_period'
        alive_period:
          $ref: '#/components/schemas/alive_period'
        url:
          type: string
          format: uri-reference
      required: [ agent_id, refresh_period, alive_period, url ]

    updated_streams_list:
      type: array
      description: Streams which were updated after link/unlink.
      items:
        type: object
        properties:
          stream_id:
            $ref: '#/components/schemas/stream_id'
          consequence:
            type: string
            enum: [ update, restart ]
            nullable: false
            description: Whether stream was updated or restarted after link/unlink to/from group.
        required: [ stream_id, consequence ]
      minItems: 0

    updated_streams:
      type: object
      properties:
        streams:
          $ref: '#/components/schemas/updated_streams_list'
      required: [streams]
  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'

    license_problem:
      description: License problem.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error'
          examples:
            no_license_info:
              value:
                error_code: 11055
                desc: Forbidden
                detail: "License problem: Cannot get license information"
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11055
            license_expired:
              value:
                error_code: 11055
                desc: Forbidden
                detail: "License problem: License expired"
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11055
            streams_feature_is_disabled:
              value:
                error_code: 11055
                desc: Forbidden
                detail: "Analytics streams license feature is disabled."
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11055
            streams_limit_feature_is_disabled:
              value:
                error_code: 11055
                desc: Forbidden
                detail: "Analytics streams license limit feature is disabled."
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11055
            license_limit_exceeded:
              value:
                error_code: 11055
                desc: Forbidden
                detail: "Streams license limit exceeded. Please contact VisionLabs for license upgrade or delete redundant streams"
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11055
paths:
  /version:
    get:
      tags:
      - version

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

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/json_or_msgpack'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/version'
            application/msgpack:
              schema:
                $ref: '#/components/schemas/version'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/docs/spec:
    get:
      tags:
        - documents
      summary: get openapi documentation
      description: |
        Get service OpenApi documentation. If *Accept* request header is of type `application/x-yaml`,
        returns documentation in `yaml` format or returns `html` documentation, if *Accept-Type* is `text/html`
      operationId: getSpec

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/accept_docs_handler'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/docs_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/x-yaml:
              schema:
                type: string
                description: yaml format documentation
            text/html:
              schema:
                type: string
                description: html format documentation
        415:
          description: Unsupported Media Type
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                unsupported_media_type:
                  value:
                    error_code: 12024
                    detail: 'Bad/incomplete input data'
                    desc: "Unsupported media type"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024"
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/docs/dev:
    parameters:
      - $ref: '#/components/parameters/Accept'
    get:
      tags:
        - documents
      summary: get development manual
      description: |
        Get sphinx documentation - *Development Manual*. After the request you will be redirected to the page `/docs/dev/index.html`
      operationId: getDevManual

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

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/accept_config_handler'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/config_accept_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                description: json format configuration
              example:
                INFLUX_MONITORING:
                  SEND_DATA_FOR_MONITORING: 0
                  VERSION: 2
                  ORGANIZATION: ORGANIZATION_NAME
                  TOKEN: '********'
                  BUCKET: luna_monitoring
                  HOST: 127.0.0.1
                  PORT: 8086
                  USE_SSL: 0
                  FLUSHING_PERIOD: 1.0
            text/plain:
              schema:
                type: string
                description: text format configuration
              example: |
                [INFLUX_MONITORING]
                SEND_DATA_FOR_MONITORING = 0
                VERSION = 2
                ORGANIZATION = ORGANIZATION_NAME
                TOKEN = ********
                BUCKET = luna_monitoring
                HOST = 127.0.0.1
                PORT = 8086
                USE_SSL = 0
                FLUSHING_PERIOD = 1.0
        415:
          description: Unsupported Media Type
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                unsupported_media_type:
                  value:
                    error_code: 12024
                    detail: '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/streams:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'

    post:
      tags:
        - streams
      summary: create stream
      description: |
        Create stream.
        
        See `Group settings` chapter in service developers documentation for stream and groups settings and analytics
        sharing features.
      operationId: createStream
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
        - $ref: '#/components/parameters/check_agent'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/stream_to_be_created'
        required: true
      responses:
        201:
          description: Create success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /2/streams/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of new stream
              required: true

          content:
            application/json:
              schema:
                $ref: '#/components/schemas/create_stream_response'
              example:
                stream_id: b5d6fd45-fcca-453d-ac05-3e594054b813
                url: /2/streams/b5d6fd45-fcca-453d-ac05-3e594054b813
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'check_agent'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        403:
          $ref: '#/components/responses/license_problem'
        422:
          description: Unprocessable content.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                no_suitable_agent:
                  value:
                    error_code: 44014
                    desc: Unprocessable content
                    detail: |
                      Failed to find agent that supports all analytics associated with the stream
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44014
                analytics_not_found:
                  value:
                    error_code: 44014
                    desc: Unprocessable content
                    detail: Analytic 'non-exists' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44014
                fail_to_merge_settings_from_group_by_name:
                  value:
                    error_code: 44022
                    desc: Unprocessable content
                    detail: |
                      Failed to merge settings for stream with id '6e5611a8-ac85-4b84-bbf2-0d8364615922' during merging
                      settings from group with name 'group_test': 'Failed to validate input json. Path: 'analytics', 
                      message: 'List should have at least 1 item after validation, not 0''
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44022
                fail_to_merge_settings_from_group_by_id:
                  value:
                    error_code: 44023
                    desc: Unprocessable content
                    detail: |
                      Failed to merge settings for stream with id '6e5611a8-ac85-4b84-bbf2-0d8364615922' during merging
                      settings from group with id '6e5611a8-ac85-4b84-bbf2-0d8364615922': 'Failed to validate input json. Path: 'analytics', 
                      message: 'List should have at least 1 item after validation, not 0''
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44023
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
        - streams
      summary: get streams
      description: Get streams according to filters. The results are sorted by stream creation order, the oldest streams shown first.
      operationId: getStreams
      parameters:
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/stream_ids'
        - $ref: '#/components/parameters/stream_id__gte'
        - $ref: '#/components/parameters/stream_id__lt'
        - $ref: '#/components/parameters/stream_names'
        - $ref: '#/components/parameters/stream_reference'
        - $ref: '#/components/parameters/stream_statuses'
        - $ref: '#/components/parameters/create_time__gte'
        - $ref: '#/components/parameters/create_time__lt'
        - $ref: '#/components/parameters/agent_id_query'
        - $ref: '#/components/parameters/group_name'
        - $ref: '#/components/parameters/group_id'
        - $ref: '#/components/parameters/sources'
        - $ref: '#/components/parameters/event_source_groups'
        - $ref: '#/components/parameters/splittable'
        - $ref: '#/components/parameters/order'
        - $ref: '#/components/parameters/order_column'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/page_size'
        - $ref: '#/components/parameters/stream_targets'
        - $ref: '#/components/parameters/enriched'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  streams:
                    type: array
                    items:
                      $ref: '#/components/schemas/stream_response'
                    minItems: 0
                required: [ streams ]
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'stream_ids'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - streams
      summary: delete streams
      description: Delete streams matching specified filters.
      operationId: deleteStreams
      parameters:
        - $ref: '#/components/parameters/account_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/streams_to_be_deleted'
        required: true
      responses:
        204:
          description: Delete success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/streams/count:
    get:
      tags:
        - streams
      summary: count streams
      description: |
        Count streams according to the filters.

      operationId: countStreams
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/stream_ids'
        - $ref: '#/components/parameters/stream_id__gte'
        - $ref: '#/components/parameters/stream_id__lt'
        - $ref: '#/components/parameters/stream_names'
        - $ref: '#/components/parameters/stream_reference'
        - $ref: '#/components/parameters/stream_statuses'
        - $ref: '#/components/parameters/create_time__gte'
        - $ref: '#/components/parameters/create_time__lt'
        - $ref: '#/components/parameters/agent_id_query'
        - $ref: '#/components/parameters/group_name'
        - $ref: '#/components/parameters/group_id'
        - $ref: '#/components/parameters/sources'
        - $ref: '#/components/parameters/splittable'
        - $ref: '#/components/parameters/agent_id_query'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  streams_count:
                    allOf:
                      - $ref: '#/components/schemas/count'
                    description: Streams count.
                description: Stream count.
                required: [ streams_count ]
        400:
          description: Bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'stream_ids'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/streams/{stream_id}:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/path_stream_id'

    get:
      tags:
      - streams
      summary: get stream
      description: Get the stream by ID.
      operationId: getStream
      parameters:
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/stream_targets'
        - $ref: '#/components/parameters/enriched'
      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/stream_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 44021
                    desc: Bad input data
                    detail: >-
                      'notification_policys' is not valid target to get streams. Valid target should be one of
                      ['stream_id', 'account_id', 'name', 'description', 'data', 'location', 'source', 'version',
                      'create_time', 'last_error', 'groups', 'status', 'splittable', 'analytics', 'notification_policy']
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44021
        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'

    head:
      tags:
        - streams
      summary: head stream
      operationId: checkStream
      description:  Check if stream exists.
      parameters:
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/stream_targets'
      responses:
        200:
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          description: No content
        404:
          description: Stream not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        500:
          $ref: '#/components/responses/internal_server_error'

    put:
      tags:
        - streams
      summary: put stream
      description: |
        Update existing stream. You should specify all the fields required for the stream in the request.

        See `Group settings` chapter in service developers documentation for stream and groups settings and analytics
        sharing features.
      operationId: putStream
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
        - $ref: '#/components/parameters/check_agent'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/stream_to_be_created'
        required: true
      responses:
        200:
          description: Put success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  stream_id:
                    allOf:
                      - $ref: '#/components/schemas/stream_id'
                    description: |
                      ID of the stream that was put.
                      The ID can be used as the `stream_id` parameter in [GET](#operation/getStream) `/streams/{stream_id}`.
                  version:
                    $ref: '#/components/schemas/stream_version'
                required: [ stream_id, version ]
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'check_agent'
                    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
        422:
          description: Unprocessable content.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                no_suitable_agent:
                  value:
                    error_code: 44014
                    desc: Unprocessable content
                    detail: |
                      Failed to find agent that supports all analytics associated with the stream
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44014
                analytics_not_found:
                  value:
                    error_code: 44014
                    desc: Unprocessable content
                    detail: Analytic 'non-exists' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44014
                fail_to_merge_settings_from_group_by_name:
                  value:
                    error_code: 44022
                    desc: Unprocessable content
                    detail: |
                      Failed to merge settings for stream with id '6e5611a8-ac85-4b84-bbf2-0d8364615922' during merging
                      settings from group with name 'group_test': 'Failed to validate input json. Path: 'analytics', 
                      message: 'List should have at least 1 item after validation, not 0''
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44022
                fail_to_merge_settings_from_group_by_id:
                  value:
                    error_code: 44023
                    desc: Unprocessable content
                    detail: |
                      Failed to merge settings for stream with id '6e5611a8-ac85-4b84-bbf2-0d8364615922' during merging
                      settings from group with 'name' 'group_name': 'Failed to validate input json. Path: 'analytics', 
                      message: 'List should have at least 1 item after validation, not 0''
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44023
        500:
          $ref: '#/components/responses/internal_server_error'

    patch:
      tags:
        - streams
      summary: patch stream
      description: |
        Stop/resume stream processing.

        Due to peculiarities of patching implementation it is possible that stream patching can not be performed immediately and 0 patched count will be returned. In this case, repeat the request after a short time.
      operationId: patchStream
      parameters:
        - $ref: "#/components/parameters/patch_stream_action"
      responses:
        200:
          description: Patched success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  patched_count:
                    allOf:
                      - $ref: '#/components/schemas/count'
                    description: Patched streams count.
                description: Patched streams count.
                required: [ patched_count ]
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'action'
                    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'

    delete:
      tags:
        - streams
      summary: remove stream
      description: Remove the stream by ID.
      operationId: removeStream
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        204:
          description: Delete success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        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'
  /2/streams/{stream_id}/restream:
    parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/path_stream_id'

    get:
      parameters:
        - $ref: '#/components/parameters/restream_quality'
      tags:
        - streams
      summary: get stream retransmission
      description: Get stream retransmission (HLS).
      operationId: retransmission
      responses:
        '200':
          description: Retransmission.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/stream_info_required'
        '400':
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''Additional properties are not allowed (''userdata'' was unexpected)'''
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022"
        '403':
          description: Forbidden, luna-streams-retranslator support is disabled on server.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 11078
                desc: Forbidden
                detail: Luna Streams Service service is disabled
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11078"
        '404':
          description: Object not Found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 45002
                    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-45002"
        '422':
          description: Unprocessable Content.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 46002
                    desc: 'Unprocessable Content'
                    detail: 'The `videofile` retranslation is not supported at the moment'
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-46002"
        '500':
          $ref: '#/components/responses/internal_server_error'
  /2/streams/{stream_id}/ws:
    parameters:
      - $ref: '#/components/parameters/path_stream_id'

    get:
      tags:
      - streams
      summary: stream events ws handshake
      description: |
        Stream ws events handshake. The resource is designed to receive realtime events from one 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).

        **WARNING**: If analytics processing not carried out according to schedule, response of request will be
        the as in the case when stream analytics does not exists.
      operationId: wsHandshake
      parameters:
      - $ref: '#/components/parameters/luna_account_id_header_required'
      - $ref: '#/components/parameters/analytic_index'

      responses:
        101:
          description: Success handshake.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/message_from_ws'
              examples:
                in_progress_no_error:
                  value:
                    stream_status: "in_progress"
                    error: null
                    analytics_results:
                      crowd:
                        track_id: "557d54ec-29ad-4f3c-93b4-c9092ef12515"
                        event_id: "557d54ec-29ad-4f3c-93b4-c9092ef12515"
                        people_count: 2
                        time_offset: 1.234
                        event_status: "started"
                        people_coordinates: [[64,128],[491,375]]
                in_progress_analytics_error:
                  value:
                    stream_status: "in_progress"
                    error: null
                    analytics_results:
                      crowd:
                        error: "error decoding frame number 12345"
                stream_error:
                  value:
                    stream_status: "error"
                    error: "fatal error during stream processing: connection refused"
                processing_finished:
                  value:
                    stream_status: "finished"
                    error: null
        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
        422:
          description: Stream is not in progress.
          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:
                stream_is_not_in_progress:
                  value:
                    error_code: 44013
                    desc: Stream status is unsuitable
                    detail: Stream with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' is not currently being processed
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44013
        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:5230/1/streams/70c75b04-1ec8-4aa1-930c-ddad9e47b54b/ws"  # Note filtering by gender!
                async with websockets.connect(uri, extra_headers={"Luna-Account-Id": "70c75b04-1ec8-4aa1-930c-ddad9e47b54b") as websocket:
                    while True:
                        data = await websocket.recv()
                        print(data)


            asyncio.run(main())

        - lang: bash
          label: using curl
          source: |
            curl -i -N \
              -H "Connection: Upgrade" \
              -H "Upgrade: websocket" \
              -H "Sec-WebSocket-Version: 13" \
              -H "Sec-WebSocket-Key: YWFhYWFhYWFhYWFhYWFhYQ==" \
              -H "Luna-Account-Id: 8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a" \
              "http://127.0.0.1:5230/1/streams/70c75b04-1ec8-4aa1-930c-ddad9e47b54b/ws"
  /2/streams/{stream_id}/{analytic_idx}/intervals:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/path_stream_id'
      - $ref: '#/components/parameters/path_analytic_index'

    get:
      tags:
      - streams schedules
      summary: get all stream analytics working intervals
      description: Get stream working intervals by stream ID and analytics index.
      operationId: getAnalyticsIntervals
      parameters:
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/merged'
      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/intervals_nested_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Stream or schedule not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                stream_not_found:
                  value:
                    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
                stream_analytics_not_found:
                  value:
                    error_code: 440021
                    desc: Object not found
                    detail: The analytics with index '123' for stream with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-440021
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/streams/{stream_id}/{analytic_idx}/intervals/{intervals_idx}:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/path_stream_id'
      - $ref: '#/components/parameters/path_analytic_index'
      - $ref: '#/components/parameters/intervals_idx'

    put:
      tags:
        - streams schedules
      summary: replace or create stream analytics working intervals
      description: |
        Replace or create stream analytics schedule. After this operation, final stream analytics working
        intervals will be recalculated.
        
        Analytics working intervals can be specified in two ways or their combinations:

        - using [previously created *schedule*](#tag/schedule-template/operation/createScheduleTemplate) by specifying it's id
        - specifying intervals (can be calculated using [intervals calculation request](#tag/schedule-template/operation/calcIntervals))

        If more than one working intervals lists specified, it will be merged into one final intervals group, to
        see non merged and merged final working intervals, us [get stream analytics working intervals request](#tag/streams-schedules/operation/getStreamSchedules)
        with specifying *merged* query parameter.
      operationId: putAnalyticsIntervals
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/schedule_to_replace'
        required: true
      responses:
        204:
          description: Success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        404:
          description: Stream or analytics not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                stream_not_found:
                  value:
                    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
                stream_analytics_not_found:
                  value:
                    error_code: 440021
                    desc: Object not found
                    detail: The analytics with index '123' for stream with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-440021
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
      - streams schedules
      summary: get stream analytics working intervals
      description: Get stream analytics intervals by stream ID, analytics index and intervals index.
      operationId: getAnalyticsIntervalsIntervals
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/intervals_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Stream or schedule not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                stream_not_found:
                  value:
                    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
                stream_analytics_not_found:
                  value:
                    error_code: 440021
                    desc: Object not found
                    detail: The analytics with index '123' for stream with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-440021
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - streams schedules
      summary: delete stream analytics working intervals
      description: |
        Delete stream analytics schedule. After this operation, final stream analytics working
        intervals will be recalculated. If last stream analytics schedule
        removed, stream analytics processing will become permanent.
      operationId: deleteAnalyticsIntervals
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
      responses:
        204:
          description: Success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        404:
          description: Stream or schedule not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                stream_not_found:
                  value:
                    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
                stream_analytics_not_found:
                  value:
                    error_code: 440021
                    desc: Object not found
                    detail: The analytics with index '123' for stream with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-440021
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/templates/schedules:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'

    post:
      tags:
        - schedule template
      summary: create schedule template
      description: |
        Create schedule template.
        
        It will calculate working intervals based on specified parameters for future usage in analytics working according
        to these intervals. 
        
        Calculated intervals are available in response of this request and in response of
        ["get schedule templates"](#operation/getScheduleTemplates)/["get schedule template"](#operation/getScheduleTemplate)
      operationId: createScheduleTemplate
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/sch_template_to_create'
        required: true
      responses:
        201:
          description: Create success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/sch_creation_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
        - schedule template
      summary: get schedule templates
      description: |
        Get schedule templates according to filters. 
        The results are sorted by templates creation order, the oldest streams shown first.
      operationId: getScheduleTemplates
      parameters:
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/schedule_ids'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/page_size'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/sch_template_response_array'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'schedule_ids'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/templates/schedules/{schedule_id}:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/schedule_id'

    put:
      tags:
        - schedule template
      summary: replace schedule template
      description: |
        (Re)Create schedule template.
        
        It will calculate working intervals based on specified parameters for future usage in analytics working according
        to these intervals. 
        
        Calculated intervals are available in response of this request and in response of
        ["get schedule templates"](#operation/getScheduleTemplates)/["get schedule template"](#operation/getScheduleTemplate)
        requests
      operationId: replaceSchedule
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/sch_template_to_create'
        required: true
      responses:
        201:
          description: Create success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/sch_creation_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
        - schedule template
      summary: get schedule template
      description: Get schedule template by ID.
      operationId: getScheduleTemplate
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/sch_template_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Schedule template not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 440017
                    desc: Object not found
                    detail: Schedule template with id 'db73d824-4de5-4096-aa4f-fa589764ae40' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-440017
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - schedule template
      summary: delete schedule template
      description: Delete schedule template by ID.
      operationId: deleteScheduleTemplate
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        204:
          description: Delete success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Schedule template not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 440017
                    desc: Object not found
                    detail: Schedule template with id 'db73d824-4de5-4096-aa4f-fa589764ae40' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-440017
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/templates/schedules/{schedule_id}/intervals:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/schedule_id'

    get:
      tags:
        - schedule template
      summary: get schedule template intervals
      description: Get schedule template generated working intervals by schedule ID.
      operationId: getScheduleTemplateIntervals
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/intervals_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Schedule template not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 440017
                    desc: Object not found
                    detail: Schedule template with id 'db73d824-4de5-4096-aa4f-fa589764ae40' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-440017
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/intervals/calculate:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'

    post:
      tags:
        - schedule template
      summary: calculate intervals
      description: |
        Calculate intervals which can be used for schedules.
        
        This request can be used for schedule template parameters check, it will calculate working intervals in the
        same way as ["create schedule template"](#operation/createScheduleTemplate)/
        ["(re)create schedule template"](#operation/replaceSchedule) requests, but no data will be saved for future
        usage.
      operationId: calcIntervals
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/helpers_request'
        required: true
      responses:
        200:
          description: Intervals successfully calculated.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/intervals_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/streams/logs:
    get:
      tags:
        - streams logs
      summary: get streams logs
      description: Get streams logs according to filters. The results are sorted by log creation order, 
        the new streams logs shown first.
      operationId: getStreamsLogs
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/stream_ids'
        - $ref: '#/components/parameters/stream_statuses'
        - $ref: '#/components/parameters/log_targets'
        - $ref: '#/components/parameters/log_time__lt'
        - $ref: '#/components/parameters/log_time__gte'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/page_size'
        - $ref: '#/components/parameters/analytic_indexes'
      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/streams_logs'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'log_time__lt'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - streams logs
      summary: delete stream logs
      description: |
        Delete streams logs older than specified date excluding last log entry.
        
        Also you can run streams logs auto deletion by using `LUNA_STREAMS_LOGS_CLEAR_INTERVAL` setting.
        For more information see development documentation.
      operationId: deleteStreamsLogs
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/log_time__lt_deleting'
      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/streams_logs_deleted_count'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'log_time__lt'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/linker:
    patch:
      tags:
        - streams group linker
      summary: attach (or detach) streams to a group
      description: |
        Attach (or detach) streams to a group.
        
        See `Group settings` chapter in service developers documentation for stream and groups settings and analytics
        sharing features.
      operationId: streamsGroupLinker
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/streams_update'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/linker'
      responses:
        200:
          description: Operation succeeded. Streams were updated.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/updated_streams'
        204:
          description: Operation succeeded.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
                stream_not_found:
                  value:
                    error_code: 44001
                    desc: Object not found
                    detail: Stream with id 8406e8fd-4a02-4a72-81e1-6dfd2441fd2b not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44001
                group_not_found:
                  value:
                    error_code: 44004
                    desc: Object not found
                    detail: Group with id afb2639c-9fcb-43fe-b48c-95e2fd1335b9 not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44004
        422:
          description: Unprocessable content.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                fail_to_merge_settings_from_group_by_name:
                  value:
                    error_code: 44022
                    desc: Unprocessable content
                    detail: |
                      Failed to merge settings for stream with id '6e5611a8-ac85-4b84-bbf2-0d8364615922' during merging
                      settings from group with name 'group_test': 'Failed to validate input json. Path: 'analytics', 
                      message: 'List should have at least 1 item after validation, not 0''
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44022
                fail_to_merge_settings_from_group_by_id:
                  value:
                    error_code: 44023
                    desc: Unprocessable content
                    detail: |
                      Failed to merge settings for stream with id '6e5611a8-ac85-4b84-bbf2-0d8364615922' during merging
                      settings from group with id '6e5611a8-ac85-4b84-bbf2-0d8364615922': 'Failed to validate input json. Path: 'analytics', 
                      message: 'List should have at least 1 item after validation, not 0''
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44023
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/groups:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'

    post:
      tags:
        - groups
      summary: create group
      description: Create group.
      operationId: createGroup
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create_group'
        required: true
      responses:
        201:
          description: Create success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /2/groups/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: Location of new group.
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/create_group_response'
              example:
                group_id: b5d6fd45-fcca-453d-ac05-3e594054b813
                url: /2/groups/b5d6fd45-fcca-453d-ac05-3e594054b813
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        409:
          description: Conflict
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 44003
                desc: Unique constraint error
                detail: Group named 'group1' already exists
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44003
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
        - groups
      summary: get groups
      description: Get groups according to filters. The results are sorted by group creation order, the oldest group shown first.
      operationId: getGroups
      parameters:
        - $ref: '#/components/parameters/group_ids'
        - $ref: '#/components/parameters/group_names'
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/page_size'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  groups:
                    type: array
                    items:
                      $ref: '#/components/schemas/group_response'
                    minItems: 0
                required: [ groups ]
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/groups/count:
    get:
      tags:
        - groups
      summary: get group count
      description: |
        Count of groups according to the filters.
      operationId: countGroups
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/group_ids'
        - $ref: '#/components/parameters/group_names'
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/groups_count'
        400:
          description: Bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/groups/{group_id}:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - in: path
        name: group_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: ID of the group (`group_id` received in the ["create group"](#operation/createGroup) request).

    get:
      tags:
        - groups
      summary: get group
      description: Get the group by name.
      operationId: getGroup
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/group_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Group 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: 39008
                desc: Object not found
                detail: Group with id ee4c42b6-23ae-410e-a2aa-a4220e64ba4b not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-39008
        500:
          $ref: '#/components/responses/internal_server_error'

    patch:
      tags:
        - groups
      summary: update group
      description: |
        Update group fields: *description*
      parameters:
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/applicationJsonContent'
      operationId: patchGroup
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/update_group'
        required: true
      responses:
        204:
          description: Update success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Group 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: 44004
                desc: Object not found
                detail: Group with id ee4c42b6-23ae-410e-a2aa-a4220e64ba4b not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44004
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - groups
      summary: remove group
      description: Remove the group by ID.
      operationId: deleteGroup
      parameters:
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/with_streams'
      responses:
        204:
          description: Delete success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Group 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: 44004
                desc: Object not found
                detail: Group with id ee4c42b6-23ae-410e-a2aa-a4220e64ba4b not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44004
        500:
          $ref: '#/components/responses/internal_server_error'

    put:
      tags:
        - groups
      summary: put group
      description: |
        Update existing or create new group.

      operationId: putGroup
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
        - $ref: '#/components/parameters/streams_update'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create_group'
        required: true
      responses:
        200:
          description: Put success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /2/groups/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: Location of new group.
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/replace_group_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        409:
          description: Conflict
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              example:
                error_code: 44003
                desc: Unique constraint error
                detail: Group named 'group1' already exists
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44003
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/groups/{group_id}/streams:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'
      - in: path
        name: group_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: ID of the group (`group_id` received in the ["create group"](#operation/createGroup) request).

    patch:
      tags:
        - groups
      summary: patch streams in group
      description: |
        Pause/unpause all streams in a group.

        The operation will be applied to all streams that can be switched to a different state, if at least one stream can be modified. 

        If no streams can be changed, an `Unable to patch streams` error will be returned.
      operationId: patchGroupStreams
      parameters:
        - $ref: "#/components/parameters/patch_stream_action"
      responses:
        200:
          description: Patched success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  patched_count:
                    allOf:
                      - $ref: '#/components/schemas/count'
                    description: Patched streams count.
                description: Patched streams count.
                required: [ patched_count ]
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'action'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Group 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: 39008
                desc: Object not found
                detail: Group with id ee4c42b6-23ae-410e-a2aa-a4220e64ba4b not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-39008
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - groups
      summary: remove all streams in the group
      description: Remove all streams in the group without removing the group itself.
      operationId: removeGroupStreams
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        204:
          description: Delete success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        404:
          description: Group 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: 39008
                desc: Object not found
                detail: Group with id ee4c42b6-23ae-410e-a2aa-a4220e64ba4b not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-39008
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/analytics:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'

    post:
      tags:
        - analytics
      summary: create analytic
      description: Create analytic.
      operationId: createAnalytic
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/analytic_to_be_created'
        required: true
      responses:
        201:
          description: Create success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /2/analytics/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of new analytic
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/create_analytic_response'
              example:
                analytic_id: b5d6fd45-fcca-453d-ac05-3e594054b813
                url: /2/analytics/b5d6fd45-fcca-453d-ac05-3e594054b813
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
        - analytics
      summary: get analytics
      description: Get analytics according to filters. The results are sorted by analytic creation order, the oldest analytics shown first.
      operationId: getAnalytics
      parameters:
        - $ref: '#/components/parameters/analytic_ids'
        - $ref: '#/components/parameters/analytic_id__gte'
        - $ref: '#/components/parameters/analytic_id__lt'
        - $ref: '#/components/parameters/create_time__lt'
        - $ref: '#/components/parameters/create_time__gte'
        - $ref: '#/components/parameters/analytic_names'
        - $ref: '#/components/parameters/order'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/page_size'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  analytics:
                    type: array
                    items:
                      $ref: '#/components/schemas/analytic_response'
                    minItems: 0
                required: [ analytics ]
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'analytic_ids'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - analytics
      summary: delete analytics
      description: Delete analytics matching specified filters.
      operationId: deleteAnalytics
      parameters:
        - $ref: '#/components/parameters/account_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/analytics_to_be_deleted'
        required: true
      responses:
        204:
          description: Delete success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                      Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/analytics/{analytic_id}:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - in: path
        name: analytic_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: ID of the analytic (`analytic_id` received in the ["create analytic"](#operation/createAnalytic) request).

    get:
      tags:
      - analytics
      summary: get analytic
      description: Get the analytic by ID.
      operationId: getAnalytic
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/analytic_response'
        404:
          description: Analytic 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: 44008
                desc: Object not found
                detail: Analytic with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44008
        500:
          $ref: '#/components/responses/internal_server_error'

    head:
      tags:
        - analytics
      summary: head analytic
      operationId: checkAnalytic
      description:  Check if analytic exists.
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        204:
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          description: No content
        404:
          description: Analytic not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        500:
          $ref: '#/components/responses/internal_server_error'

    put:
      tags:
        - analytics
      summary: put analytic
      description: Update existing analytic. You should specify all the fields required for the stream in the request.
      operationId: putAnalytic
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/analytic_to_be_created'
        required: true
      responses:
        204:
          description: Put success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        404:
          description: Analytic 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: 44008
                desc: Object not found
                detail: Analytic with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44008
        409:
          description: Analytic version is too low.
          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: 44016
                desc: Unable to update analytic
                detail: "'people_count' analytic version is too low"
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44016
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - analytics
      summary: remove analytic
      description: Remove the analytic by ID.
      operationId: removeAnalytic
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        204:
          description: Delete success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        404:
          description: Analytic 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: 44008
                desc: Object not found
                detail: Analytic with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44008
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/analytics/{analytic_id}/docs:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - in: path
        name: analytic_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: ID of the analytic (`analytic_id` received in the ["create analytic"](#operation/createAnalytic) request).

    get:
      tags:
      - analytics
      summary: get analytic documentation
      description: Get the analytic documentation by ID.
      operationId: getAnalyticDoc
      parameters:
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/accept_html'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              oneOf:
                - $ref: '#/components/headers/application_json'
                - $ref: '#/components/headers/text_html'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: string
                description: raw analytic documentation.
            application/x-yaml:
              schema:
                type: object
                description: analytics documentation
            text/html:
              schema:
                type: string
                description: HTML format analytic documentation.
        404:
          description: Analytic 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: 44008
                desc: Object not found
                detail: Analytic with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44008
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/agents:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'

    post:
      tags:
        - agents
      summary: register agent
      description: register agent.
      operationId: registerAgent
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/luna_account_id_header_required'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/agent_to_be_created'
        required: true
      responses:
        201:
          description: Create success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /2/agents/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of new agent
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/create_agent_response'
              example:
                agent_id: b5d6fd45-fcca-453d-ac05-3e594054b813
                refresh_period: 5
                alive_period: 30
                url: /2/agents/b5d6fd45-fcca-453d-ac05-3e594054b813
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
        - agents
      summary: get agents
      description: Get agents according to filters. The results are sorted by agent creation order, the oldest agents shown first.
      operationId: getAgents
      parameters:
        - $ref: '#/components/parameters/agent_ids'
        - $ref: '#/components/parameters/agent_id__gte'
        - $ref: '#/components/parameters/agent_id__lt'
        - $ref: '#/components/parameters/agent_names'
        - $ref: '#/components/parameters/create_time__lt'
        - $ref: '#/components/parameters/create_time__gte'
        - $ref: '#/components/parameters/order'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/page_size'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  agents:
                    type: array
                    description: agent list
                    items:
                      $ref: '#/components/schemas/agent_to_get'
                    minItems: 0
                required: [ agents ]
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_query:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'agent_ids'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - agents
      summary: delete agents
      description: Delete agents matching specified filters.
      operationId: deleteAgents
      parameters:
        - $ref: '#/components/parameters/account_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/agents_to_be_deleted'
        required: true
      responses:
        204:
          description: Delete success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''Additional properties are not
                                 allowed (''faces'' was unexpected)'''
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/agents/{agent_id}:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/agent_id'

    get:
      tags:
      - agents
      summary: get agent
      description: Get the agent by ID.
      operationId: getAgent
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/agent_to_get'
        404:
          description: Analytic 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: 44007
                desc: Object not found
                detail: Agent with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44007
        500:
          $ref: '#/components/responses/internal_server_error'

    head:
      tags:
        - agents
      summary: head agent
      operationId: checkAgent
      description:  Check if agent exists.
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        204:
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          description: Agent exists.
        404:
          description: Agent not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - agents
      summary: remove agent
      description: Remove the agent by ID.
      operationId: removeAgent
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        204:
          description: Delete success.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        404:
          description: Analytic 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: 44007
                desc: Object not found
                detail: Agent with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44007
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/streams/{stream_id}/agent:
    parameters:
      - $ref: '#/components/parameters/path_stream_id'

    get:
      tags:
      - agents
      summary: get stream agent
      description: |
        Get an agent that process the stream
      operationId: getStreamAgent
      parameters:
      - $ref: '#/components/parameters/luna_account_id_header_required'
      - $ref: '#/components/parameters/analytic_index'

      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/agent_to_get'
        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
        422:
          description: Stream is not in progress.
          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:
                stream_is_not_in_progress:
                  value:
                    error_code: 44013
                    desc: Stream status is unsuitable
                    detail: Stream with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' is not currently being processed
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44013
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/agents/{agent_id}/streams:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - in: path
        name: agent_id
        schema:
          $ref: '#/components/schemas/uuid'
        required: true
        description: ID of the agent (`agent_id` received in the ["register agent"](#operation/registerAgent) request).

    post:
      tags:
      - agents interaction
      summary: get streams which processing must be started.
      description: Get agents streams by agent ID and send information about streams processing.
      operationId: postAgentStreams
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/agents_streams_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        404:
          description: Agent 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: 44007
                desc: Object not found
                detail: Agent with id '7acc35cf-a3b2-4f87-8d8b-5496a2782d37' not found
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-44007
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/agents/{agent_id}/streams/feedback:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/agent_id'
    post:
      tags:
      - agents interaction
      summary: post feedback on streams
      description: |

        Post information about streams processing. 

      operationId: postStreamsFeedback
      parameters:
        - $ref: '#/components/parameters/applicationJsonContent'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/post_streams_processing_feedback_request'
      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/streams_feedback_response'
        400:
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
              examples:
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: |
                        Failed to validate input json. Path: 'extra',  message: 'Extra inputs are not permitted'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
        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'
