OpenApi for tasks_worker Luna Tasks service

View spec in html.

openapi: 3.0.0
info:
  version: 'v.3.21.7'
  title: 'Luna tasks-worker'
  description: 'VisionLabs Luna Tasks Worker'

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

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

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

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

    transfer_encoding:
      schema:
        type: string
      example: 'chunked'
      required: true
      description: transfer encoding type

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

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

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

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

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

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

    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

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

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

    schedule_id:
      in: query
      name: schedule_id
      schema:
        $ref: '#/components/schemas/schedule_id'
      description: Schedule according to which the task was created

    schedule_id_path:
      in: path
      name: schedule_id
      required: true
      schema:
        $ref: '#/components/schemas/schedule_id'
      description: Schedule according to which the task was created

    schedule_patch:
      in: query
      name: action
      required: true
      schema:
        type: string
        enum: [pause, start]
      description: pause/start tasks schedule

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

    create_time__gte:
      in: query
      name: create_time__gte
      schema:
        type: string
        format: date-time
      description: lower included bound for object create_time.
      example: "2018-08-11T09:11:41.674Z"

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

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

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

    error_time__gte:
      in: query
      name: error_time__gte
      schema:
        type: string
        format: date-time
      description: lower included bound for object error_time.
      example: "2018-08-11T09:11:41.674Z"

    task_type:
      in: query
      name: task_type
      schema:
        $ref: '#/components/schemas/task_type'
      example: 1

    task_type_schedulable:
      in: query
      name: task_type
      schema:
        $ref: '#/components/schemas/task_type_schedulable'
      example: 1

    task_status:
      in: query
      name: task_status
      schema:
        $ref: '#/components/schemas/task_status'
      example: 1

    subtask_status:
      in: query
      name: subtask_status
      schema:
        $ref: '#/components/schemas/subtask_status'
      example: 2

    account_id:
      in: query
      name: account_id
      schema:
        $ref: '#/components/schemas/uuid'
      description: account id.
      example: 7daa0e35-36a2-474a-8f2b-87f78b59d080

    account_id_header_required:
      in: header
      name: Luna-Account-Id
      schema:
        $ref: '#/components/schemas/account_id'
      description: luna account id
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'
      required: true

    result_id:
      in: query
      name: result_id
      schema:
        $ref: '#/components/schemas/uuid'
      description: id of task result, which stored in luna-image store.
      example: 8f4f0070-c464-460b-bf78-fac225df72e9

    error_ids:
      in: query
      name: error_ids
      schema:
        $ref: '#/components/schemas/errorIds'
      description: error ids

    error_id_uri:
      in: path
      name: error_id
      schema:
        $ref: '#/components/schemas/error_id'
      required: true
      description: error id
      example: 10

    task_ids:
      in: query
      name: task_ids
      schema:
        $ref: '#/components/schemas/task_ids'
      description: comma-separate task ids

    task_id_uri:
      in: path
      name: task_id
      schema:
        $ref: '#/components/schemas/task_id'
      required: true
      description: task id

    error_code:
      in: query
      name: error_code
      schema:
        $ref: '#/components/schemas/error_code'
      description: error code

    status_code:
      in: query
      name: status_code
      schema:
        $ref: '#/components/schemas/status_code'
      description: status code

    accept_docs_handler:
      in: header
      name: Accept
      schema:
        $ref: '#/components/schemas/accept_docs_handler'
      required: true
      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.

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

    error_code:
      type: integer
      description: error code.

    error_link:
      type: string
      description: Link to the documentation website with the error description.

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

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

    int0100:
      type: integer
      minimum: 0
      maximum: 100

    string36:
      type: string
      maxLength: 36

    image_origin:
      type: string
      maxLength: 256
      description: the image url - source of the detection
      nullable: true

    tags:
      description: tag array.
      type: array
      minItems: 1
      items:
        $ref: '#/components/schemas/string36'
      example: ["tag1", "tag2"]

    error_id:
      type: integer
      example: 10

    errorIds:
      type: string
      format: comma-separate task ids
      minItems: 1
      example: 4,5,6

    task_status:
      type: integer
      enum: [0, 1, 2, 3, 4, 5]
      example: 1
      description: |
        task status

        | task status | value |
        |-----------------|---|
        | pending         | 0 |
        | in progress     | 1 |
        | cancelled       | 2 |
        | failed          | 3 |
        | collect results | 4 |
        | done            | 5 |

    subtask_status:
      type: integer
      enum: [0, 1, 2, 3, 4]
      example: 2
      description: |
        subtask status

        | subtask status| value |
        |-------------------|---|
        | pending           | 0 |
        | in progress       | 1 |
        | cancelled         | 2 |
        | failed            | 3 |
        | done              | 4 |

    result_id:
      allOf:
      - $ref: '#/components/schemas/uuid'
      description: task result id in a storage.
      nullable: true

    account_id:
      allOf:
      - $ref: '#/components/schemas/uuid'
      description: account id

    task_account_id:
      allOf:
      - $ref: '#/components/schemas/uuid'
      description: account id of the task
      example: '346a5645-ec89-4806-820a-dbcb6e0dc381'

    task_count:
      type: object
      properties:
        count:
          type: integer
          minimum: 0
          example: 152
          description: tasks count

    error_count:
      type: object
      properties:
        count:
          type: integer
          minimum: 0
          example: 101
          description: errors count

    task_type:
      type: integer
      enum: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      example: 3
      description: |
        task type

        | task type            | value |
        |----------------------|-------|
        | unknown              | 0     |
        | linker               | 1     |
        | clusterization       | 2     |
        | report               | 3     |
        | garbage collect      | 4     |
        | additional extract   | 5     |
        | cross match          | 6     |
        | roc-curve calculation| 7     |
        | export objects       | 8     |
        | estimate data        | 9     |
        | lambda task          | 10    |

    task_type_schedulable:
      type: integer
      enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      example: 3
      description: |
        task type

        | task type            | value |
        |----------------------|-------|
        | linker               | 1     |
        | clusterization       | 2     |
        | report               | 3     |
        | garbage collect      | 4     |
        | additional extract   | 5     |
        | cross match          | 6     |
        | roc-curve calculation| 7     |
        | export objects       | 8     |
        | estimate data        | 9     |
        | lambda               | 10    |

        Scheduling a *report* task will spawn 2 tasks: *clusterization* and then *report*. If the *clustering* task is not completed, the *report* task will not be created

    int_version:
      type: integer
      minimum: 0

    task_ids:
      type: string
      format: comma-separate task ids
      description: task ids.
      example: 1,2,3

    task_description:
      type: string
      maxLength: 128
      description: task description
      example: "task description"

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

    task_notification_policy_response:
      allOf:
        - $ref: "#/components/schemas/notification_policy"
      required: [enable, task_callbacks, subtask_callbacks]

    task_base:
      type: object
      properties:
        notification_policy:
          $ref: '#/components/schemas/notification_policy'
        description:
          $ref: '#/components/schemas/task_description'
      required: [content]

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

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

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

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

    task_callbacks:
      type: array
      items:
        $ref: '#/components/schemas/task_callback'
      description: |
        Callbacks for sending tasks id and status to third party system. Callbacks are executed after task status changed.
        
        **Sample Output for successful task**
        ```
        {
          "task_id": 123,  
          "task_status": "done",  
          "result_id": "00000000-0000-4000-a000-000000658854", 
          "result_url": "http://127.0.0.1:5000/6/tasks/00000000-0000-4000-a000-000000658854/result"
        }
        ```
        
        ** Sample Output for failed task **
        ```
        {"task_id": 123, "task_status": "failed"}
        ```
                
        ** Sample Output for cancelled task **
        ```
        {"task_id": 123, "task_status": "cancelled"}
        ```
      example:
        $ref: "#/components/schemas/task_callbacks_example"

    subtask_callbacks:
      type: array
      items:
        $ref: '#/components/schemas/task_callback'
      description: |
        Callbacks for sending subtasks id, status and number of completed subtasks to third party system. 
        Callbacks are executed after subtask status changed.
        
        ** Sample Output for start subtask **
        ```
        {"subtask_id": 123, "subtask_status": "in_progress", "completed_subtasks": 0}
        ```
        
        ** Sample Output for successful subtask **
        ```
        {"subtask_id": 123, "subtask_status": "done", "completed_subtasks": 1}
        ```
        
        ** Sample Output for failed subtask **
        ```
        {"subtask_id": 123, "subtask_status": "failed", "completed_subtasks": 0}
        ```
                
        ** Sample Output for cancelled subtask **
        ```
        {"subtask_id": 123, "subtask_status": "cancelled", "completed_subtasks": 0}

      example:
        $ref: "#/components/schemas/task_callbacks_example"

    task_content:
      type: object
      description: content of task
      example: content

    subtask_content:
      type: object
      description: content of subtask
      example: content
      additionalProperties: true

    objects_type:
      type: string
      description: objects type - faces or events
      enum: ["faces", "events"]
      example: "faces"

    common_objects_type:
      type: string
      description: objects type - faces, attributes or events
      enum: ["faces", "events", "attributes"]

    error_description:
      type: string
      description: error description
      example: Faces not found

    error_detail:
      type: string
      description: error detail
      example: One or more faces not found, including face with id '8f4f0070-c464-460b-bf78-fac225df72e9'

    errors_additional_info:
      type: string
      description: additional error info
      example: 8f4f0070-c464-460b-bf78-fac225df72e9
      nullable: true

    count_task_parts_done:
      type: integer
      minimum: 0
      description: count of task finished parts
      example: 10

    count_task_parts_all:
      type: integer
      minimum: 1
      description: count of task parts
      example: 100

    status_code:
      type: integer
      minimum: 400
      maximum: 599
      description: error status code
      example: 500

    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]

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

    task_id:
      type: integer
      minimum: 1
      description: task id
      example: 123

    subtask_id:
      type: integer
      minimum: 1
      description: subtask id
      example: 5

    time:
      description: time in rfc3339 format
      type: string
      format: date-time
      example: "2021-07-28T01:23:21.537604+03:00"

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

    time_nullable:
      type: string
      nullable: true
      format: date-time
      example: "2018-08-11T10:11:41.674Z"

    tasks_reply:
      type: object
      description: tasks container
      properties:
        tasks:
          type: array
          description: found tasks
          items:
            $ref: '#/components/schemas/task_reply'

    limit:
      description: Maximum number of matching candidates to return for every match.
      type: integer
      minimum: 1
      example: 3
      default: 5

    clustering_limit:
      allOf:
      - $ref: '#/components/schemas/limit'
      maximum: 20000
      default: 20000

    subtask_in_reply:
      type: object
      properties:
        subtask_id:
          $ref: '#/components/schemas/subtask_id'
        task_id:
          $ref: '#/components/schemas/task_id'
        result_id:
          $ref: '#/components/schemas/result_id'
        create_time:
          allOf:
          - $ref: '#/components/schemas/time'
          description: subtask create time
        end_time:
          allOf:
          - $ref: '#/components/schemas/time_nullable'
          description: subtask end time
        subtask_status:
          $ref: '#/components/schemas/subtask_status'
        content:
          $ref: '#/components/schemas/subtask_content'
      required: [subtask_id, task_id, create_time, subtask_status, content]

    subtasks_reply:
      description: Subtasks of a current task.
      type: object
      properties:
        subtasks:
          type: array
          items:
            $ref: '#/components/schemas/subtask_in_reply'

    task_error:
      type: object
      properties:
        error_id:
          $ref: '#/components/schemas/error_id'
        task_id:
          $ref: '#/components/schemas/task_id'
        subtask_id:
          $ref: '#/components/schemas/subtask_id'
        error_code:
          $ref: '#/components/schemas/error_code'
        link:
          $ref: '#/components/schemas/error_link'
        description:
          $ref: '#/components/schemas/error_description'
        detail:
          $ref: '#/components/schemas/error_detail'
        additional_info:
          $ref: '#/components/schemas/errors_additional_info'
        error_time:
          allOf:
          - $ref: '#/components/schemas/time'
          description: error time
      required: [error_id, task_id, subtask_id, error_code, link, description, detail, error_time]

    task_errors:
      type: array
      items:
        $ref: '#/components/schemas/task_error'
      maxItems: 100000
      description: |
        done task errors. Max error count is setting in the service configuration file. This limitation is applied at the moment when the
        task creates result.

    task_handler_errors:
      type: array
      items:
        $ref: '#/components/schemas/Error'
      minItems: 0
      description: image processing errors in handlers

    float10:
      type: number
      format: float
      minimum: 0
      maximum: 1

    face_ids:
      description: face ids
      type: array
      minItems: 1
      items:
        $ref: '#/components/schemas/uuid'
      example: ['8950722f-3fd4-4223-b48f-03f95f0e8dfb', '346a5645-ec89-4806-820a-dbcb6e0dc381']

    attribute_ids:
      description: attribute ids
      type: array
      items:
        $ref: '#/components/schemas/uuid'
      minItems: 1
      example: ['8950722f-3fd4-4223-b48f-03f95f0e8dfb', '346a5645-ec89-4806-820a-dbcb6e0dc381']

    external_id:
      description: user-defined external id for face.
      type: string
      maxLength: 36
      example: "2xQ2gprbMUePw1s9gw9fvA=="

    external_ids:
      type: array
      minItems: 1
      items:
        $ref: '#/components/schemas/external_id'
      description: list of external ids. Each event from result will contain one of the given external ids.
      example: ['8950722f-3fd4-4223-b48f-03f95f0e8dfb', '346a5645-ec89-4806-820a-dbcb6e0dc381']

    user_data:
      description: user data.
      type: string
      maxLength: 128
      example: "100-00-12"

    face_id__gte:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: face id lower included boundary

    face_id__lt:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: face id upper excluded boundary

    descriptor_info:
      type: object
      description: descriptor object filter
      properties:
        type:
          type: string
          description: descriptor type
          enum: ["face", "body"]
          default: "face"
      required: [type]

    faces_filters_no_account:
      allOf:
        - $ref: '#/components/schemas/faces_filters_no_create_time'
      type: object
      properties:
        create_time__gte:
          description: Create time lower included boundary.
          oneOf:
            - $ref: '#/components/schemas/create_time__gte'
            - $ref: '#/components/schemas/create_time_now__gte'
        create_time__lt:
          description: Create time upper excluded boundary.
          oneOf:
            - $ref: '#/components/schemas/create_time__lt'
            - $ref: '#/components/schemas/create_time_now__lt'

    faces_filters_schedule:
      allOf:
        - $ref: '#/components/schemas/faces_filters_no_create_time'
      type: object
      properties:
        create_time__gte:
          description: Create time lower included boundary.
          $ref: '#/components/schemas/create_time_now__gte'
        create_time__lt:
          description: Create time upper excluded boundary.
          $ref: '#/components/schemas/create_time_now__lt'
        account_id:
          $ref: '#/components/schemas/account_id'

    faces_filters_no_create_time:
      type: object
      properties:
        face_ids:
          $ref: '#/components/schemas/face_ids'
        external_ids:
          $ref: '#/components/schemas/external_ids'
        user_data:
          $ref: '#/components/schemas/user_data'
        face_id__gte:
          $ref: '#/components/schemas/face_id__gte'
        face_id__lt:
          $ref: '#/components/schemas/face_id__lt'
        list_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: list id.
          example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    faces_filters_no_account_limited:
      allOf:
        - $ref: '#/components/schemas/faces_filters_no_account'
      properties:
        face_ids:
          maxItems: 20000
        external_ids:
          maxItems: 1000

    faces_filters_no_account_limited_reply:
      allOf:
        - $ref: '#/components/schemas/faces_filters_no_create_time'
      properties:
        create_time__gte:
          description: Create time lower included boundary.
          $ref: '#/components/schemas/create_time__gte'
        create_time__lt:
          description: Create time upper excluded boundary.
          $ref: '#/components/schemas/create_time__lt'
        face_ids:
          maxItems: 20000
        external_ids:
          maxItems: 1000

    faces_filters:
      allOf:
        - $ref: '#/components/schemas/faces_filters_no_account'
      type: object
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'
      required: [ account_id ]

    faces_filters_regular_create_time:
      allOf:
        - $ref: '#/components/schemas/faces_filters_no_create_time'
      type: object
      properties:
        create_time__gte:
          description: Create time lower included boundary.
          $ref: '#/components/schemas/create_time__gte'
        create_time__lt:
          description: Create time upper excluded boundary.
          $ref: '#/components/schemas/create_time__lt'
        account_id:
          $ref: '#/components/schemas/account_id'
      required: [ account_id ]

    faces_filters_limited_optional_account:
      allOf:
      - $ref: '#/components/schemas/faces_filters_no_account_limited'
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'

    faces_filters_limited:
      allOf:
      - $ref: '#/components/schemas/faces_filters_limited_optional_account'
      required: [account_id]

    attributes_filters_no_account:
      type: object
      properties:
        attribute_ids:
          $ref: '#/components/schemas/attribute_ids'
      required: [attribute_ids]

    attributes_filters_no_account_limited:
      allOf:
      - $ref: '#/components/schemas/attributes_filters_no_account'
      type: object
      properties:
        attribute_ids:
          minItems: 1
          maxItems: 20000

    geo_position:
      type: object
      description: |
        geo position filter is bounding box specified by coordinates of its center (origin) and some delta.
        WARNING: boxes with a vertex or border on the International Date Line (IDL) or the North or South pole are
        not fully supported due to features of database spatial index - filter result may be unexpected.
        NOTE: highly recommended for citywide use only.
      properties:
        origin_longitude:
          $ref: '#/components/schemas/longitude'
        origin_latitude:
          $ref: '#/components/schemas/latitude'
        longitude_delta:
          type: number
          minimum: 0
          maximum: 90
          default: 0.01
          example: 0.1
          description: |
            longitude delta in degrees.
            WARNING: boxes with a vertex or border on the International Date Line (IDL) or the North or South pole
            are not fully supported due to features of database spatial index - filter result may be unexpected.
            Box edges more than 180 degrees long are not allowed. Boundaries of valid range are **exclusive**. NOTE: highly recommended for citywide use only.
        latitude_delta:
          type: number
          minimum: 0
          maximum: 90
          default: 0.01
          example: 0.1
          description: |
            latitude delta in degrees.
            WARNING: boxes with a vertex or border on the International Date Line (IDL) or the North or South pole
            are not fully supported due to features of database spatial index - filter result may be unexpected.
            Box edges more than 180 degrees long are not allowed. Boundaries of valid range are **exclusive**. NOTE: highly recommended for citywide use only.
      required: [origin_longitude, origin_latitude]

    label:
      type: string
      maxLength: 36
      description: matching label
      example: "matching_label"

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

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

    event_id__gte:
      allOf:
        - $ref: '#/components/schemas/event_id'
      description: event id lower included boundary

    event_id__lt:
      allOf:
        - $ref: '#/components/schemas/event_id'
      description: event id upper excluded boundary

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

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

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

    events_filters_no_account:
      allOf:
        - $ref: '#/components/schemas/events_filters_no_create_end_time'
      properties:
        create_time__gte:
          description: Create time lower included boundary.
          oneOf:
            - $ref: '#/components/schemas/create_time__gte'
            - $ref: '#/components/schemas/create_time_now__gte'
        create_time__lt:
          description: Create time upper excluded boundary.
          oneOf:
            - $ref: '#/components/schemas/create_time__lt'
            - $ref: '#/components/schemas/create_time_now__lt'
        end_time__gte:
          description: End time lower included boundary.
          oneOf:
            - $ref: '#/components/schemas/end_time__gte'
            - $ref: '#/components/schemas/end_time_now__gte'
        end_time__lt:
          description: End time upper excluded boundary.
          oneOf:
            - $ref: '#/components/schemas/end_time__lt'
            - $ref: '#/components/schemas/end_time_now__lt'

    events_filters_schedule:
      allOf:
        - $ref: '#/components/schemas/events_filters_no_create_end_time'
      properties:
        create_time__gte:
          description: Create time lower included boundary.
          $ref: '#/components/schemas/create_time_now__gte'
        create_time__lt:
          description: Create time upper excluded boundary.
          $ref: '#/components/schemas/create_time_now__lt'
        end_time__gte:
          description: End time lower included boundary.
          $ref: '#/components/schemas/end_time_now__gte'
        end_time__lt:
          description: End time upper excluded boundary.
          $ref: '#/components/schemas/end_time_now__lt'
        account_id:
          $ref: '#/components/schemas/account_id'

    deepfake_enum:
      description: |
        predominant deepfake.

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

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

    deepfake_filter:
      type: array
      minItems: 1
      items:
        $ref: '#/components/schemas/deepfake_enum'
      description: |
        list of deepfake. Each event from result will contain one of the given deepfake.

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

    events_filters_no_create_end_time:
      type: object
      properties:
        sources:
          description: sources. Each event from result will contain one of the given sources.
          type: array
          minItems: 1
          items:
            type: [string, null]
          example: ["cam1", "cam2"]
        stream_ids:
          description: stream ids
          type: array
          minItems: 1
          items:
            allOf:
              - $ref: '#/components/schemas/stream_id'
              - nullable: true
          example: ['8950722f-3fd4-4223-b48f-03f95f0e8dfb', '346a5645-ec89-4806-820a-dbcb6e0dc381']
        event_ids:
          description: events ids
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/event_id'
          example: ['8950722f-3fd4-4223-b48f-03f95f0e8dfb', '346a5645-ec89-4806-820a-dbcb6e0dc381']
        event_id__gte:
          $ref: '#/components/schemas/event_id__gte'
        event_id__lt:
          $ref: '#/components/schemas/event_id__lt'
        external_ids:
          $ref: '#/components/schemas/external_ids'
        handler_ids:
          description: handler ids. Each event from result will contain one of the given handlers.
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/uuid'
          example: ['8950722f-3fd4-4223-b48f-03f95f0e8dfb', '346a5645-ec89-4806-820a-dbcb6e0dc381']
        top_matching_candidates_label:
          type: string
          maxLength: 36
          description: top matching candidate label
          example: "matching_label"
        top_similar_object_ids:
          description: ids of the most similar object.
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/uuid'
          example: ['8950722f-3fd4-4223-b48f-03f95f0e8dfb', '346a5645-ec89-4806-820a-dbcb6e0dc381']
        top_similar_external_ids:
          description: external ids of the most similar objects.
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/external_id'
          example: ['external_id_1', 'external_id_2']
        top_similar_object_similarity__gte:
          allOf:
            - $ref: '#/components/schemas/float10'
          description: the lower including boundary of the most similar face similarity.
          example: 0.5
        top_similar_object_similarity__lt:
          allOf:
            - $ref: '#/components/schemas/float10'
          description: the upper excluding boundary of the most similar face similarity.
        age__lt:
          description: the upper excluding boundary of age.
          type: integer
          minimum: 0
          maximum: 100
          example: 50
        age__gte:
          description: the lower including boundary of age.
          type: integer
          minimum: 0
          maximum: 100
          example: 50
        gender:
          type: [integer, null]
          enum: [ 0, 1, null ]
          description: gender, 0 - female, 1 - male
        emotions:
          description: |
            list of predominant emotions. Each event from result will contain one of the given emotions.

            | emotions    | value |
            |-----------------|---|
            | anger           | 1 |
            | disgust         | 2 |
            | fear            | 3 |
            | happiness       | 4 |
            | neutral         | 5 |
            | sadness         | 6 |
            | surprise        | 7 |
          type: array
          minItems: 1
          items:
            type: [integer, null]
            enum: [1, 2, 3, 4, 5, 6, 7, null]
          example: [1, 2, 3]
        ethnic_groups:
          description: |
            list of dominant ethnic group. Each event from result will contain one of the given ethnic groups.

            | ethnicity   | value |
            |-----------------|---|
            | AfricanAmerican | 1 |
            | Indian          | 2 |
            | Asian           | 3 |
            | Caucasian       | 4 |
          type: array
          minItems: 1
          items:
            type: [integer, null]
            enum: [1, 2, 3, 4, null]
          example: [1, 2]
        face_ids:
          $ref: '#/components/schemas/face_ids'
        user_data:
          $ref: '#/components/schemas/user_data'
        tags:
          allOf:
            - $ref: '#/components/schemas/tags'
          description: list of tags. Each event from result will contain all of the given tags.
        cities:
          description: comma-separated list of cities. Each event from result will contain one of the given cities in location.
          type: array
          minItems: 1
          items:
            type: [string, null]
          example: ["moscow", "New-York"]
        areas:
          description: comma-separated list of areas. Each event from result will contain one of the given areas in location.
          type: array
          minItems: 1
          items:
            type: [string, null]
          example: ["CAO", "central park"]
        districts:
          description: comma-separated list of districts. Each event from result will contain one of the given districts in location.
          type: array
          minItems: 1
          items:
            type: [string, null]
          example: ["mitino", "central park"]
        streets:
          description: comma-separated list of streets. Each event from result will contain one of the given streets  in location.
          type: array
          minItems: 1
          items:
            type: [string, null]
          example: ["arbat", "schepkina"]
        house_numbers:
          description: comma-separated list of house numbers. Each event from result will contain one of the given house numbers in location.
          type: array
          minItems: 1
          items:
            type: [string, null]
          example: ["1", "1/2str3"]
        geo_position:
          allOf:
          - $ref: '#/components/schemas/geo_position'
          nullable: true
        masks:
          description: |
            list of mask states. Each event from result will contain one of the given mask states.

            | masks      | value |
            |----------------|---|
            | missing        | 1 |
            | medical_mask   | 2 |
            | occluded       | 3 |
          type: array
          minItems: 1
          items:
            type: [integer, null]
            enum: [1, 2, 3, null]
          example: [2, 3]
        track_ids:
          type: array
          minItems: 1
          description: list of track ids. Each event from result will contain one of the given track ids.
          items:
            type: [string, null]
            pattern: '^[a-zA-Z0-9_\-]{1,36}$'
          example: ["track_id_number_1", "track_id_number_2"]
        liveness:
          type: array
          minItems: 1
          description: |
            list of predominant liveness. Each event from result will contain one of the given liveness.

            | liveness | value |
            |--------------|---|
            | spoof        | 0 |
            | real         | 1 |
            | unknown      | 2 |
          items:
            type: [integer, null]
            enum: [0, 1, 2, null]
          example: [1, 2]
        deepfake:
          $ref: '#/components/schemas/deepfake_filter'
        apparent_gender:
          type: array
          minItems: 1
          items:
            type: [integer, null]
            nullable: true
            enum: [ 0, 1, 2, null ]
          description: |
            List of apparent gender: 0 - female, 1 - male, 2 - undefined. Each event from result will contain one of the given states.
          example: [0,1]
        apparent_age__lt:
          type: integer
          minimum: 0
          maximum: 100
          description: Apparent age upper excluded bound.
          example: 50
        apparent_age__gte:
          type: integer
          minimum: 0
          maximum: 100
          description: Apparent age lower included bound.
          example: 50
        headwear_states:
          type: array
          minItems: 1
          items:
            type: [integer, null]
            enum: [ 0, 1, 2, null ]
          description: |
            List of headwear states: 0 - absent, 1 - present, 2 - undefined. Each event from result will contain one of the given states.
          example: [0,1]
        sleeve_lengths:
          type: array
          minItems: 1
          items:
            type: [string, null]
            enum: [ short, long, undefined, null ]
          description: |
            List of sleeve length states. Each event from result will contain one of the given states.
          example: [short,long]
        upper_clothing_colors:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/expanded_palette"
          description: |
            List of upper clothing colors. Each event from result will contain at least one of the given clothing colors.
          example: [black,white]
        lower_garment_colors:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/expanded_palette"
          description: |
            Clothing color filter. Each event from result will contain at least one of the given clothing colors.
            
            > **WARNING** This enum may be to expand. This field must be interpret as arbitrary string which can be equal 
            to one element from enum.
          example: [ black, white ]
        backpack_states:
          type: array
          minItems: 1
          items:
            type: [integer, null]
            enum: [ 0, 1, 2, null ]
          description: |
            List of backpack states: 0 - absent, 1 - present, 2 - undefined. Each event from result will contain one of the given states.
          example: [1,2]
        lower_garment_types:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/lower_garment_type'
          description: |
            Lower garment type filter.
            
            > **WARNING** This enum may be to expand. This field must be interpret as arbitrary string which can be equal 
            to one element from enum.
          example: [ 'shorts',  'skirt' ]
        shoes_apparent_colors:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/short_palette'
          description: |
            Shoes apparent color filter.
            
            > **WARNING** This enum may be to expand. This field must be interpret as arbitrary string which can be equal 
            to one element from enum.
          example: [ 'white' ]
        headwear_apparent_colors:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/short_palette'
          description: |
            Headwear apparent color filter.
            
            > **WARNING** This enum may be to expand. This field must be interpret as arbitrary string which can be equal 
            to one element from enum.
          example: [ 'black' ]
        meta:
          type: object
          nullable: true
          additionalProperties: true
          description: |
            User-defined event meta's filters.

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

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

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

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

            Allowed usage of filters is:

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

          example: {"user.email": "root@localhost", "user.age__gt": 18}

    events_filters_no_filters_limited:
      allOf:
        - $ref: '#/components/schemas/events_filters_no_create_end_time'
      type: object
      properties:
        event_ids:
          maxItems: 20000
        handler_ids:
          maxItems: 1000
        external_ids:
          maxItems: 1000
        top_similar_object_ids:
          maxItems: 1000
        top_similar_external_ids:
          maxItems: 1000
        face_ids:
          maxItems: 1000
        sources:
          maxItems: 1000
        stream_ids:
          maxItems: 1000
        cities:
          maxItems: 1000
        areas:
          maxItems: 1000
        districts:
          maxItems: 1000
        streets:
          maxItems: 1000
        house_numbers:
          maxItems: 1000
        track_ids:
          maxItems: 1000

    events_filters_no_account_limited:
      allOf:
        - $ref: '#/components/schemas/events_filters_no_filters_limited'
      properties:
        create_time__gte:
          description: Create time lower included boundary.
          oneOf:
            - $ref: '#/components/schemas/create_time__gte'
            - $ref: '#/components/schemas/create_time_now__gte'
        create_time__lt:
          description: Create time upper excluded boundary.
          oneOf:
            - $ref: '#/components/schemas/create_time__lt'
            - $ref: '#/components/schemas/create_time_now__lt'
        end_time__gte:
          description: End time lower included boundary.
          oneOf:
            - $ref: '#/components/schemas/end_time__gte'
            - $ref: '#/components/schemas/end_time_now__gte'
        end_time__lt:
          description: End time upper excluded boundary.
          oneOf:
            - $ref: '#/components/schemas/end_time__lt'
            - $ref: '#/components/schemas/end_time_now__lt'

    events_filters_no_account_limited_reply:
      allOf:
        - $ref: '#/components/schemas/events_filters_no_filters_limited'
      type: object
      properties:
        create_time__gte:
          description: Create time lower included boundary.
          $ref: '#/components/schemas/create_time__gte'
        create_time__lt:
          description: Create time upper excluded boundary.
          $ref: '#/components/schemas/create_time__lt'
        end_time__gte:
          description: End time lower included boundary.
          $ref: '#/components/schemas/end_time__gte'
        end_time__lt:
          description: End time upper excluded boundary.
          $ref: '#/components/schemas/end_time__lt'

    events_filters:
      allOf:
      - $ref: '#/components/schemas/events_filters_no_account'
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'
      required: [ account_id ]

    events_filters_regular_create_time:
      allOf:
        - $ref: '#/components/schemas/events_filters_no_create_end_time'
      type: object
      properties:
        create_time__gte:
          description: Create time lower included boundary.
          $ref: '#/components/schemas/create_time__gte'
        create_time__lt:
          description: Create time upper excluded boundary.
          $ref: '#/components/schemas/create_time__lt'
        end_time__gte:
          description: End time lower included boundary.
          $ref: '#/components/schemas/end_time__gte'
        end_time__lt:
          description: End time upper excluded boundary.
          $ref: '#/components/schemas/end_time__lt'
        account_id:
          $ref: '#/components/schemas/account_id'
      required: [ account_id ]

    events_filters_limited_optional_account:
      allOf:
      - $ref: '#/components/schemas/events_filters_no_account_limited'
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'

    events_filters_limited:
      allOf:
      - $ref: '#/components/schemas/events_filters_limited_optional_account'
      required: [ account_id ]

    face_filters:
      description: face filters.
      type: object
      properties:
        account_id:
            $ref: '#/components/schemas/account_id'
        face_id__lt:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: upper face id excluding boundary.
        face_id__gte:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: lower face id including boundary.

    linker_task_content:
      allOf:
        - $ref: "#/components/schemas/linker_task_content_no_filters"
      type: object
      properties:
        filters:
          anyOf:
            - $ref: '#/components/schemas/faces_filters'
            - $ref: '#/components/schemas/events_filters'
      required: [ objects_type, filters ]

    linker_task_content_reply:
      allOf:
        - $ref: "#/components/schemas/linker_task_content_no_filters"
      type: object
      properties:
        filters:
          anyOf:
            - $ref: '#/components/schemas/faces_filters_regular_create_time'
            - $ref: '#/components/schemas/events_filters_regular_create_time'
      required: [ objects_type, filters ]

    linker_task_content_schedule:
      allOf:
        - $ref: "#/components/schemas/linker_task_content_no_filters"
      type: object
      properties:
        filters:
          anyOf:
            - $ref: '#/components/schemas/faces_filters_schedule'
            - $ref: '#/components/schemas/events_filters_schedule'
          required: [account_id]
      required: [ objects_type, filters ]

    linker_task_content_no_filters:
      type: object
      description: linker task content
      properties:
        create_list:
          description: create list to link faces to or not | require list_id or create_list set to 1
          type: integer
          enum: [0, 1]
          example: 0
        list_id:
          description: id of list to link faces to | require list_id or create_list set to 1
          allOf:
          - $ref: '#/components/schemas/uuid'
        user_data:
          allOf:
          - $ref: '#/components/schemas/user_data'
          description: user data to create the list with | works if create_list set to 1
        objects_type:
          $ref: '#/components/schemas/objects_type'

    linker_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/linker_task_content'

    new_handler_task_estimator:
      type: object
      description: new handler with policies
      properties:
        description:
          type: string
          maxLength: 128
          description: user description.
          default: estimator_task_{task_id}
        policies:
          description: handler policies.
          type: object
          additionalProperties:
            x-additionalPropertiesName: new handler policies fields
            description: See the Luna Handlers documentation section for details - "creating a handler".
      required: [policies]

    existing_handler_task_estimator:
      type: object
      description: existing handler
      properties:
        handler_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: |
           handler_id of static or dynamic handler.

           An error will occur if policies are specified for static handlers.
        policies:
          description: handler policies (required for dynamic handler).
          type: object
          additionalProperties:
            x-additionalPropertiesName: handler policies fields
            description: See the Luna Handlers documentation section for details - "creating a handler".
      required: [ handler_id ]

    base_estimator_task_content_source:
      type: object
      properties:
        image_type:
          type: integer
          enum: [0,1,2]
          default: 0
          description: image type of input image.  0 - raw image, 1 - face warped image, 2 - body warped image
      required: [source_type]

    base_estimator_task_content_source_required:
      allOf:
        - $ref: '#/components/schemas/base_estimator_task_content_source'
        - required: [image_type, source_type]

    zip_password_authorization:
      type: object
      description: password authorization
      properties:
        password:
          type: string
          maxLength: 128
          description: user password for the archive (zip archive support now)

    estimator_authorization_by_password:
      type: object
      description: user authorization meta
      properties:
        source_type:
          type: string
          enum: ["zip"]
          description: data type where images are located
        reference:
          oneOf:
          - $ref: '#/components/schemas/zip_reference'
          - type: string
            description: archive location url
            format: uri
        authorization:
          $ref: '#/components/schemas/zip_password_authorization'
        recursive:
          type: boolean
          default: true
          description: whether to estimate images from zip archive subdirectories recursively
      required: [reference]

    estimator_source_with_option_zip:
      allOf:
        - $ref: '#/components/schemas/estimator_authorization_by_password'
        - $ref: '#/components/schemas/base_estimator_task_content_source'

    estimator_source_with_option_network_disk:
      allOf:
        - $ref: '#/components/schemas/estimator_mounted_network_path'
        - $ref: '#/components/schemas/base_estimator_task_content_source'

    estimator_source_with_option_ftp:
      allOf:
        - $ref: '#/components/schemas/estimator_ftp_server_data'
        - $ref: '#/components/schemas/base_estimator_task_content_source'

    estimator_source_with_option_samba:
      allOf:
        - $ref: '#/components/schemas/estimator_samba_data'
        - $ref: '#/components/schemas/base_estimator_task_content_source'

    estimator_source_with_option_zip_required:
      allOf:
        - $ref: '#/components/schemas/estimator_authorization_by_password'
        - $ref: '#/components/schemas/base_estimator_task_content_source_required'

    estimator_source_with_option_network_disk_required:
      allOf:
        - $ref: '#/components/schemas/estimator_mounted_network_path_required'
        - $ref: '#/components/schemas/base_estimator_task_content_source_required'

    estimator_source_with_option_ftp_required:
      allOf:
        - $ref: '#/components/schemas/estimator_ftp_server_data_required'
        - $ref: '#/components/schemas/base_estimator_task_content_source_required'

    estimator_source_with_option_samba_required:
      allOf:
        - $ref: '#/components/schemas/estimator_samba_data_required'
        - $ref: '#/components/schemas/base_estimator_task_content_source_required'

    prefix_schema:
      type: string
      description: |
        file key prefix, also can be used to download from specific folder

        example file tree and prefixes
        ```
        .
        ├── prefix
        │   ├── 123_file.jpg
        │   └── file2.jpg
        ├── temp_file.jpg
        └── prefix_file.jpg
        ```

        | prefix        | result files                                           |
        |---------------|--------------------------------------------------------|
        | prefix        | prefix/file2.jpg, prefix/123_file.jpg, prefix_file.jpg |
        | prefix/       | prefix/file2.jpg, prefix/123_file.jpg                  |
        | prefix/123    | prefix/123_file.jpg                                    |
        | temp          | temp_file.jpg                                          |

    postfix_schema:
      type: string
      description: |
        file key postfix, also can be used to download files with specific extension

        example file tree and postfixes
        ```
        .
        ├── dir
        │   ├── face1.jpg
        │   └── face2.png
        ├── temp_file.png
        └── file.jpg
        ```

        | postfix       | result files                          |
        |---------------|---------------------------------------|
        | .jpg          | dir/face1.jpg, file.jpg               |
        | .png          | dir/face2.png, temp_file.png          |

    zip_reference:
      type: object
      description: zip archive reference
      properties:
        url:
          type: string
          description: archive location url
          format: uri
        prefix:
          $ref: '#/components/schemas/prefix_schema'
        postfix:
          $ref: '#/components/schemas/postfix_schema'
      required: [url]

    samba_reference:
      type: object
      description: samba reference.
      properties:
        host:
          type: string
          description: samba server host (IP)
        port:
          type: integer
          description: samba port
          minimum: 1
          maximum: 65535
          default: 445
        path:
          type: string
          description: path to directory with images
        prefix:
          $ref: '#/components/schemas/prefix_schema'
        postfix:
          $ref: '#/components/schemas/postfix_schema'
      required: [host]

    samba_reference_required:
      allOf:
        - $ref: '#/components/schemas/samba_reference'
        - required: [ host, port, path ]

    samba_authorization:
      type: object
      description: | 
        samba authorization.
        
        If no authorization data, connect to samba will be like guest.
      properties:
        user:
          type: string
          description: samba user
        password:
          type: string
          description: samba server password
      required: [user, password]

    estimator_samba_data:
      type: object
      description: samba
      properties:
        source_type:
          type: string
          enum: ["samba"]
          description: data type where images are located
        reference:
          $ref: '#/components/schemas/samba_reference'
        authorization:
          $ref: '#/components/schemas/samba_authorization'
        recursive:
          type: boolean
          default: true
          description: whether to estimate images from samba subdirectories recursively
      required: [reference]

    estimator_samba_data_required:
      allOf:
        - $ref: '#/components/schemas/estimator_samba_data'
        - properties:
            reference:
              $ref: '#/components/schemas/samba_reference_required'
        - required: [source_type, reference, recursive]

    ftp_reference:
      type: object
      description: ftp server reference
      properties:
        host:
          type: string
          description: ftp server host (IP or hostname)
        port:
          type: integer
          description: ftp server port
          minimum: 1
          maximum: 65535
          default: 21
        max_sessions:
          type: integer
          description: maximum number of allowed FTP sessions on server
          minimum: 1
          maximum: 50
          default: 8
        path:
          type: string
          description: path to directory with images
        prefix:
          $ref: '#/components/schemas/prefix_schema'
        postfix:
          $ref: '#/components/schemas/postfix_schema'
      required: [host]

    ftp_reference_required:
      allOf:
        - $ref: '#/components/schemas/ftp_reference'
        - required: [host, port, max_sessions, path]

    ftp_authorization:
      type: object
      description: FTP authorization
      properties:
        user:
          type: string
          description: ftp server user
          default: anonymous
        password:
          type: string
          description: ftp server password
          default: anonymous

    estimator_ftp_server_data:
      type: object
      description: ftp server
      properties:
        source_type:
          type: string
          enum: ["ftp"]
          description: data type where images are located
        reference:
          $ref: '#/components/schemas/ftp_reference'
        authorization:
          $ref: '#/components/schemas/ftp_authorization'
        recursive:
          type: boolean
          default: true
          description: whether to estimate images from ftp subdirectories recursively
      required: [reference]

    estimator_ftp_server_data_required:
      allOf:
        - $ref: '#/components/schemas/estimator_ftp_server_data'
        - properties:
            reference:
              $ref: '#/components/schemas/ftp_reference_required'
        - required: [source_type, reference, recursive]

    follow_links:
      type: boolean
      default: false
      description: whether follow file system links

    network_disk_reference:
      type: object
      description: network disk reference
      properties:
        path:
          type: string
          description: absolute mounted directory path
        prefix:
          $ref: '#/components/schemas/prefix_schema'
        postfix:
          $ref: '#/components/schemas/postfix_schema'
        follow_links:
          $ref: '#/components/schemas/follow_links'
      required: [path]

    estimator_mounted_network_path:
      type: object
      description: mounted network disk
      properties:
        source_type:
          type: string
          enum: ["network_disk"]
          description: Network disk source must be configured properly. See luna-tasks development manual for more information
        reference:
          $ref: '#/components/schemas/network_disk_reference'
        recursive:
          type: boolean
          default: true
          description: whether to estimate images from bucket subdirectories recursively
      required: [reference]

    estimator_mounted_network_path_required:
      allOf:
        - $ref: '#/components/schemas/estimator_mounted_network_path'
        - required: [source_type, reference, recursive]

    s3_reference:
      type: object
      description: s3-like storage reference
      properties:
        endpoint:
          type: string
          description: storage endpoint
          format: uri
        bucket_name:
          type: string
          description: |
            one of the following options:<ul>
            <li>raw bucket name (in this case, `endpoint` must be specified)</li>
            <li>access point ARN (in this case, `endpoint` and `region` must not be specified)
            (see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html">aws userguide</a> for details)</li>
            <li>outpost ARN (in this case, `endpoint` and `region` must not be specified)
            (see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html">aws userguide</a> for details)</li>
            </ul>
        prefix:
          type: string
          description: |
            file key prefix, also can be used to download from specific folder
            (see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-prefixes.html"> aws userguide</a> for details)
        region:
          type: string
          description: bucket region
      required: [bucket_name]

    s3_authorization:
      type: object
      description: s3-like authorization
      properties:
        public_access_key:
          type: string
          description: public access key
        secret_access_key:
          type: string
          description: secret access key
        signature_version:
          type: string
          enum: [ s3v2, s3v4 ]
          default: s3v4
          description: authorization signature version
        verify_ssl:
          type: boolean
          default: true
          description: enable ssl certificate verification
      required: [public_access_key, secret_access_key]

    s3_authorization_required:
      allOf:
        - $ref: '#/components/schemas/s3_authorization'
        - required: [public_access_key, secret_access_key, signature_version]

    estimator_authorization_s3_like_storage:
      type: object
      description: s3-like storages auth data
      properties:
        source_type:
          type: string
          enum: ["s3"]
          description: data type where images are located
        reference:
          $ref: '#/components/schemas/s3_reference'
        authorization:
          $ref: '#/components/schemas/s3_authorization'
        recursive:
          type: boolean
          default: true
          description: whether to estimate images from bucket subdirectories recursively
        save_origin:
          type: boolean
          default: true
          description: whether to save image origin
      required: [reference]

    estimator_authorization_s3_like_storage_required:
      allOf:
        - $ref: "#/components/schemas/estimator_authorization_s3_like_storage"
        - properties:
            reference:
              $ref: '#/components/schemas/s3_reference'
            authorization:
              $ref: '#/components/schemas/s3_authorization_required'
        - required: [source_type, reference, recursive, save_origin]

    estimator_source_with_option_s3bucket:
      allOf:
        - $ref: '#/components/schemas/estimator_authorization_s3_like_storage'
        - $ref: '#/components/schemas/base_estimator_task_content_source'

    estimator_source_with_option_s3bucket_required:
      allOf:
        - $ref: '#/components/schemas/estimator_authorization_s3_like_storage_required'
        - $ref: '#/components/schemas/base_estimator_task_content_source_required'

    estimator_task_content_handler:
      description: |
        handler for estimator task.

        You can create a new static handler and specify policies for it or specify an existing static or dynamic handler. For the existing dynamic handler, you can specify policies.

        The same dynamic handler can be used in different estimator tasks, and it is not required to create a new handler for each task.
      oneOf:
        - $ref: '#/components/schemas/new_handler_task_estimator'
        - $ref: '#/components/schemas/existing_handler_task_estimator'

    estimator_task_content_filters:
      type: object
      description: estimator filters
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'
      required: [account_id]

    estimator_task_content_source:
      description: images source
      oneOf:
        - $ref: '#/components/schemas/estimator_source_with_option_zip'
        - $ref: '#/components/schemas/estimator_source_with_option_s3bucket'
        - $ref: '#/components/schemas/estimator_source_with_option_network_disk'
        - $ref: '#/components/schemas/estimator_source_with_option_ftp'
        - $ref: '#/components/schemas/estimator_source_with_option_samba'
      discriminator:
        propertyName: "source_type"
        mapping:
          zip: '#/components/schemas/estimator_source_with_option_zip'
          s3: '#/components/schemas/estimator_source_with_option_s3bucket'
          network_disk: '#/components/schemas/estimator_source_with_option_network_disk'
          ftp: '#/components/schemas/estimator_source_with_option_ftp'
          samba: '#/components/schemas/estimator_source_with_option_samba'

    estimator_task_content_source_schedulable:
      description: images source
      oneOf:
        - $ref: '#/components/schemas/estimator_source_with_option_s3bucket'
        - $ref: '#/components/schemas/estimator_source_with_option_network_disk'
        - $ref: '#/components/schemas/estimator_source_with_option_ftp'
        - $ref: '#/components/schemas/estimator_source_with_option_samba'
      discriminator:
        propertyName: "source_type"
        mapping:
          s3: '#/components/schemas/estimator_source_with_option_s3bucket'
          network_disk: '#/components/schemas/estimator_source_with_option_network_disk'
          ftp: '#/components/schemas/estimator_source_with_option_ftp'
          samba: '#/components/schemas/estimator_source_with_option_samba'

    estimator_task_content_source_required:
      description: images source
      oneOf:
        - $ref: '#/components/schemas/estimator_source_with_option_zip_required'
        - $ref: '#/components/schemas/estimator_source_with_option_s3bucket_required'
        - $ref: '#/components/schemas/estimator_source_with_option_network_disk_required'
        - $ref: '#/components/schemas/estimator_source_with_option_ftp_required'
        - $ref: '#/components/schemas/estimator_source_with_option_samba_required'
      discriminator:
        propertyName: "source_type"
        mapping:
          zip: '#/components/schemas/estimator_source_with_option_zip_required'
          s3: '#/components/schemas/estimator_source_with_option_s3bucket_required'
          network_disk: '#/components/schemas/estimator_source_with_option_network_disk_required'
          ftp: '#/components/schemas/estimator_source_with_option_ftp_required'
          samba: '#/components/schemas/estimator_source_with_option_samba_required'

    estimator_task_content:
      type: object
      description: estimator task content
      properties:
        handler:
          $ref: '#/components/schemas/estimator_task_content_handler'
        source:
          $ref: '#/components/schemas/estimator_task_content_source'
        filters:
          $ref: '#/components/schemas/estimator_task_content_filters'
      required: [handler, source, filters]

    estimator_task_content_for_schedule:
      type: object
      description: estimator task content
      properties:
        handler:
          $ref: '#/components/schemas/estimator_task_content_handler'
        source:
          $ref: '#/components/schemas/estimator_task_content_source_schedulable'
        filters:
          $ref: '#/components/schemas/estimator_task_content_filters'
      required: [handler, source, filters]

    estimator_content_props:
      type: object
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type_schedulable"
          enum: [9]
        content:
          $ref: '#/components/schemas/estimator_task_content_for_schedule'

    schedule_estimator_task_content_request:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_request"
        - $ref: "#/components/schemas/estimator_content_props"

    schedule_estimator_task_content_response:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_response"
        - $ref: "#/components/schemas/estimator_content_props"


    estimator_task_content_required:
      type: object
      description: estimator task content
      properties:
        handler:
          $ref: '#/components/schemas/estimator_task_content_handler'
        source:
          $ref: '#/components/schemas/estimator_task_content_source_required'
        filters:
          $ref: '#/components/schemas/estimator_task_content_filters'
      required: [handler, source, filters]

    estimator_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/estimator_task_content'

    lambda_task_content:
      type: object
      description: lambda task content
      properties:
        lambda_id:
          type: string
          description: lambda task id
      required: [lambda_id]
      additionalProperties:
        x-additionalPropertiesName: lambda task content fields
        description: Fields define by lambda task creator.

    lambda_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/lambda_task_content'

    schedule_lambda_task_props:
      type: object
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type_schedulable"
          enum: [ 10 ]
        content:
          $ref: '#/components/schemas/lambda_task_content'

    schedule_lambda_task_content_request:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_request"
        - $ref: "#/components/schemas/schedule_lambda_task_props"

    schedule_lambda_task_content_response:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_response"
        - $ref: "#/components/schemas/schedule_lambda_task_props"

    gc_task_content_reply:
      oneOf:
        - $ref: '#/components/schemas/gc_face_descriptors_task_content'
        - $ref: '#/components/schemas/gc_faces_task_content_reply'
        - $ref: '#/components/schemas/gc_event_descriptors_task_content'
        - $ref: '#/components/schemas/gc_events_task_content_reply'
      discriminator:
        propertyName: "target"
        mapping:
          face_descriptors: '#/components/schemas/gc_face_descriptors_task_content'
          faces: '#/components/schemas/gc_faces_task_content_reply'
          event_descriptors: '#/components/schemas/gc_event_descriptors_task_content'
          events: '#/components/schemas/gc_events_task_content_reply'

    gc_task_content:
      oneOf:
        - $ref: '#/components/schemas/gc_face_descriptors_task_content'
        - $ref: '#/components/schemas/gc_faces_task_content'
        - $ref: '#/components/schemas/gc_event_descriptors_task_content'
        - $ref: '#/components/schemas/gc_events_task_content'
      discriminator:
        propertyName: "target"
        mapping:
          face_descriptors: '#/components/schemas/gc_face_descriptors_task_content'
          faces: '#/components/schemas/gc_faces_task_content'
          event_descriptors: '#/components/schemas/gc_event_descriptors_task_content'
          events: '#/components/schemas/gc_events_task_content'

    gc_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/gc_task_content'

    gc_face_descriptors_task_content:
      description: Garbage collecting task content to delete face descriptors by version.
      type: object
      properties:
        target:
          type: string
          enum: ['face_descriptors']
        filters:
          type: object
          properties:
            descriptor_version:
              description: version of descriptors to delete
              type: integer
          required: [descriptor_version]
        store_results:
          type: boolean
          description: Whether to store task results. Whatever, task errors are stored.
          default: true
      required: [target, filters]

    gc_faces_task_content_no_filters:
      description: Garbage collecting task content to delete faces by extended filters.
      type: object
      properties:
        target:
          type: string
          enum: ['faces']
        filters:
          type: object
          properties:
            account_id:
              $ref: '#/components/schemas/account_id'
            user_data:
              $ref: '#/components/schemas/user_data'
            list_id:
              allOf:
                - $ref: '#/components/schemas/uuid'
              description: list id.
              example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'
        store_results:
          type: boolean
          description: Whether to store task results. Whatever, task errors are stored.
          default: true
        remove_samples:
          type: boolean
          description: |
            Whether to remove face descriptor and basic attributes samples along with the face.
          default: false

    gc_faces_task_content:
      allOf:
        - $ref: '#/components/schemas/gc_faces_task_content_no_filters'
      properties:
        filters:
          type: object
          properties:
            create_time__lt:
              description: Create time lower included boundary.
              oneOf:
                - $ref: '#/components/schemas/create_time__lt'
                - $ref: '#/components/schemas/create_time_now__lt'
            create_time__gte:
              description: Create time lower included boundary.
              oneOf:
                - $ref: '#/components/schemas/create_time__gte'
                - $ref: '#/components/schemas/create_time_now__gte'
      required: [ target, filters ]

    gc_faces_task_content_schedule:
      allOf:
        - $ref: '#/components/schemas/gc_faces_task_content_no_filters'
      properties:
        filters:
          type: object
          properties:
            create_time__lt:
              description: Create time lower included boundary.
              $ref: '#/components/schemas/create_time_now__lt'
            create_time__gte:
              description: Create time lower included boundary.
              $ref: '#/components/schemas/create_time_now__gte'
      required: [ target, filters ]

    gc_faces_task_content_reply:
      allOf:
        - $ref: '#/components/schemas/gc_faces_task_content_no_filters'
      properties:
        filters:
          type: object
          properties:
            create_time__lt:
              description: Create time lower included boundary.
              $ref: '#/components/schemas/create_time__lt'
            create_time__gte:
              description: Create time lower included boundary.
              $ref: '#/components/schemas/create_time__gte'
      required: [ target, filters ]

    gc_event_descriptors_task_content:
      description: Garbage collecting task content to delete event descriptors by version and type.
      type: object
      properties:
        target:
          type: string
          enum: [ event_descriptors ]
        filters:
          type: object
          properties:
            descriptor_version:
              description: Descriptors version.
              type: integer
            descriptor_type:
              description: Descriptors type.
              type: string
              enum: ['face', 'body']
          required: [descriptor_version, descriptor_type]
        store_results:
          type: boolean
          description: Whether to store task results. Whatever, task errors are stored.
          default: true
      required: [target, filters]

    gc_events_task_content_no_filters:
      description: garbage collecting task content to remove events
      type: object
      properties:
        target:
          type: string
          enum: ['events']
        filters:
          type: object
          properties:
            account_id:
              allOf:
                - $ref: '#/components/schemas/uuid'
              description: account id to execute task within the specified account.
            handler_id:
              allOf:
                - $ref: '#/components/schemas/uuid'
              description: handler id to execute task within the handler.
        store_results:
          type: boolean
          description: Whether to store task results. Whatever, task errors are stored.
          default: true
        remove_samples:
          type: boolean
          description: |
            Whether to remove face and body samples along with the event.

            > **WARNING**: After removing samples, it will become impossible to re-extract the attribute or descriptor for the created face.
          default: false
        remove_image_origins:
          type: boolean
          description: |
            Whether to remove origin images.
            In case url of the image origin points to external image task tries to remove it by performing DELETE request to the image url.

            > **WARNING**: Some images may belong to multiple events simultaneously.

          default: false
      required: [target]

    gc_events_task_content:
      allOf:
        - $ref: '#/components/schemas/gc_events_task_content_no_filters'
      properties:
        filters:
          type: object
          properties:
            create_time__lt:
              description: Create time upper excluded boundary.
              oneOf:
                - $ref: '#/components/schemas/create_time__lt'
                - $ref: '#/components/schemas/create_time_now__lt'
            insert_time__lt:
              description: Insert time upper excluding boundary.
              oneOf:
                - $ref: '#/components/schemas/insert_time__lt'
                - $ref: '#/components/schemas/insert_time_now__lt'

    gc_events_task_content_schedule:
      allOf:
        - $ref: '#/components/schemas/gc_events_task_content_no_filters'
      properties:
        filters:
          type: object
          properties:
            create_time__lt:
              description: Create time upper excluded boundary.
              $ref: '#/components/schemas/create_time_now__lt'
            insert_time__lt:
              description: Insert time upper excluding boundary.
              $ref: '#/components/schemas/insert_time_now__lt'

    gc_events_task_content_reply:
      allOf:
        - $ref: '#/components/schemas/gc_events_task_content_no_filters'
      properties:
        filters:
          type: object
          properties:
            create_time__lt:
              description: Create time upper excluded boundary.
              $ref: '#/components/schemas/create_time__lt'
            insert_time__lt:
              description: Insert time upper excluding boundary.
              $ref: '#/components/schemas/insert_time__lt'

    clustering_task:
      anyOf:
        - $ref: '#/components/schemas/event_clustering_task'
        - $ref: '#/components/schemas/face_clustering_task'

    event_clustering_task_params:
      type: object
      description: additional task parameters
      properties:
        use_track_info:
          type: integer
          enum: [0, 1]
          default: 0
          description: whether to place events with equal track_id in the same clusters

    clustering_task_content_template:
      description: Clustering task content
      type: object
      properties:
        threshold:
          description: The minimum acceptable degree of similarity. If the similarity of two descriptors exceeds the specified value, it is considered that they belong to the same person. In this case, both descriptors are added to the same cluster.
          type: number
          format: float
          maximum: 1
          minimum: 0
          example: 0.5
          default: 0.81
        descriptor:
          $ref: '#/components/schemas/descriptor_info'
        limit:
          $ref: '#/components/schemas/clustering_limit'
      required: [objects_type, filters]

    clustering_task_content_events:
      allOf:
        - $ref: '#/components/schemas/clustering_task_content_template'
      description: Events clustering task content
      properties:
        objects_type:
          enum: [ events ]
        filters:
          $ref: '#/components/schemas/events_filters_limited_optional_account'
        params:
          $ref: '#/components/schemas/event_clustering_task_params'

    clustering_task_content_events_regular_create_time:
      allOf:
        - $ref: '#/components/schemas/clustering_task_content_template'
      description: Events clustering task content
      properties:
        objects_type:
          enum: [ events ]
        filters:
          allOf:
            - $ref: '#/components/schemas/events_filters_no_account_limited_reply'
          properties:
            account_id:
              $ref: '#/components/schemas/account_id'
        params:
          $ref: '#/components/schemas/event_clustering_task_params'

    event_clustering_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/clustering_task_content_events'

    clustering_task_content_faces:
      allOf:
        - $ref: '#/components/schemas/clustering_task_content_template'
      description: Faces clustering task content
      properties:
        objects_type:
          enum: [ faces ]
        filters:
          $ref: '#/components/schemas/faces_filters_limited_optional_account'

    clustering_task_content_faces_regular_create_time:
      allOf:
        - $ref: '#/components/schemas/clustering_task_content_template'
      description: Faces clustering task content
      properties:
        objects_type:
          enum: [ faces ]
        filters:
          allOf:
            - $ref: '#/components/schemas/faces_filters_no_create_time'
          type: object
          properties:
            create_time__gte:
              description: Create time lower included boundary.
              $ref: '#/components/schemas/create_time__gte'
            create_time__lt:
              description: Create time upper excluded boundary.
              $ref: '#/components/schemas/create_time__lt'
            account_id:
              $ref: '#/components/schemas/account_id'
            face_ids:
              maxItems: 20000
            external_ids:
              maxItems: 1000

    face_clustering_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/clustering_task_content_faces'

    clustering_task_content:
      description: Clustering task content
      oneOf:
        - $ref: '#/components/schemas/clustering_task_content_faces'
        - $ref: '#/components/schemas/clustering_task_content_events'
      discriminator:
        propertyName: objects_type
        mapping:
          faces: '#/components/schemas/clustering_task_content_faces'
          events: '#/components/schemas/clustering_task_content_events'

    clustering_task_content_reply:
      description: Clustering task content
      oneOf:
        - $ref: '#/components/schemas/clustering_task_content_faces_regular_create_time'
        - $ref: '#/components/schemas/clustering_task_content_events_regular_create_time'
      discriminator:
        propertyName: objects_type
        mapping:
          faces: '#/components/schemas/clustering_task_content_faces_regular_create_time'
          events: '#/components/schemas/clustering_task_content_events_regular_create_time'

    ae_face_filters:
      description: face filters.
      type: object
      properties:
        objects_type:
          description: object type.
          type: string
          enum: [ "faces" ]
        account_id:
          $ref: '#/components/schemas/account_id'
        face_id__lt:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: upper face id excluding boundary.
        face_id__gte:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: lower face id including boundary.
      required: [ objects_type ]

    ae_event_filters_no_inspect_time:
      description: event filters.
      type: object
      properties:
        objects_type:
          description: object type.
          type: string
          enum: [ "events" ]
        account_id:
          $ref: '#/components/schemas/account_id'
        handler_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: handler id.
        event_id__gte:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: lower event id including boundary.
        event_id__lt:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: upper event id excluding boundary.
      required: [ objects_type ]

    ae_event_filters:
      allOf:
        - $ref: "#/components/schemas/ae_event_filters_no_inspect_time"
      type: object
      properties:
        insert_time__gte:
          description: Insert time upper excluding boundary.
          oneOf:
            - $ref: '#/components/schemas/insert_time__gte'
            - $ref: '#/components/schemas/insert_time_now__gte'
        insert_time__lt:
          description: Insert time upper excluding boundary.
          oneOf:
            - $ref: '#/components/schemas/insert_time__lt'
            - $ref: '#/components/schemas/insert_time_now__lt'

    ae_event_filters_reply:
      allOf:
        - $ref: "#/components/schemas/ae_event_filters_no_inspect_time"
      type: object
      properties:
        insert_time__gte:
          description: Insert time upper excluding boundary.
          $ref: '#/components/schemas/insert_time__gte'
        insert_time__lt:
          description: Insert time upper excluding boundary.
          $ref: '#/components/schemas/insert_time__lt'

    additional_extract_task_content_body_descriptor_no_filters:
      description: additional extract human descriptors task
      type: object
      properties:
        extraction_target:
          description: extraction target
          type: string
          enum: [ "body_descriptor" ]
        options:
          description: extract task options
          type: object
          properties:
            descriptor_version:
              description: version of descriptors to extract
              type: integer
            missing:
              type: boolean
              description: whether to extract only missing descriptors (`false` is not implemented)
              default: true
          required: [ descriptor_version ]

    additional_extract_task_content_body_descriptor:
      allOf:
        - $ref: '#/components/schemas/additional_extract_task_content_body_descriptor_no_filters'
      properties:
        filters:
          allOf:
            - $ref: '#/components/schemas/ae_event_filters'
          description: |
            object filters.
            Body descriptor re-extraction can be performed on events only (see `objects_type` in filters).
      required: [ extraction_target, options, filters ]

    additional_extract_task_content_body_descriptor_reply:
      allOf:
        - $ref: '#/components/schemas/additional_extract_task_content_body_descriptor_no_filters'
      properties:
        filters:
          allOf:
            - $ref: '#/components/schemas/ae_event_filters_reply'
          description: |
            object filters.
            Body descriptor re-extraction can be performed on events only (see `objects_type` in filters).
      required: [ extraction_target, options, filters ]

    additional_extract_task_content_face_descriptor_no_filters:
      description: additional extract face descriptors task
      type: object
      properties:
        extraction_target:
          description: extraction target
          type: string
          enum: ["face_descriptor"]
        options:
          description: extract task options
          type: object
          properties:
            descriptor_version:
              description: version of descriptors to extract
              type: integer
            missing:
              type: boolean
              description: whether to extract only missing descriptors (`false` is not implemented)
              default: true
          required: [descriptor_version]

    additional_extract_task_content_face_descriptor:
      allOf:
        - $ref: '#/components/schemas/additional_extract_task_content_face_descriptor_no_filters'
      properties:
        filters:
          description: |
            object filters.
            Face descriptor re-extraction can be performed on either faces or events (see `objects_type` in filters).
          oneOf:
            - $ref: '#/components/schemas/ae_face_filters'
            - $ref: '#/components/schemas/ae_event_filters'
          discriminator:
            propertyName: objects_type
            mapping:
              faces: '#/components/schemas/ae_face_filters'
              events: '#/components/schemas/ae_event_filters'
      required: [ extraction_target, options, filters ]

    additional_extract_task_content_face_descriptor_reply:
      allOf:
        - $ref: '#/components/schemas/additional_extract_task_content_face_descriptor_no_filters'
      properties:
        filters:
          description: |
            object filters.
            Face descriptor re-extraction can be performed on either faces or events (see `objects_type` in filters).
          oneOf:
            - $ref: '#/components/schemas/ae_face_filters'
            - $ref: '#/components/schemas/ae_event_filters_reply'
          discriminator:
            propertyName: objects_type
            mapping:
              faces: '#/components/schemas/ae_face_filters'
              events: '#/components/schemas/ae_event_filters_reply'
      required: [ extraction_target, options, filters ]

    additional_extract_task_content_basic_attributes_no_filters:
      description: additional extract basic attributes task
      type: object
      properties:
        extraction_target:
          description: extraction target
          type: string
          enum: ["basic_attributes"]
        options:
          type: object
          description: extract task options
          properties:
            missing:
              type: boolean
              description: whether to extract only missing basic attributes (`false` is not implemented)
              default: true

    additional_extract_task_content_basic_attributes:
      allOf:
        - $ref: '#/components/schemas/additional_extract_task_content_basic_attributes_no_filters'
      properties:
        filters:
          description: |
            object filters.
            Basic attributes re-extraction can be performed on either faces or events (see `objects_type` in filters).
          oneOf:
            - $ref: '#/components/schemas/ae_face_filters'
            - $ref: '#/components/schemas/ae_event_filters'
          discriminator:
            propertyName: objects_type
            mapping:
              faces: '#/components/schemas/ae_face_filters'
              events: '#/components/schemas/ae_event_filters'
      required: [ extraction_target, filters ]

    additional_extract_task_content_basic_attributes_reply:
      allOf:
        - $ref: '#/components/schemas/additional_extract_task_content_basic_attributes_no_filters'
      properties:
        filters:
          description: |
            object filters.
            Basic attributes re-extraction can be performed on either faces or events (see `objects_type` in filters).
          oneOf:
            - $ref: '#/components/schemas/ae_face_filters'
            - $ref: '#/components/schemas/ae_event_filters_reply'
          discriminator:
            propertyName: objects_type
            mapping:
              faces: '#/components/schemas/ae_face_filters'
              events: '#/components/schemas/ae_event_filters_reply'
      required: [ extraction_target, options, filters ]

    additional_extract_task_content:
      description: additional extractor task content.
      oneOf:
        - $ref: '#/components/schemas/additional_extract_task_content_basic_attributes'
        - $ref: '#/components/schemas/additional_extract_task_content_face_descriptor'
        - $ref: '#/components/schemas/additional_extract_task_content_body_descriptor'
      discriminator:
        propertyName: extraction_target
        mapping:
          basic_attributes: '#/components/schemas/additional_extract_task_content_basic_attributes'
          face_descriptor: '#/components/schemas/additional_extract_task_content_face_descriptor'
          body_descriptor: '#/components/schemas/additional_extract_task_content_body_descriptor'

    additional_extract_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/additional_extract_task_content'

    gc_descriptors_task_result:
      description: faces whoes descriptors was removed
      type: array
      items:
        allOf:
          - $ref: '#/components/schemas/uuid'
        description: face id whoes descriptor was removed

    gc_events_task_result:
      description: removed events
      type: array
      items:
        description: removed event
        type: object
        properties:
          event_id:
            description: removed event id.
            allOf:
              - $ref: '#/components/schemas/uuid'
          samples:
            description: sample ids of the removed face attribute from events.
            type: array
            items:
              $ref: '#/components/schemas/uuid'
          image_origins:
            description: removed image origins.
            type: array
            items:
              type: string
              example: '/6/images/557d54ec-29ad-4f3c-93b4-c9092ef12515'
        required: [event_id]

    gc_faces_task_result:
      description: removed faces
      type: array
      items:
        description: removed face
        type: object
        properties:
          face_id:
            description: removed face id
            allOf:
              - $ref: '#/components/schemas/uuid'
          basic_attributes_samples:
            description: sample ids of the removed basic attributes samples of the face
            type: array
            items:
              $ref: '#/components/schemas/uuid'
          face_descriptor_samples:
            description: sample ids of the removed face descriptors samples of the face
            type: array
            items:
              $ref: '#/components/schemas/uuid'
        required: [face_id]

    gc_task_result:
      description: Garbage Collecting task result
      type: object
      properties:
        result:
          anyOf:
            - $ref: '#/components/schemas/gc_descriptors_task_result'
            - $ref: '#/components/schemas/gc_events_task_result'
            - $ref: '#/components/schemas/gc_faces_task_result'
        errors:
          $ref: '#/components/schemas/task_errors'
      required: [errors]

    linker_task_result:
      description: Linking task result
      type: object
      properties:
        result:
          type: object
          description: linker task result
          properties:
            list_id:
              allOf:
              - $ref: '#/components/schemas/uuid'
              description: list id
            face_ids:
              description: linked faces' ids
              type: array
              items:
                $ref: '#/components/schemas/uuid'
        errors:
          $ref: '#/components/schemas/task_errors'
      required: [errors]

    clustering_task_result:
      description: Clustering task result
      type: object
      properties:
        result:
          description: clustering result
          type: object
          properties:
            clusters:
              description: generated clusters - lists of objects ids
              type: array
              items:
                description: single cluster - list of objects' ids
                type: array
                items:
                  $ref: '#/components/schemas/uuid'
            total_objects:
              type: integer
              description: total objects count.
              example: 1
            total_clusters:
              type: integer
              description: total clusters count.
              example: 1
          required: [clusters, total_objects, total_clusters]
        errors:
          $ref: '#/components/schemas/task_errors'
      required: [errors]

    rect:
      description: bounding rectangle.
      type: object
      properties:
        height:
          type: integer
          description: rectangle height.
        width:
          type: integer
          description: rectangle width.
        x:
          type: integer
          description: top left corner "x" coordinate.
        y:
          type: integer
          description: top left corner "y" coordinate.
      required: [ height, width, x, y ]
    body_detection:
      type: object
      description: body detection
      properties:
        rect:
          allOf:
            - $ref: '#/components/schemas/rect'
            - description: body detection bounding box.

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

    longitude:
      type: number
      minimum: -180
      maximum: 180
      description: longitude in degrees

    latitude:
      type: number
      minimum: -90
      maximum: 90
      description: latitude in degrees

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

    location:
      type: object
      description: information about a place where event is incidented
      properties:
        city:
          allOf:
            - $ref: '#/components/schemas/string36'
            - nullable: true
            - description: city
        area:
          allOf:
            - $ref: '#/components/schemas/string36'
            - nullable: true
            - description: area
        district:
          allOf:
            - $ref: '#/components/schemas/string36'
            - nullable: true
            - description: district
        street:
          allOf:
            - $ref: '#/components/schemas/string36'
            - nullable: true
            - description: street
        house_number:
          allOf:
            - $ref: '#/components/schemas/string36'
            - nullable: true
            - description: house number
        geo_position:
          allOf:
            - $ref: '#/components/schemas/location_geo_position'
            - nullable: true
            - description: geo coordinates

    event_from_handler:
      type: object
      description: event format from handler.
      additionalProperties:
        x-additionalPropertiesName: handler_event
        description: |
          A generated event from handler. See the Luna Handlers documentation section for
          details - "generate events".

    success_estimator_result:
      description: Estimator task result
      type: array
      items:
        type: object
        properties:
          filename:
            type: string
            description: source image file name
          result:
            type: object
            description: image estimation result
            nullable: true
            properties:
              events:
                type: array
                items:
                  $ref: '#/components/schemas/event_from_handler'
              filtered_detections:
                type: object
                additionalProperties:
                  x-additionalPropertiesName: filtered_detections
                  description: |
                    Filtered detections on the image. See the Luna Handlers documentation section for details -
                    "generate events".
                required: [ face_detections ]
            required: [events, filtered_detections]
          errors:
            $ref: '#/components/schemas/task_handler_errors'
        required: [filename, result, errors]

    estimator_task_result:
      type: object
      description: Estimator task result
      properties:
        result:
          $ref: '#/components/schemas/success_estimator_result'
        errors:
          $ref: '#/components/schemas/task_errors'
      required: [errors]

    reporter_task_content_without_filters:
      type: object
      description: reporter task content
      properties:
        columns:
          description: Column targets in CSV report. Order of fields determinates the order columns in report.
          anyOf:
            - $ref: '#/components/schemas/report_event_columns'
            - $ref: '#/components/schemas/report_face_columns'
          example: [ "face_id", "user_data", "create_time" ]
        csv_delimiter:
          default: ','
          type: string
          description: csv delimiter
          maxLength: 1
          minLength: 1
          example: '$'
        save_images:
          type: integer
          default: 0
          enum: [ 0, 1 ]
          description: whether to save images in the result

    reporter_task_content:
      allOf:
        - $ref: '#/components/schemas/reporter_task_content_without_filters'
        - properties:
            filters:
              type: object
              description: reporter task filters
              properties:
                account_id:
                  $ref: '#/components/schemas/account_id'
                task_id:
                  description: id of task
                  type: integer
                  example: 146
              required: [ task_id ]
      required: [ filters ]

    report_event_columns:
      type: array
      items:
        description: |
          event columns
        type: string
        enum: ["event_id", "create_time", "end_time", "external_id", "handler_id", "stream_id", "source", "top_match",
               "match_result", "face_detections", "body_detections", "face_id", "attach_result", "gender", "age",
               "emotion", "ethnic_group", "tags", "user_data", "city", "area", "district", "street", "house_number",
               "geo_position", "mask", "track_id", "liveness", "deepfake", "body_basic_attributes", "upper_body",
               "lower_body", "accessories", "meta"]
      default: ["event_id","create_time", "end_time", "external_id", "handler_id", "stream_id", "source", "top_match",
                "face_id", "gender", "age", "emotion", "ethnic_group", "user_data", "city", "area", "district",
                "street", "house_number", "geo_position", "mask", "track_id", "liveness", "deepfake",
                "body_basic_attributes", "upper_body", "lower_body", "accessories", "meta"]

    report_face_columns:
      type: array
      items:
        description: face columns.
        type: string
        enum: ["user_data", "create_time", "lists", "external_id", "avatar", "event_id"]
      default: ["user_data", "create_time", "external_id", "avatar", "event_id"]

    reporter_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/reporter_task_content'

    exporter_event_columns:
      type: array
      items:
        description: |
          event columns. default is
          ["event_id", "create_time", "end_time", "external_id", "handler_id", "stream_id", "source", "top_match",
           "face_id", "gender", "age", "emotion", "ethnic_group", "user_data", "city", "area", "district",
           "street", "house_number", "geo_position", "mask", "track_id", "liveness", "deepfake", "body_basic_attributes", 
           "upper_body", "lower_body", "accessories", "meta"]
        type: string
        enum: ["event_id", "create_time", "external_id", "handler_id", "stream_id", "source", "top_match", "match_result",
               "face_detections", "face_id", "attach_result", "gender", "end_time",
               "age", "emotion", "ethnic_group", "tags", "user_data", "city", "area", "district", "street",
               "house_number", "geo_position", "body_detections", "mask", "track_id", "liveness", "deepfake",
               "body_basic_attributes", "upper_body", "lower_body", "accessories", "meta"
               ]

    exporter_face_columns:
      type: array
      items:
        description: face columns. default is ["face_id", "user_data", "create_time", "external_id", "avatar", "event_id"]
        type: string
        enum: ["face_id", "user_data", "create_time", "lists", "external_id", "avatar", "event_id"]

    exporter_task_content_no_filters:
      type: object
      description: exporter task content
      properties:
        objects_type:
          $ref: '#/components/schemas/objects_type'

        columns:
          description: colum names in csv report. Order of fields determinates the order columns in report.
          anyOf:
            - $ref: '#/components/schemas/exporter_event_columns'
            - $ref: '#/components/schemas/exporter_face_columns'
          example: [ "face_id", "user_data", "create_time" ]

        descriptor:
          $ref: '#/components/schemas/descriptor_info'

        csv_delimiter:
          default: ','
          type: string
          description: csv delimiter
          maxLength: 1
          minLength: 1
          example: '$'

        save_images:
          type: integer
          default: 0
          enum: [ 0, 1 ]
          description: whether to add images to the resulting archive

      required: [ filters, objects_type ]

    exporter_task_content:
      allOf:
        - $ref: "#/components/schemas/exporter_task_content_no_filters"
      type: object
      properties:
        filters:
          description: exporter task filters
          anyOf:
            - $ref: '#/components/schemas/events_filters'
            - $ref: '#/components/schemas/faces_filters'

    exporter_task_content_reply:
      allOf:
        - $ref: "#/components/schemas/exporter_task_content_no_filters"
      type: object
      properties:
        filters:
          description: exporter task filters
          anyOf:
            - $ref: '#/components/schemas/faces_filters_regular_create_time'
            - $ref: '#/components/schemas/events_filters_regular_create_time'

    exporter_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/exporter_task_content'

    face_additional_extract_result:
      type: object
      properties:
        face_id:
          description: extracted attribute face id.
          allOf:
            - $ref: '#/components/schemas/uuid'
        samples:
          description: sample ids used for extraction
          type: array
          items:
            $ref: '#/components/schemas/uuid'
      required: [face_id, samples]

    event_additional_extract_result:
      type: object
      properties:
        event_id:
          description: extracted attribute event id.
          allOf:
            - $ref: '#/components/schemas/uuid'
        samples:
          description: sample ids used for extraction
          type: array
          items:
            $ref: '#/components/schemas/uuid'
      required: [event_id, samples]

    additional_extract_task_result:
      description: Additional extract task result
      type: object
      properties:
        result:
          description: additional extract result
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/event_additional_extract_result'
              - $ref: '#/components/schemas/face_additional_extract_result'
        errors:
          $ref: '#/components/schemas/task_errors'
      required: [errors]

    cross_match_task_reference_filters:
      description: Object filters for references.
      anyOf:
        - $ref: '#/components/schemas/faces_filters_no_account_limited'
        - $ref: '#/components/schemas/events_filters_no_account_limited'
        - $ref: '#/components/schemas/attributes_filters_no_account_limited'

    cross_match_task_reference_filters_reply:
      description: Object filters for references.
      anyOf:
        - $ref: '#/components/schemas/faces_filters_no_account_limited_reply'
        - $ref: '#/components/schemas/events_filters_no_account_limited_reply'
        - $ref: '#/components/schemas/attributes_filters_no_account_limited'

    cross_match_task_candidate_filters:
      description: Object filters for candidates.
      anyOf:
        - $ref: '#/components/schemas/faces_filters_no_account_limited'
        - $ref: '#/components/schemas/events_filters_no_account_limited'
        - $ref: '#/components/schemas/attributes_filters_no_account_limited'

    cross_match_task_candidate_filters_reply:
      description: Object filters for candidates.
      anyOf:
        - $ref: '#/components/schemas/faces_filters_no_account_limited_reply'
        - $ref: '#/components/schemas/events_filters_no_account_limited_reply'
        - $ref: '#/components/schemas/attributes_filters_no_account_limited'

    cross_match_task_content_no_filters:
      type: object
      description: cross match task content
      properties:
        filters:
          description: Task objects' filters.
          type: object
          properties:
            reference_type:
              $ref: '#/components/schemas/common_objects_type'
            candidate_type:
              $ref: '#/components/schemas/common_objects_type'
            descriptor:
              $ref: '#/components/schemas/descriptor_info'
            account_id:
              allOf:
                - $ref: '#/components/schemas/uuid'
              description: account ID filter for task objects.
          required: [ reference_type, candidate_type, reference_filters, candidate_filters ]
        threshold:
          description: The minimum acceptable degree of similarity. If the similarity of two descriptors falls behind the specified value, the match will be ignored. References with all filtered matches also will be ignored.
          type: number
          format: float
          maximum: 1
          minimum: 0
          example: 0.5
          default: 0.0
        limit:
          $ref: '#/components/schemas/limit'
      required: [ filters ]

    cross_match_task_content:
      allOf:
        - $ref: '#/components/schemas/cross_match_task_content_no_filters'
      properties:
        filters:
          type: object
          properties:
            reference_filters:
              $ref: '#/components/schemas/cross_match_task_reference_filters'
            candidate_filters:
              $ref: '#/components/schemas/cross_match_task_candidate_filters'
          required: [ reference_filters, candidate_filters ]

    cross_match_task_content_reply:
      allOf:
        - $ref: '#/components/schemas/cross_match_task_content_no_filters'
      properties:
        filters:
          type: object
          properties:
            reference_filters:
              $ref: '#/components/schemas/cross_match_task_reference_filters_reply'
            candidate_filters:
              $ref: '#/components/schemas/cross_match_task_candidate_filters_reply'
          required: [ reference_filters, candidate_filters ]

    cross_match_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/cross_match_task_content'

    cross_match_task_result:
      description: Cross Match task result
      type: object
      properties:
        result:
          description: cross match task result
          type: array
          items:
            type: object
            properties:
              reference_id:
                description: reference id (see reference_type field in cross_match_task filters).
                allOf:
                  - $ref: '#/components/schemas/uuid'
              candidates:
                description: match candidates for the reference
                type: array
                items:
                  type: object
                  description: match with a candidate
                  properties:
                    candidate_id:
                      description: candidate id (see candidate_type field in cross_match_task filters)
                      allOf:
                        - $ref: '#/components/schemas/uuid'
                    similarity:
                      description: similatrity for the reference-candidate pair
                      type: number
                      minimum: 0
                      maximum: 1
                      example: 1
                  required: [candidate_id, similarity]
                minItems: 1
            required: [reference_id, candidates]
        errors:
          $ref: '#/components/schemas/task_errors'
      required: [errors]

    markup_face_items:
      type: object
      properties:
        face_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: face id.
        label:
          type: integer
          description: face label (group id)
          example: 12
      required: [face_id, label]

    markup_attribute_items:
      type: object
      properties:
        attribute_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: attribute id.
        label:
          type: integer
          description: face attribute label (group id)
          example: 12
      required: [attribute_id, label]

    roc_task_content:
      description: roc task content.
      type: object
      properties:
        markup:
          description: markup of face ids to labels (group ids).
          type: array
          minItems: 2
          maxItems: 20000
          items:
            oneOf:
              - $ref: '#/components/schemas/markup_face_items'
              - $ref: '#/components/schemas/markup_attribute_items'
        filters:
          description: task objects' filters.
          type: object
          properties:
            account_id:
              allOf:
                - $ref: '#/components/schemas/uuid'
              description: account id filter for a task objects.
        threshold_hit_top:
          allOf:
            - $ref: '#/components/schemas/float10'
          description: similarity threshold to calculate hit into the top-N.
          example: 0.95
          default: 0
        limit:
          $ref: '#/components/schemas/limit'
        key_FPRs:
          description: roc-curve key FPR values
          type: array
          items:
            $ref: '#/components/schemas/float10'
          example: [ 0.000001, 0.001 ]
      required: [ markup, filters ]

    roc_task:
      allOf:
        - $ref: '#/components/schemas/task_base'
        - properties:
            content:
              $ref: '#/components/schemas/roc_task_content'

    roc_points:
      type: object
      properties:
        FPR:
          allOf:
            - $ref: '#/components/schemas/float10'
          description: false positive rate.
        TPR:
          allOf:
            - $ref: '#/components/schemas/float10'
          description: true positive rate.
        similarity:
          allOf:
            - $ref: '#/components/schemas/float10'
          description: similatrity threshold.
      required: [FPR, TPR, similarity]

    roc_task_result:
      description: roc task result.
      type: object
      properties:
        result:
          description: roc-curve calculation result.
          type: object
          properties:
            roc:
              type: array
              items:
                $ref: '#/components/schemas/roc_points'
              description: roc-curve points.
              example:
               - FPR: 0.1
                 TPR: 0.95
                 similarity: 0.9
               - FPR: 0.15
                 TPR: 0.96
                 similarity: 0.8
            hit_top_probability:
              type: object
              description: propability of hit into the top.
              properties:
                top-1:
                  allOf:
                    - $ref: '#/components/schemas/float10'
                  description: propability of hit into the top-1.
                  nullable: true
                top-2:
                  allOf:
                    - $ref: '#/components/schemas/float10'
                  description: propability of hit into the top-2.
                  nullable: true
                top-3:
                  allOf:
                    - $ref: '#/components/schemas/float10'
                  description: propability of hit into the top-3.
                  nullable: true
                top-4:
                  allOf:
                    - $ref: '#/components/schemas/float10'
                  description: propability of hit into the top-4.
                  nullable: true
                top-5:
                  allOf:
                    - $ref: '#/components/schemas/float10'
                  description: propability of hit into the top-5.
                  nullable: true
              required: [top-1, top-2, top-3, top-4, top-5]
              example:
                top-1: 0.995
                top-2: 0.997
                top-3: 0.999
                top-4: 0.999
                top-5: 0.999
            auc:
              allOf:
                - $ref: '#/components/schemas/float10'
              description: area under the roc-curve.
              example: 0.99
            type_I_and_II_error_rates_equal_point:
              allOf:
                - $ref: '#/components/schemas/roc_points'
              description: ROC-curve point where type I error rate (1 - TPR) and type II error rate (FPR) are equal, i.e. intersection point of the ROC-curve and the secondary main diagonal.
              example:
                FPR: 0.15
                TPR: 0.85
                similarity: 0.8
              nullable: true
            key_points:
              type: array
              items:
                $ref: '#/components/schemas/roc_points'
              description: roc-curve points.
              example:
                - FPR: 0.000001
                  TPR: 0.95
                  similarity: 0.9
                - FPR: 0.001
                  TPR: 0.96
                  similarity: 0.8
              nullable: true
          required: [roc, hit_top_probability, auc, type_I_and_II_error_rates_equal_point, key_points]
        errors:
          $ref: '#/components/schemas/task_errors'
      required: [errors]

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

    report_task_result:
      type: string
      format: binary
      description: |
        zip archive with task result (now zip is supported in tasks on reports).

        Csv file and optional a folder with images in the case clusterization report.

        | cluster | event_id                             | create_time                      | end_time                         | external_id | handler_id                           | attribute_id                         | source | stream_id                            | top_match                                                                                                                                      | face_id                              | gender | age | emotion | ethnic_group | user_data                         | city   | area | district | street | house_number | latitude | longitude | mask | apparent_gender | apparent_age | headwear_state | sleeve_length | upper_clothing_colors | backpack_state | headwear_apparent_color | lower_garment_type    | lower_garment_colors | shoes_apparent_color | meta             |
        |---------|--------------------------------------|----------------------------------|----------------------------------|-------------|--------------------------------------|--------------------------------------|--------|--------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|--------|-----|---------|--------------|-----------------------------------|--------|------|----------|--------|--------------|----------|-----------|------|-----------------|--------------|----------------|---------------|-----------------------|----------------|-------------------------|-----------------------|----------------------|----------------------|------------------|
        | 0       | 6a4053de-17ab-40b5-bf2b-a1495df39085 | 2019-02-13T18:04:40.723800+03:00 | 2019-02-13T18:04:40.723800+03:00 |             | d727b3f5-e8ca-4fca-b092-d170ef5f9e49 | b3f9e82d-1654-4250-b39e-f8bbbca9880c |        | 91a7fd34-0877-46f5-844c-e88fd28d68f0 | "{'face_id': '23978f64-305f-4c43-8c01-c40bafabe554', 'label': '3a118ebc-18e2-4ed0-a0f0-3a50db652729', 'similarity': 0.6, 'external_id': 'e0'}" | cfb8ca11-4901-4296-a71d-0783d61ccf05 | 1      | 28  |         | 2            | vl test events_with_created_faces | Moscow | CAA  | Arbat    | Arbat  | 1            | 12.34    |   56.78   |  1   | 1               | 33           | 0              | "long"        | ["black", "white"]    | 2              | "black"                 | "shorts"              | ["black", "blue"]    | "black"              | "{'foo':'bar1'}" |
        | 1       | 110cc2d3-0350-418e-b956-90ef4dacbd23 | 2019-02-13T18:04:40.723800+03:00 | 2019-02-13T18:04:40.723800+03:00 |             | d727b3f5-e8ca-4fca-b092-d170ef5f9e49 | 3e1d0ffb-1fa6-449e-8c8b-8f9b56bfff6d |        | 91a7fd34-0877-46f5-844c-e88fd28d68f0 | "{'face_id': 'ad008886-942c-4c13-934c-8232dc7eefb2', 'label': '15859afa-37d3-41e2-8bc2-cb6f970dc6a0', 'similarity': 0.5, 'external_id': 'e1'}" | f4f17cbe-9197-4347-b214-692fa4ca9f26 | 0      | 24  |         | 2            | vl test events_with_created_faces | Moscow | CAA  | Arbat    | Arbat  | 1            | 12.34    |   56.78   |  1   | 1               | 33           | 0              | "long"        | ["black", "white"]    | 2              | "black"                 | "shorts"              | ["black", "blue"]    | "black"              | "{'foo':'bar1'}" |
        | 2       | 9a9c9445-6a3d-4f4d-b22a-64601f4c8675 | 2019-02-13T18:04:40.723800+03:00 | 2019-02-13T18:04:40.723800+03:00 |             | d727b3f5-e8ca-4fca-b092-d170ef5f9e49 | 91a7fd34-0877-46f5-844c-e88fd28d68f0 |        | 91a7fd34-0877-46f5-844c-e88fd28d68f0 | "{'face_id': 'c77bda6b-74ea-412f-989f-f27fd5be1e20', 'label': '3ac8c676-c717-4da4-8ed3-6ca9e6139c6d', 'similarity': 0.4, 'external_id': 'e2'}" | 83086070-bce2-40b9-a5c4-9df36a52fe4f | 0      | 19  |         | 4            | vl test events_with_created_faces | Moscow | CAA  | Arbat    | Arbat  | 1            | 12.34    |   56.78   |  1   | 1               | 33           | 0              | "long"        | ["black", "white"]    | 2              | "black"                 | "shorts"              | ["black", "blue"]    | "black"              | "{'foo':'bar1'}" |
        | 2       | 979be9cd-6363-431a-a8a6-3f3fff806abf | 2019-02-13T18:04:40.723800+03:00 | 2019-02-13T18:04:40.723800+03:00 |             | d727b3f5-e8ca-4fca-b092-d170ef5f9e49 | 2cfacb32-fc7a-4abd-8518-0bf759acc4f9 |        | 91a7fd34-0877-46f5-844c-e88fd28d68f0 | "{'face_id': '477a4ef7-16dc-4189-ab3b-91b1d342e101', 'label': '64058eac-eff1-4efc-b6c3-982133523a31', 'similarity': 0.3, 'external_id': 'e3'}" | e09228a7-8a7e-4581-b550-d5c0818c871f | 0      | 28  |         | 4            | vl test events_with_created_faces | Moscow | CAA  | Arbat    | Arbat  | 1            | 12.34    |   56.78   |  1   | 1               | 33           | 0              | "long"        | ["black", "white"]    | 2              | "black"                 | "shorts"              | ["black", "blue"]    | "black"              | "{'foo':'bar1'}" |
        | 3       | 60b86bf7-3395-40cf-90f0-4e0756f50b9e | 2019-02-13T18:04:40.723800+03:00 | 2019-02-13T18:04:40.723800+03:00 |             | d727b3f5-e8ca-4fca-b092-d170ef5f9e49 | 67c823db-8e3c-4638-abf9-63078d2687d5 |        | 91a7fd34-0877-46f5-844c-e88fd28d68f0 | "{'face_id': '7f5bf6fb-2ad0-42bf-98f2-fe949516db7d', 'label': 'be309d4d-deaa-479e-ba70-026a712f39e2', 'similarity': 0.2, 'external_id': 'e4'}" | 301e8eb8-b6af-4c33-b5a1-6861509d2df4 | 1      | 56  |         | 4            | vl test events_with_created_faces | Moscow | CAA  | Arbat    | Arbat  | 1            | 12.34    |   56.78   |  1   | 1               | 33           | 0              | "long"        | ["black", "white"]    | 2              | "black"                 | "shorts"              | ["black", "blue"]    | "black"              | "{'foo':'bar1'}" |

    export_task_result:
      type: string
      format: binary
      description: |
        zip archive with task result (now zip is supported in tasks on export).

        Csv file and optional a folder with images in the case export.

        | event_id                             | create_time                      | end_time                         | external_id                          | handler_id                           | source                               | stream_id                            | top_match                                                                                                                                      | face_id                              | gender | age | emotion | ethnic_group | user_data                            | mask | track_id                             | city   | area | district | street | house_number | geo_position     | mask | apparent_gender | apparent_age | headwear_state | sleeve_length | upper_clothing_colors | backpack_state | headwear_apparent_color | lower_garment_type    | lower_garment_colors | shoes_apparent_color | meta             |
        |--------------------------------------|----------------------------------|----------------------------------|--------------------------------------|--------------------------------------|--------------------------------------|--------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|--------|-----|---------|--------------|--------------------------------------|------|--------------------------------------|--------|------|----------|--------|--------------| -----------------|------|-----------------|--------------|----------------|---------------|-----------------------|----------------|-------------------------|-----------------------|----------------------|----------------------|------------------|
        | 0370f6b6-643a-4ad6-8c30-57849d7b070d | 2021-06-18T09:01:45.115401+03:00 | 2021-06-18T09:01:45.115401+03:00 | a2c4ef84-8ed6-4b9c-b4ac-b96e7ae4d973 | 0f474053-8b2c-4d62-bfd0-b2f6072464cd | a7f009a9-3a98-4e5b-8e45-0c43290c84df | 91a7fd34-0877-46f5-844c-e88fd28d68f0 | "{'face_id': '23978f64-305f-4c43-8c01-c40bafabe554', 'label': '3a118ebc-18e2-4ed0-a0f0-3a50db652729', 'similarity': 0.6, 'external_id': 'e0'}" | f687a4d1-0d25-4940-bbda-192b7b964fed | 1      | 33  | 7       | 1            | 1111632d-70fc-4e2e-b336-d5a68e1deb14 | 1    | 09e6642b-1ebe-405d-9bcd-86bbe254dc4f | Moscow | CAA  | Arbat    | Arbat  | 1            | "55.752, 36.616" | 1    | 1               | 33           | 0              | "long"        | ["black", "white"]    | 2              | "black"                 | "shorts"              | ["black", "blue"]    | "black"              | "{'foo':'bar1'}" |
        | 0370f6b6-643a-4ad6-8c30-57849d7b070c | 2021-06-18T09:01:45.115206+03:00 | 2021-06-18T09:01:45.115401+03:00 | 2ba4dcb3-0ca6-43b2-a588-42cd776a09ab | 2daa17f1-a5e6-4d7b-bae4-a224eec35eee | c038bede-f002-4c74-98fe-d3686b043fcd | 91a7fd34-0877-46f5-844c-e88fd28d68f0 | "{'face_id': 'ad008886-942c-4c13-934c-8232dc7eefb2', 'label': '15859afa-37d3-41e2-8bc2-cb6f970dc6a0', 'similarity': 0.5, 'external_id': 'e1'}" | ed5ea7ce-02b3-4129-b3e8-4721b678c463 | 1      | 33  | 7       | 1            | 42d908a4-52c5-4f46-87bd-4903ee315260 | 1    | b152f0a9-2fe7-458d-9107-9783cf14e491 | Moscow | CAA  | Arbat    | Arbat  | 1            | "55.752, 36.616" | 1    | 1               | 33           | 0              | "long"        | ["black", "white"]    | 2              | "black"                 | "shorts"              | ["black", "blue"]    | "black"              | "{'foo':'bar1'}" |
        | 0370f6b6-643a-4ad6-8c30-57849d7b070b | 2021-06-18T09:01:45.115014+03:00 | 2021-06-18T09:01:45.115401+03:00 | ca23bb19-6c15-4466-a89c-b1181adaf874 | 757318b2-3570-496a-b3c2-5d8a024e0ae1 | 4fd91006-d51a-4491-8923-1c6341a579c4 | 91a7fd34-0877-46f5-844c-e88fd28d68f0 | "{'face_id': 'c77bda6b-74ea-412f-989f-f27fd5be1e20', 'label': '3ac8c676-c717-4da4-8ed3-6ca9e6139c6d', 'similarity': 0.4, 'external_id': 'e2'}" | ae6381e6-0341-47bb-9989-3a3706ae99f9 | 1      | 33  | 7       | 1            | 079c8ecc-d29b-4ab5-aa65-d1954b5101d6 | 1    | e6495a29-7c25-45bd-b9f6-17d954f5a485 | Moscow | CAA  | Arbat    | Arbat  | 1            | "55.752, 36.616" | 1    | 1               | 33           | 0              | "long"        | ["black", "white"]    | 2              | "black"                 | "shorts"              | ["black", "blue"]    | "black"              | "{'foo':'bar1'}" |
        | 0370f6b6-643a-4ad6-8c30-57849d7b070a | 2021-06-18T09:01:45.114805+03:00 | 2021-06-18T09:01:45.115401+03:00 | 7e1c37d0-74f1-4ca7-8fbe-f5c26b6a5fb7 | 7c57c339-4fc3-4a1a-90e3-e932eb4b022d | 8391e7c7-a8b1-4466-8b1e-76433f3e92a7 | 91a7fd34-0877-46f5-844c-e88fd28d68f0 | "{'face_id': '477a4ef7-16dc-4189-ab3b-91b1d342e101', 'label': '64058eac-eff1-4efc-b6c3-982133523a31', 'similarity': 0.3, 'external_id': 'e3'}" | 830bc063-d5ca-4eba-a8c3-2094d9e4bd32 | 1      | 33  | 7       | 1            | 5068d60e-5f50-4e45-bdbf-d68a3020097c | 1    | b3b780ea-76f2-4147-ae4e-674bbf8c8aa0 | Moscow | CAA  | Arbat    | Arbat  | 1            | "55.752, 36.616" | 1    | 1               | 33           | 0              | "long"        | ["black", "white"]    | 2              | "black"                 | "shorts"              | ["black", "blue"]    | "black"              | "{'foo':'bar1'}" |
        | 0370f6b6-643a-4ad6-8c30-57849d7b0709 | 2021-06-18T09:01:45.114531+03:00 | 2021-06-18T09:01:45.115401+03:00 | 3a95f340-9b02-4b4d-b56c-bc6aeaae46db | aa7d4de1-d4fb-4052-acb4-1ccb5be99ece | c1275d2f-95d1-4034-870f-da0a8f9d02b8 | 91a7fd34-0877-46f5-844c-e88fd28d68f0 | "{'face_id': '7f5bf6fb-2ad0-42bf-98f2-fe949516db7d', 'label': 'be309d4d-deaa-479e-ba70-026a712f39e2', 'similarity': 0.2, 'external_id': 'e4'}" | 64c4f42e-e7e3-4a72-93d8-399e5c8451c9 | 1      | 33  | 7       | 1            | 7bcc784c-d699-492e-99e5-5c3cdea79764 | 1    | d0e339e3-472a-4da0-b90a-43693ca5fb47 | Moscow | CAA  | Arbat    | Arbat  | 1            | "55.752, 36.616" | 1    | 1               | 33           | 0              | "long"        | ["black", "white"]    | 2              | "black"                 | "shorts"              | ["black", "blue"]    | "black"              | "{'foo':'bar1'}" |

    schedule_id:
      type: integer
      nullable: false
      minimum: 1
      description: Schedule according to which the task was created

    retry_count:
      type: integer
      minimum: 0
      maximum: 32767

    schedule_trigger:
      type: object
      description: task schedule trigger
      properties:
        cron:
          type: string
          maxLength: 128
          example: 5 4 * * *
          description: |
            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
      required: [cron]

    schedule_behaviour:
      type: object
      description: schedule behaviour parameters
      properties:
        start_immediately:
          type: bool
          default: false
          description: whether to create first task immediately regardless to schedule
        create_stopped:
          type: bool
          default: false
          description: |
            whether to create schedule and not execute any tasks

            expected that schedule will execute by user manually in future

    task_schedule_template_request:
      type: object
      description: tasks schedule
      properties:
        notification_policy:
          $ref: '#/components/schemas/notification_policy'
      required: [task_type, content]

    task_schedule_template_response:
      type: object
      description: tasks schedule
      properties:
        notification_policy:
          $ref: '#/components/schemas/task_notification_policy_response'
      required: [task_type, content, notification_policy]

    linker_content_props:
      type: object
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type_schedulable"
          enum: [1]
        content:
          $ref: "#/components/schemas/linker_task_content"

    schedule_linker_task_content_request:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_request"
        - $ref: "#/components/schemas/linker_content_props"

    schedule_linker_task_content_response:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_response"
        - $ref: "#/components/schemas/linker_content_props"

    clustering_content_props:
      type: object
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type_schedulable"
          enum: [2]
        content:
          $ref: "#/components/schemas/clustering_task_content"

    schedule_clustering_task_content_request:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_request"
        - $ref: "#/components/schemas/clustering_content_props"

    schedule_clustering_task_content_response:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_response"
        - $ref: "#/components/schemas/clustering_content_props"

    reporter_content_props:
      type: object
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type_schedulable"
          enum: [3]
        content:
          type: object
          properties:
            clusterization:
              $ref: "#/components/schemas/clustering_task_content"
            reporter:
              $ref: "#/components/schemas/reporter_task_content_without_filters"
          required: [clusterization, reporter]

    schedule_reporter_task_content_request:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_request"
        - $ref: "#/components/schemas/reporter_content_props"

    schedule_reporter_task_content_response:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_response"
        - $ref: "#/components/schemas/reporter_content_props"

    gc_content_props:
      type: object
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type_schedulable"
          enum: [4]
        content:
          $ref: "#/components/schemas/gc_task_content"

    schedule_gc_task_content_request:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_request"
        - $ref: "#/components/schemas/gc_content_props"

    schedule_gc_task_content_response:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_response"
        - $ref: "#/components/schemas/gc_content_props"

    ae_task_content_props:
      type: object
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type_schedulable"
          enum: [5]
        content:
          $ref: "#/components/schemas/additional_extract_task_content"

    schedule_ae_task_content_request:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_request"
        - $ref: "#/components/schemas/ae_task_content_props"

    schedule_ae_task_content_response:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_response"
        - $ref: "#/components/schemas/ae_task_content_props"

    cm_content_props:
      type: object
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type_schedulable"
          enum: [6]
        content:
          $ref: "#/components/schemas/cross_match_task_content"

    schedule_cross_match_task_content_request:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_request"
        - $ref: "#/components/schemas/cm_content_props"

    schedule_cross_match_task_content_response:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_response"
        - $ref: "#/components/schemas/cm_content_props"

    roc_content_props:
      type: object
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type_schedulable"
          enum: [7]
        content:
          $ref: "#/components/schemas/roc_task_content"

    schedule_roc_task_content_request:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_request"
        - $ref: "#/components/schemas/roc_content_props"

    schedule_roc_task_content_response:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_response"
        - $ref: "#/components/schemas/roc_content_props"

    exporter_content_props:
      type: object
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type_schedulable"
          enum: [8]
        content:
          $ref: "#/components/schemas/exporter_task_content"

    schedule_exporter_task_content_request:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_request"
        - $ref: "#/components/schemas/exporter_content_props"

    schedule_exporter_task_content_response:
      allOf:
        - $ref: "#/components/schemas/task_schedule_template_response"
        - $ref: "#/components/schemas/exporter_content_props"

    task_schedulable_request:
      description: task schedule
      oneOf:
        - $ref: '#/components/schemas/schedule_linker_task_content_request'
        - $ref: '#/components/schemas/schedule_clustering_task_content_request'
        - $ref: '#/components/schemas/schedule_reporter_task_content_request'
        - $ref: '#/components/schemas/schedule_gc_task_content_request'
        - $ref: '#/components/schemas/schedule_ae_task_content_request'
        - $ref: '#/components/schemas/schedule_cross_match_task_content_request'
        - $ref: '#/components/schemas/schedule_roc_task_content_request'
        - $ref: '#/components/schemas/schedule_exporter_task_content_request'
        - $ref: '#/components/schemas/schedule_estimator_task_content_request'
        - $ref: '#/components/schemas/schedule_lambda_task_content_request'
      discriminator:
        propertyName: task_type
        mapping:
          1: '#/components/schemas/schedule_linker_task_content_request'
          2: '#/components/schemas/schedule_clustering_task_content_request'
          3: '#/components/schemas/schedule_reporter_task_content_request'
          4: '#/components/schemas/schedule_gc_task_content_request'
          5: '#/components/schemas/schedule_ae_task_content_request'
          6: '#/components/schemas/schedule_cross_match_task_content_request'
          7: '#/components/schemas/schedule_roc_task_content_request'
          8: '#/components/schemas/schedule_exporter_task_content_request'
          9: '#/components/schemas/schedule_estimator_task_content_request'
          10: '#/components/schemas/schedule_lambda_task_content_request'

    task_schedulable_response:
      description: task schedule
      oneOf:
        - $ref: '#/components/schemas/schedule_linker_task_content_response'
        - $ref: '#/components/schemas/schedule_clustering_task_content_response'
        - $ref: '#/components/schemas/schedule_reporter_task_content_response'
        - $ref: '#/components/schemas/schedule_gc_task_content_response'
        - $ref: '#/components/schemas/schedule_ae_task_content_response'
        - $ref: '#/components/schemas/schedule_cross_match_task_content_response'
        - $ref: '#/components/schemas/schedule_roc_task_content_response'
        - $ref: '#/components/schemas/schedule_exporter_task_content_response'
        - $ref: '#/components/schemas/schedule_estimator_task_content_response'
        - $ref: '#/components/schemas/schedule_lambda_task_content_response'
      discriminator:
        propertyName: task_type
        mapping:
          1: '#/components/schemas/schedule_linker_task_content_response'
          2: '#/components/schemas/schedule_clustering_task_content_response'
          3: '#/components/schemas/schedule_reporter_task_content_response'
          4: '#/components/schemas/schedule_gc_task_content_response'
          5: '#/components/schemas/schedule_ae_task_content_response'
          6: '#/components/schemas/schedule_cross_match_task_content_response'
          7: '#/components/schemas/schedule_roc_task_content_response'
          8: '#/components/schemas/schedule_exporter_task_content_response'
          9: '#/components/schemas/schedule_estimator_task_content_response'
          10: '#/components/schemas/schedule_lambda_task_content_response'

    schedule:
      type: object
      description: tasks schedule
      properties:
        task:
          $ref: '#/components/schemas/task_schedulable_request'
        trigger:
          $ref: '#/components/schemas/schedule_trigger'
        behaviour:
          $ref: '#/components/schemas/schedule_behaviour'
      required: [trigger, task]

    schedule_status:
      type: string
      enum: [running, stopped]
      description: |
        schedule status

        | status  | description                                  |
        |---------|----------------------------------------------|
        | running | schedule is running                          |
        | stopped | schedule is stopped by user                  |

    schedule_reply:
      type: object
      properties:
        schedule_id:
          $ref: '#/components/schemas/schedule_id'
        task_ids:
          type: array
          items:
            $ref: '#/components/schemas/task_id'
          example: [1,2,3]
          description: list of executed task ids in descending order
        account_id:
          $ref: '#/components/schemas/account_id'
        task:
          $ref: '#/components/schemas/task_schedulable_response'
        trigger:
          $ref: '#/components/schemas/schedule_trigger'
        status:
          $ref: '#/components/schemas/schedule_status'
        next_run_time:
          allOf:
            - $ref: '#/components/schemas/time'
          nullable: True
          description: estimated time for next task
        create_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: schedule create time
        last_update_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: schedule last update time
      required:
        - schedule_id
        - task_ids
        - account_id
        - task
        - trigger
        - status
        - next_run_time
        - create_time
        - last_update_time

    schedules_reply:
      type: array
      items:
        $ref: '#/components/schemas/schedule_reply'

    task_template_reply:
      type: object
      properties:
        task_id:
          $ref: '#/components/schemas/task_id'
        create_time:
          allOf:
            - $ref: '#/components/schemas/time'
          description: task create time
        end_time:
          allOf:
            - $ref: '#/components/schemas/time_nullable'
          description: task end time
        last_update_time:
          allOf:
            - description: task last update time
          $ref: '#/components/schemas/time_nullable'
        task_status:
          $ref: '#/components/schemas/task_status'
        result_id:
          $ref: '#/components/schemas/result_id'
        account_id:
          $ref: '#/components/schemas/account_id'
        count_task_parts_done:
          $ref: '#/components/schemas/count_task_parts_done'
        count_task_parts_all:
          $ref: '#/components/schemas/count_task_parts_all'
        description:
          $ref: '#/components/schemas/task_description'
        notification_policy:
          $ref: '#/components/schemas/task_notification_policy_response'
      required: [ task_id, create_time, last_update_time, task_type, task_status, count_task_parts_done,
                  count_task_parts_all, content, notification_policy ]

    schedulable_task_template_reply:
      allOf:
        - $ref: '#/components/schemas/task_template_reply'
        - properties:
            schedule_id:
              $ref: '#/components/schemas/schedule_id'

    task_linker_reply:
      allOf:
        - $ref: "#/components/schemas/schedulable_task_template_reply"
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type"
          enum: [ 1 ]
        content:
          $ref: "#/components/schemas/linker_task_content_reply"

    task_clustering_reply:
      allOf:
        - $ref: "#/components/schemas/schedulable_task_template_reply"
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type"
          enum: [ 2 ]
        content:
          $ref: "#/components/schemas/clustering_task_content_reply"

    task_report_reply:
      allOf:
        - $ref: "#/components/schemas/schedulable_task_template_reply"
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type"
          enum: [ 3 ]
        content:
          $ref: "#/components/schemas/reporter_task_content"

    task_lambda_reply:
      allOf:
        - $ref: "#/components/schemas/schedulable_task_template_reply"
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type"
          enum: [ 10 ]
        content:
          $ref: "#/components/schemas/lambda_task_content"

    task_gc_reply:
      allOf:
        - $ref: "#/components/schemas/schedulable_task_template_reply"
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type"
          enum: [ 4 ]
        content:
          description: Garbage collecting task content
          oneOf:
            - $ref: '#/components/schemas/gc_face_descriptors_task_content'
            - $ref: '#/components/schemas/gc_faces_task_content_reply'
            - $ref: '#/components/schemas/gc_event_descriptors_task_content'
            - $ref: '#/components/schemas/gc_events_task_content_reply'
          discriminator:
            propertyName: target
            mapping:
              face_descriptors: '#/components/schemas/gc_face_descriptors_task_content'
              faces: '#/components/schemas/gc_faces_task_content_reply'
              event_descriptors: '#/components/schemas/gc_event_descriptors_task_content'
              events: '#/components/schemas/gc_events_task_content_reply'

    task_additional_extract_reply:
      allOf:
        - $ref: "#/components/schemas/schedulable_task_template_reply"
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type"
          enum: [ 5 ]
        content:
          description: additional extractor task content.
          oneOf:
            - $ref: '#/components/schemas/additional_extract_task_content_basic_attributes_reply'
            - $ref: '#/components/schemas/additional_extract_task_content_face_descriptor_reply'
            - $ref: '#/components/schemas/additional_extract_task_content_body_descriptor_reply'
          discriminator:
            propertyName: extraction_target
            mapping:
              basic_attributes: '#/components/schemas/additional_extract_task_content_basic_attributes_reply'
              face_descriptor: '#/components/schemas/additional_extract_task_content_face_descriptor_reply'
              body_descriptor: '#/components/schemas/additional_extract_task_content_body_descriptor_reply'

    task_cross_match_reply:
      allOf:
        - $ref: "#/components/schemas/schedulable_task_template_reply"
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type"
          enum: [ 6 ]
        content:
          $ref: "#/components/schemas/cross_match_task_content_reply"

    task_roc_reply:
      allOf:
        - $ref: "#/components/schemas/schedulable_task_template_reply"
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type"
          enum: [ 7 ]
        content:
          $ref: "#/components/schemas/roc_task_content"

    task_exporter_reply:
      allOf:
        - $ref: "#/components/schemas/schedulable_task_template_reply"
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type"
          enum: [ 8 ]
        content:
          $ref: "#/components/schemas/exporter_task_content_reply"

    task_estimator_reply:
      allOf:
        - $ref: "#/components/schemas/schedulable_task_template_reply"
      properties:
        task_type:
          allOf:
            - $ref: "#/components/schemas/task_type"
          enum: [9]
        content:
          $ref: "#/components/schemas/estimator_task_content_required"

    task_reply:
      oneOf:
        - $ref: "#/components/schemas/task_linker_reply"
        - $ref: "#/components/schemas/task_clustering_reply"
        - $ref: "#/components/schemas/task_report_reply"
        - $ref: "#/components/schemas/task_gc_reply"
        - $ref: "#/components/schemas/task_additional_extract_reply"
        - $ref: "#/components/schemas/task_cross_match_reply"
        - $ref: "#/components/schemas/task_roc_reply"
        - $ref: "#/components/schemas/task_exporter_reply"
        - $ref: "#/components/schemas/task_estimator_reply"
        - $ref: "#/components/schemas/task_lambda_reply"
      discriminator:
        propertyName: task_type
        mapping:
          1: '#/components/schemas/task_linker_reply'
          2: '#/components/schemas/task_clustering_reply'
          3: '#/components/schemas/task_report_reply'
          4: '#/components/schemas/task_gc_reply'
          5: '#/components/schemas/task_additional_extract_reply'
          6: '#/components/schemas/task_cross_match_reply'
          7: '#/components/schemas/task_roc_reply'
          8: '#/components/schemas/task_exporter_reply'
          9: '#/components/schemas/task_estimator_reply'
          10: '#/components/schemas/task_lambda_reply'

    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: tasks_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
          - component: tasks_worker
            error:
              error_code: 0
              desc: Success
              detail: Success
              link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0
            status: 1

    create_time__gte:
      allOf:
        - $ref: '#/components/schemas/time'
      description: Create time lower included boundary.
      pattern: '^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|\.\d+Z|\.\d+[+-]\d{2}:\d{2}|[+-]\d{2}:\d{2}))$'
      example: "2018-08-11T09:11:41.674Z"

    create_time__lt:
      allOf:
        - $ref: '#/components/schemas/time'
      description: Create time upper excluded boundary.
      pattern: '^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|\.\d+Z|\.\d+[+-]\d{2}:\d{2}|[+-]\d{2}:\d{2}))$'
      example: "2018-08-11T09:11:41.674Z"

    end_time__gte:
      allOf:
        - $ref: '#/components/schemas/time'
      description: End time lower included boundary.
      pattern: '^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|\.\d+Z|\.\d+[+-]\d{2}:\d{2}|[+-]\d{2}:\d{2}))$'
      example: "2018-08-11T09:11:41.674Z"

    end_time__lt:
      allOf:
        - $ref: '#/components/schemas/time'
      description: End time upper excluded boundary.
      pattern: '^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|\.\d+Z|\.\d+[+-]\d{2}:\d{2}|[+-]\d{2}:\d{2}))$'
      example: "2018-08-11T09:11:41.674Z"

    insert_time__gte:
      allOf:
        - $ref: '#/components/schemas/time'
      description: Event insert time lower excluding boundary.
      pattern: '^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|\.\d+Z|\.\d+[+-]\d{2}:\d{2}|[+-]\d{2}:\d{2}))$'
      example: "2018-08-11T09:11:41.674Z"

    insert_time__lt:
      allOf:
        - $ref: '#/components/schemas/time'
      description: Event insert time upper excluding boundary.
      pattern: '^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|\.\d+Z|\.\d+[+-]\d{2}:\d{2}|[+-]\d{2}:\d{2}))$'
      example: "2018-08-11T09:11:41.674Z"

    now_delta_time_filter:
      type: string
      pattern: '^now-(\d+)[smhdwMy]$'
      example: "now-2d"

    create_time_now__gte:
      allOf:
        - $ref: '#/components/schemas/now_delta_time_filter'
      description: |
            Create time lower included boundary in format `now-time`, where time must be present as follows:

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

    create_time_now__lt:
      allOf:
        - $ref: '#/components/schemas/now_delta_time_filter'
      description: |
            Create time upper excluded boundary in format `now-time`, where time must be present as follows:

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

    end_time_now__gte:
      allOf:
        - $ref: '#/components/schemas/now_delta_time_filter'
      description: |
        End time lower included boundary in format `now-time`, where time must be present as follows:

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

    end_time_now__lt:
      allOf:
        - $ref: '#/components/schemas/now_delta_time_filter'
      description: |
        End time upper excluded boundary in format `now-time`, where time must be present as follows:

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

    insert_time_now__gte:
      allOf:
        - $ref: '#/components/schemas/now_delta_time_filter'
      description: |
        End time lower included boundary in format `now-time`, where time must be present as follows:

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

    insert_time_now__lt:
      allOf:
        - $ref: '#/components/schemas/now_delta_time_filter'
      description: |
        End time upper excluded boundary in format `now-time`, where time must be present as follows:

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

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

    plugins:
      type: object
      properties:
        plugins:
          description: list of imported plugins
          type: array
          items:
            $ref: '#/components/schemas/plugin_status'
      required: [plugins]
      example:
        plugins:
          - name: foo
            running: 1
  responses:
    internal_server_error:
      description: internal server error.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'

    server_timeout_error:
      description: server timeout error.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error_code: 9
            detail: Request timeout
            desc: Request timeout on http://127.0.0.1:5050/{...}, method {...}
            link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-9

    lis_disabled:
      description: The luna-image-store is disabled.
      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: 11070
            desc: Forbidden
            detail: Luna Image Store service is disabled
            link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11070"

    ae_not_implemented:
      description: not implemented.
      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:
            not_implemented:
              value:
                error_code: 12029
                desc: Functionality is not implemented
                detail: Required server functionality is not implemented
                link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12029

    forbidden_resource_error:
      description: Forbidden.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            resource_is_disabled:
              value:
                error_code: 12049
                desc: Forbidden
                detail: Resource is disabled.
                link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12049"
paths:
  /2/docs/spec:
    get:
      tags:
        - documents
      summary: get openapi documentation
      description: |
        Get service OpenApi documentation. If *Accept* request header is of type `application/x-yaml`,
        returns documentation in `yaml` format or returns `html` documentation, if *Accept-Type* is `text/html`
      operationId: getSpec

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

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/text_html'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            text/html:
              schema:
                type: string
                description: html format documentation
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/plugins:
    get:
      tags:
        - plugins
      summary: get list of plugins
      description: |
        Get list of service plugins
      operationId: getPlugins
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/plugins'
        500:
          $ref: '#/components/responses/internal_server_error'
  /healthcheck:
    get:
      tags:
        - health
      summary: get health
      description: get health of service
      operationId: healthcheck
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/include_luna_services'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/health_ok'
        500:
          $ref: '#/components/responses/internal_server_error'
        502:
          description: Unhealthy
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/health_errors'