openapi: 3.0.0
info:
  version: 'v.3.0.27'
  title: 'Luna tasks'
  description: 'VisionLabs Luna Tasks'

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

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

    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
  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: 100
        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.

    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/taskType'
      example: 1

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

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

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

    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_id:
      in: query
      name: error_id
      schema:
        $ref: '#/components/schemas/errorId'
      description: error id
      example: 10

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

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

    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
  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.
      required: [error_code, detail, desc]
      example:
        error_code: 1
        detail: internal server error
        desc: internal server error

    error_code:
      type: integer
      description: error code.

    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

    errorId:
      type: integer
      example: 10

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

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

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

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

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

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

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

    taskType:
      type: integer
      enum: [0, 1, 2, 3, 4, 5, 6, 7]
      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 |

    int_version:
      type: integer
      minimum: 0

    taskIds:
      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"

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

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

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

    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

    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:
      type: string
      format: date-time
      pattern: '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$'
      example: "2018-08-11T09:11:41.674Z"

    time_end:
      type: string
      format: date-time
      pattern: '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$'
      example: "2018-08-11T10:11:41.674Z"

    Task:
      type: object
      properties:
        task_id:
          $ref: '#/components/schemas/task_id'
        create_time:
          allOf:
          - description: task create time
          - $ref: '#/components/schemas/time'
        end_time:
          allOf:
          - description: task end time
          - $ref: '#/components/schemas/time_end'
        last_update_time:
          allOf:
          - description: task last update time
          - $ref: '#/components/schemas/time_end'
        task_type:
          $ref: '#/components/schemas/taskType'
        task_status:
          $ref: '#/components/schemas/taskStatus'
        result_id:
          $ref: '#/components/schemas/resultId'
        account_id:
          $ref: '#/components/schemas/accountId'
        count_task_parts_done:
          $ref: '#/components/schemas/count_task_parts_done'
        count_task_parts_all:
          $ref: '#/components/schemas/count_task_parts_all'
        content:
          $ref: '#/components/schemas/task_content'
        description:
          $ref: '#/components/schemas/task_description'
      required: [task_id, create_time, last_update_time, task_type, task_status, count_task_parts_done,
                 count_task_parts_all, content]

    Tasks:
      type: array
      items:
        $ref: '#/components/schemas/Task'
      minItems: 0

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

    SubTasks:
      type: array
      items:
        $ref: '#/components/schemas/SubTask'
      minItems: 0

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

    TaskErrors:
      type: array
      items:
        $ref: '#/components/schemas/TaskError'
      minItems: 0
      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.

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

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

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

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

    external_ids:
      type: array
      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-dbcb6e0dc38']

    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"]
      required: [type]

    FacesFiltersNoAccount:
      type: object
      properties:
        face_ids:
          $ref: '#/components/schemas/face_ids'
        external_ids:
          $ref: '#/components/schemas/external_ids'
        user_data:
          $ref: '#/components/schemas/user_data'
        create_time__gte:
          allOf:
            - $ref: '#/components/schemas/time'
            - description: create time lower including boundary.
          example: "2018-08-11T09:11:41.674Z"
        create_time__lt:
          allOf:
            - $ref: '#/components/schemas/time'
            - description: create time upper excluding boundary.
          example: "2018-08-11T09:11:41.674Z"
        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'

    FacesFilters:
      allOf:
      - $ref: '#/components/schemas/FacesFiltersNoAccount'
      - properties:
          account_id:
            allOf:
              - $ref: '#/components/schemas/uuid'
              - description: account id.
            example: '346a5645-ec89-4806-820a-dbcb6e0dc38'
        required: [account_id]

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

    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:
          type: number
          minimum: -180
          maximum: 180
          example: 36.616
          description: longitude origin in degrees.
        origin_latitude:
          type: number
          minimum: -90
          maximum: 90
          example: 55.752
          description: latitude origin in degrees.
        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"

    EventsFiltersNoAccount:
      type: object
      properties:
        create_time__gte:
          allOf:
            - $ref: '#/components/schemas/time'
            - description: create time lower including boundary.
          example: "2018-08-11T09:11:41.674Z"
        create_time__lt:
          allOf:
            - $ref: '#/components/schemas/time'
            - description: create time upper excluding boundary.
          example: "2018-08-11T09:11:41.674Z"
        sources:
          description: sources. Each event from result will contain one of the given sources.
          type: array
          items:
            type: string
          example: ["cam1", "cam2"]
        event_ids:
          description: events ids
          type: array
          items:
            $ref: '#/components/schemas/uuid'
          example: ['8950722f-3fd4-4223-b48f-03f95f0e8dfb', '346a5645-ec89-4806-820a-dbcb6e0dc38']
        handler_ids:
          description: handler ids. Each event from result will contain one of the given handlers.
          type: array
          items:
            $ref: '#/components/schemas/uuid'
          example: ['8950722f-3fd4-4223-b48f-03f95f0e8dfb', '346a5645-ec89-4806-820a-dbcb6e0dc38']
        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 faces.
          type: array
          items:
            $ref: '#/components/schemas/uuid'
          example: ['8950722f-3fd4-4223-b48f-03f95f0e8dfb', '346a5645-ec89-4806-820a-dbcb6e0dc38']
        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:
          description: gender, 0 - female, 1 - male.
          type: integer
          enum: [0, 1]
          example: 1
        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
          items:
            type: integer
            enum: [1, 2, 3, 4, 5, 6, 7]
          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
          items:
            type: integer
            enum: [1, 2, 3, 4]
          example: [1, 2]
        face_ids:
          $ref: '#/components/schemas/face_ids'
        user_data:
          $ref: '#/components/schemas/user_data'
        tags:
          description: list of tags. Each event from result will contain all of the given tags.
          type: array
          items:
            type: string
          example: ["tag_1", "tag_2"]
        cities:
          description: comma-separated list of cities. Each event from result will contain one of the given cities in location.
          type: array
          items:
            type: string
          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
          items:
            type: string
          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
          items:
            type: string
          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
          items:
            type: string
          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
          items:
            type: string
          example: ["1", "1/2str3"]
        geo_position:
          $ref: '#/components/schemas/geo_position'
        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
          items:
            type: integer
            enum: [1, 2, 3]
          example: [2, 3]
        track_ids:
          type: array
          description: list of track ids. Each event from result will contain one of the given track ids.
          items:
            type: string
            pattern: '^[a-zA-Z0-9_\-](1, 36)$'
          example: ["track_id_number_1", "track_id_number_2"]


    EventsFilters:
      allOf:
      - $ref: '#/components/schemas/EventsFiltersNoAccount'
      - type: object
        properties:
          account_id:
            allOf:
              - $ref: '#/components/schemas/uuid'
              - description: account id.
            example: '346a5645-ec89-4806-820a-dbcb6e0dc38'
        required: [account_id]

    FaceFilters:
      description: face filters.
      type: object
      properties:
        account_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - description: 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.

    LinkerTaskContentBoth:
      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: 1
        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'
        filters:
          oneOf:
          - $ref: '#/components/schemas/FacesFilters'
          - $ref: '#/components/schemas/EventsFilters'
      required: [objects_type, filters]

    LinkerTask:
      type: object
      properties:
        account_id:
          description: account id of the task
          allOf:
          - $ref: '#/components/schemas/uuid'
        description:
          type: string
          description: provided user data for current task
          example: linker task one
        content:
          $ref: '#/components/schemas/LinkerTaskContentBoth'
      required: [account_id, content]

    GcTask:
      oneOf:
        - $ref: '#/components/schemas/GcDescriptorsTask'
        - $ref: '#/components/schemas/GcEventsTask'

    GcTaskTemplate:
      type: object
      properties:
        account_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - description: account id of the task.
          example: '346a5645-ec89-4806-820a-dbcb6e0dc38'
        description:
          type: string
          description: provided user data for current task.
          example: gc task one
      required: [account_id, content]

    GcDescriptorsTask:
      allOf:
        - $ref: '#/components/schemas/GcTaskTemplate'
        - type: object
          properties:
            content:
              $ref: '#/components/schemas/GcDescriptorsTaskContent'

    GcEventsTask:
      allOf:
        - $ref: '#/components/schemas/GcTaskTemplate'
        - type: object
          properties:
            content:
              $ref: '#/components/schemas/GcEventsTaskContent'

    GcDescriptorsTaskContent:
      description: garbage collecting task content to delete descriptors by version
      type: object
      properties:
        target:
          type: string
          enum: ['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]

    GcEventsTaskContent:
      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.
            create_time__lt:
              allOf:
                - $ref: '#/components/schemas/time'
              description: create time upper excluding boundary.
            insert_time__lt:
              allOf:
                - $ref: '#/components/schemas/time'
              description: insert time upper excluding boundary.
            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
      required: [target]

    ClusteringTask:
      oneOf:
        - $ref: '#/components/schemas/EventClusteringTask'
        - $ref: '#/components/schemas/FaceClusteringTask'

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

    EventClusteringTask:
      allOf:
        - $ref: '#/components/schemas/ClusteringTaskTemplate'
        - type: object
          properties:
            content:
              type: object
              properties:
                objects_type:
                  enum: ["events"]
                filters:
                  $ref: '#/components/schemas/EventsFilters'
                params:
                  $ref: '#/components/schemas/EventClusteringTaskParams'
              required: [objects_type, filters]

    FaceClusteringTask:
      allOf:
        - $ref: '#/components/schemas/ClusteringTaskTemplate'
        - type: object
          properties:
            content:
              type: object
              properties:
                objects_type:
                  enum: ["faces"]
                filters:
                  $ref: '#/components/schemas/FacesFilters'
              required: [objects_type, filters]

    ClusteringTaskTemplate:
      type: object
      properties:
        account_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - description: account id of the task.
          example: '346a5645-ec89-4806-820a-dbcb6e0dc38'
        description:
          type: string
          description: provided user data for current task.
          example: clustering usefull faces
        content:
          type: object
          description: clustering task content
          properties:
            objects_type:
              type: string
              description: clustering object type
            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'
          required: [objects_type]
      required: [account_id, content]

    AdditionalExtractTaskContentDescriptor:
      description: additional extract descriptors task
      type: object
      properties:
        extraction_target:
          description: extraction target is "descriptor"
          type: string
          enum: ["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]
        filters:
          $ref: '#/components/schemas/FaceFilters'
      required: [extraction_target, options]

    AdditionalExtractTaskContentBasicAttributes:
      description: additional extract basic attributes task
      type: object
      properties:
        extraction_target:
          description: extraction target is "basic_attributes"
          type: string
          enum: ["basic_attributes"]
        options:
          type: object
          description: extract task options
          properties:
            missing:
              type: boolean
              description: whether to extract only missing basic attributes
              default: true
        filters:
          $ref: '#/components/schemas/FaceFilters'
      required: [extraction_target]

    AdditionalExtractTask:
      type: object
      properties:
        account_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - description: account id of the task.
        description:
          type: string
          description: provided user data for current task
          example: additional extract usefull faces
        content:
          oneOf:
          - $ref: '#/components/schemas/AdditionalExtractTaskContentDescriptor'
          - $ref: '#/components/schemas/AdditionalExtractTaskContentBasicAttributes'
      required: [account_id, content]

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

    GCEventsTaskResult:
      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.
            type: array
            items:
              $ref: '#/components/schemas/uuid'
        required: [event_id, samples]

    GCTaskResult:
      description: Garbage Collecting task result
      type: object
      properties:
        result:
          oneOf:
            - $ref: '#/components/schemas/GCDescriptorsTaskResult'
            - $ref: '#/components/schemas/GCEventsTaskResult'
        errors:
          $ref: '#/components/schemas/TaskErrors'
      required: [errors]

    LinkerTaskResult:
      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'
              minItems: 0
        errors:
          $ref: '#/components/schemas/TaskErrors'
      required: [errors]

    ClusteringTaskResult:
      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/TaskErrors'
      required: [errors]

    ReporterTaskContent:
      type: object
      description: reporter task content
      properties:
        filters:
          type: object
          description: reporter task filters
          properties:
            account_id:
              allOf:
              - $ref: '#/components/schemas/uuid'
              - description: account id.
            task_id:
              description: id of task
              type: integer
              example: 146
          required: [task_id]
        columns:
          description: colum names in csv report. Order of fields determinates the order columns in report.
          oneOf:
            - $ref: '#/components/schemas/ReportEventColumns'
            - $ref: '#/components/schemas/ReportFaceColumns'
          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
      required: [filters]

    ReportEventColumns:
      type: array
      items:
        description: event columns
        type: string
        enum: ["create_time", "external_id", "handler_id", "source", "top_match", "match_result", "face_detections", "face_id", "attach_result", "gender",
               "age", "emotion", "ethnic_group", "tags", "user_data", "city", "area", "district", "street",
               "house_number", "latitude", "longitude", "body_detections", "mask", "track_id"]
      default: ["create_time", "external_id", "handler_id", "source", "top_match",
                "face_id", "gender", "age", "emotion", "ethnic_group", "user_data", "city", "area", "district",
                "street", "house_number", "latitude", "longitude", "mask", "track_id"]

    ReportFaceColumns:
      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"]

    ReporterTask:
      type: object
      properties:
        account_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - description: account id of the task.
        description:
          type: string
          description: provided user data for current task
          example: report clasterization events from cam1
        content:
          $ref: '#/components/schemas/ReporterTaskContent'
      required: [account_id, content]

    AdditionalExtractTaskResult:
      description: Additional extract task result
      type: object
      properties:
        result:
          description: additional extract result
          type: array
          items:
            type: object
            properties:
              face_id:
                description: extracted attribute face id.
                allOf:
                  - $ref: '#/components/schemas/uuid'
              generation:
                description: attribute generation
                type: integer
                minimum: 0
              samples:
                description: sample ids used for extraction
                type: array
                items:
                  $ref: '#/components/schemas/uuid'
            required: [face_id, generation, samples]
        errors:
          $ref: '#/components/schemas/TaskErrors'
      required: [errors, result]

    CrossMatchTaskReferenceFilters:
      description: Object filters for references.
      oneOf:
      - $ref: '#/components/schemas/FacesFiltersNoAccount'
      - $ref: '#/components/schemas/EventsFiltersNoAccount'
      - $ref: '#/components/schemas/attributes_filters_no_account'

    CrossMatchTaskCandidateFilters:
      description: Object filters for candidates.
      oneOf:
      - $ref: '#/components/schemas/FacesFiltersNoAccount'
      - $ref: '#/components/schemas/EventsFiltersNoAccount'
      - $ref: '#/components/schemas/attributes_filters_no_account'

    CrossMatchTask:
      type: object
      properties:
        account_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - description: account id of the task.
        description:
          type: string
          description: provided user data for current task
          example: matching famous people with customers
        content:
          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'
                reference_filters:
                  $ref: '#/components/schemas/CrossMatchTaskReferenceFilters'
                candidate_filters:
                  $ref: '#/components/schemas/CrossMatchTaskCandidateFilters'
                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:
              description: Maximum number of matching candidates to return for every match.
              type: integer
              minimum: 1
              example: 3
              default: 5
          required: [filters]

      required: [account_id, content]

    CrossMatchTaskResult:
      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 CrossMatchTask 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 CrossMatchTask 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/TaskErrors'
      required: [errors]

    markup_face_items:
      type: object
      properties:
        face_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
          description: face id.
        label:
          type: string
          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: string
          description: face attribute label (group id)
          example: 12
      required: [attribute_id, label]

    ROCTask:
      type: object
      properties:
        account_id:
          allOf:
            - $ref: '#/components/schemas/uuid'
            - description: account id of the task.
        description:
          description: provided user data for current task.
          type: string
          example: matching famous people with customers
        content:
          description: roc task content.
          type: object
          properties:
            markup:
              description: markup of face ids to labels (group ids).
              type: array
              minItems: 2
              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:
              description: maximum candidates count for every match.
              type: integer
              minimum: 1
              example: 100
              default: 5
            key_FPRs:
              description: roc-curve key FPR values
              type: array
              items:
                $ref: '#/components/schemas/float10'
              minItems: 0
              example: [0.000001, 0.001]
          required: [markup, filters]
      required: [account_id, content]

    ROCpoints:
      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]

    ROCTaskResult:
      description: roc task result.
      type: object
      properties:
        result:
          description: roc-curve calculation result.
          type: object
          properties:
            roc:
              type: array
              items:
                $ref: '#/components/schemas/ROCpoints'
              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/ROCpoints'
                - 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/ROCpoints'
              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/TaskErrors'
      required: [errors]

    accept_docs_handler:
      type: string
      enum: [application/x-yaml, text/html]
  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 {...}
paths:
  /version:
    get:
      tags:
      - version

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

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

      summary: get tasks
      description: get tasks with filters
      operationId: getTasks

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/page_size'
      - $ref: '#/components/parameters/create_time__lt'
      - $ref: '#/components/parameters/create_time__gte'
      - $ref: '#/components/parameters/end_time__lt'
      - $ref: '#/components/parameters/end_time__gte'
      - $ref: '#/components/parameters/task_ids'
      - $ref: '#/components/parameters/task_type'
      - $ref: '#/components/parameters/task_status'
      - $ref: '#/components/parameters/account_id'
      - $ref: '#/components/parameters/result_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/Tasks'
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'create_time__lt'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/tasks/count:
    get:
      tags:
      - tasks

      summary: get tasks count
      description: get tasks count with filters
      operationId: getTasksCount

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      - $ref: '#/components/parameters/create_time__lt'
      - $ref: '#/components/parameters/create_time__gte'
      - $ref: '#/components/parameters/end_time__lt'
      - $ref: '#/components/parameters/end_time__gte'
      - $ref: '#/components/parameters/task_ids'
      - $ref: '#/components/parameters/task_type'
      - $ref: '#/components/parameters/task_status'
      - $ref: '#/components/parameters/account_id'

      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/taskCount'
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'create_time__lt'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/tasks/{task_id}:
    get:
      tags:
      - tasks

      summary: get task
      description: get task by id
      operationId: getTask

      parameters:
      - in: path
        name: task_id
        schema:
          type: integer
          minimum: 1
        required: true
        description: task id
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'

      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
        404:
          description: task not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Task with id '146' not found
        500:
          $ref: '#/components/responses/internal_server_error'

    patch:
      tags:
      - tasks

      summary: cancel task
      description: cancel task by id
      operationId: cancelTask

      parameters:
      - in: path
        name: task_id
        schema:
          type: integer
          minimum: 1
        required: true
        description: task id
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'

      responses:
        202:
          description: Canceling
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                task_can_not_canceled:
                  value:
                    error_code: 28019
                    desc: Bad/incomplete input data
                    detail: Task '146' with status 5 can not canceled
        404:
          description: task not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Task with id '146' not found
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
      - tasks

      summary: delete task
      description: delete task by id
      operationId: deleteTask
      parameters:
      - in: path
        name: task_id
        schema:
          type: integer
          minimum: 1
        required: true
        description: task id
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/account_id'

      responses:
        204:
          description: Deleted.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
        404:
          description: task not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Task with id '146' not found
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/tasks/{task_id}/result:
    get:
      tags:
      - tasks

      summary: get task result
      description: get task result by task id
      operationId: getTaskResult

      parameters:
      - in: path
        name: task_id
        schema:
          type: integer
          minimum: 1
        required: true
        description: task id
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      - $ref: '#/components/parameters/account_id'

      responses:
        200:
          description: OK
          headers:
            Content-Type:
              schema:
                type: string
                enum:
                - application/json
                - application/zip
              required: true
              description: content type of body
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Disposition:
              $ref: '#/components/headers/content_disposition'
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/GCTaskResult'
                - $ref: '#/components/schemas/ClusteringTaskResult'
                - $ref: '#/components/schemas/LinkerTaskResult'
                - $ref: '#/components/schemas/AdditionalExtractTaskResult'
                - $ref: '#/components/schemas/CrossMatchTaskResult'
                - $ref: '#/components/schemas/ROCTaskResult'
            application/zip:
              schema:
                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                      | external_id | handler_id                           | attribute_id                         | source | top_similar_face_id | top_similar_matching_candidates_label | top_similar_face_similarity | face_id                              | gender | age | emotion | ethnic_group | user_data                         | city   | area | district | street | house_number | latitude | longitude | mask |
                  |---------|--------------------------------------|----------------------------------|-------------|--------------------------------------|--------------------------------------|--------|---------------------|---------------------------------------|-----------------------------|--------------------------------------|--------|-----|---------|--------------|-----------------------------------|--------|------|----------|--------|--------------|----------|-----------|------|
                  | 0       | 6a4053de-17ab-40b5-bf2b-a1495df39085 | 2019-02-13T18:04:40.723800+03:00 |             | d727b3f5-e8ca-4fca-b092-d170ef5f9e49 | b3f9e82d-1654-4250-b39e-f8bbbca9880c |        |                     |                                       |                             | 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       | 110cc2d3-0350-418e-b956-90ef4dacbd23 | 2019-02-13T18:04:40.723800+03:00 |             | d727b3f5-e8ca-4fca-b092-d170ef5f9e49 | 3e1d0ffb-1fa6-449e-8c8b-8f9b56bfff6d |        |                     |                                       |                             | f4f17cbe-9197-4347-b214-692fa4ca9f26 | 0      | 24  |         | 2            | vl test events_with_created_faces | Moscow | CAA  | Arbat    | Arbat  | 1            | 12.34    |   56.78   |  1   |
                  | 2       | 9a9c9445-6a3d-4f4d-b22a-64601f4c8675 | 2019-02-13T18:04:40.723800+03:00 |             | d727b3f5-e8ca-4fca-b092-d170ef5f9e49 | 91a7fd34-0877-46f5-844c-e88fd28d68f0 |        |                     |                                       |                             | 83086070-bce2-40b9-a5c4-9df36a52fe4f | 0      | 19  |         | 4            | vl test events_with_created_faces | Moscow | CAA  | Arbat    | Arbat  | 1            | 12.34    |   56.78   |  1   |
                  | 2       | 979be9cd-6363-431a-a8a6-3f3fff806abf | 2019-02-13T18:04:40.723800+03:00 |             | d727b3f5-e8ca-4fca-b092-d170ef5f9e49 | 2cfacb32-fc7a-4abd-8518-0bf759acc4f9 |        |                     |                                       |                             | e09228a7-8a7e-4581-b550-d5c0818c871f | 0      | 28  |         | 4            | vl test events_with_created_faces | Moscow | CAA  | Arbat    | Arbat  | 1            | 12.34    |   56.78   |  1   |
                  | 3       | 60b86bf7-3395-40cf-90f0-4e0756f50b9e | 2019-02-13T18:04:40.723800+03:00 |             | d727b3f5-e8ca-4fca-b092-d170ef5f9e49 | 67c823db-8e3c-4638-abf9-63078d2687d5 |        |                     |                                       |                             | 301e8eb8-b6af-4c33-b5a1-6861509d2df4 | 1      | 56  |         | 4            | vl test events_with_created_faces | Moscow | CAA  | Arbat    | Arbat  | 1            | 12.34    |   56.78   |  1   |

        404:
          description: object not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                task_not_found:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Task with id '146' not found
                task_result_not_found:
                  value:
                    error_code: 28017
                    desc: Object not found
                    detail: Result of the task '146' not found
                task_does_not_have_result_yet:
                  value:
                    error_code: 28018
                    desc: Object not found
                    detail: task '146' does not have result yet
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/tasks/{task_id}/errors:
    get:
      tags:
      - errors

      summary: get errors of task
      description: get errors of task by task id
      operationId: getTaskErrors

      parameters:
      - in: path
        name: task_id
        schema:
          type: integer
          minimum: 1
        required: true
        description: task id
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/page_size'
      - $ref: '#/components/parameters/account_id'

      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                properties:
                  errors:
                    description: task errors
                    allOf:
                    - $ref: '#/components/schemas/TaskErrors'
                required: [errors]
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'create_time__lt'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/tasks/{task_id}/errors/count:
    get:
      tags:
      - errors

      summary: get error count of task
      description: get task error count by task id with filters
      operationId: getTaskErrorsCount

      parameters:
      - in: path
        name: task_id
        schema:
          type: integer
          minimum: 1
        required: true
        description: task id
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      - $ref: '#/components/parameters/error_time__lt'
      - $ref: '#/components/parameters/error_time__gte'
      - $ref: '#/components/parameters/error_code'
      - $ref: '#/components/parameters/account_id'

      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errorCount'
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'error_time__lt'
        404:
          description: object not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Task with id '49152' not found'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/tasks/{task_id}/subtasks:
    get:
      tags:
      - tasks

      summary: get subtasks
      description: get subtasks of task with filter(s)
      operationId: getSubTasks

      parameters:
      - in: path
        name: task_id
        schema:
          type: integer
          minimum: 1
        required: true
        description: task id
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      - $ref: '#/components/parameters/account_id'

      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubTasks'
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'create_time__lt'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/tasks/clustering:
    post:
      tags:
      - task processing

      summary: create a new clustering task
      description: Request to create a new clustering task
      operationId: createClusteringTask

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClusteringTask'
        required: true

      responses:
        202:
          description: Accepted
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  task_id:
                    $ref: '#/components/schemas/task_id'
                required:
                - task_id
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'create_time__lt'
        500:
          $ref: '#/components/responses/internal_server_error'
        504:
          $ref: '#/components/responses/server_timeout_error'
  /2/tasks/errors:
    get:
      tags:
      - errors

      summary: get errors
      description: get errors with filters
      operationId: getErrors

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/page_size'
      - $ref: '#/components/parameters/task_ids'
      - $ref: '#/components/parameters/error_code'
      - $ref: '#/components/parameters/error_ids'
      - $ref: '#/components/parameters/error_time__lt'
      - $ref: '#/components/parameters/error_time__gte'
      - $ref: '#/components/parameters/task_type'
      - $ref: '#/components/parameters/status_code'
      - $ref: '#/components/parameters/account_id'

      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                properties:
                  errors:
                    description: task errors
                    $ref: '#/components/schemas/TaskErrors'
                required: [errors]
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'create_time__lt'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/tasks/errors/count:
    get:
      tags:
      - errors

      summary: get errors count
      description: get errors count with filters
      operationId: getErrorsCount

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      - $ref: '#/components/parameters/error_time__lt'
      - $ref: '#/components/parameters/error_time__gte'
      - $ref: '#/components/parameters/task_type'
      - $ref: '#/components/parameters/task_ids'
      - $ref: '#/components/parameters/error_ids'
      - $ref: '#/components/parameters/error_code'
      - $ref: '#/components/parameters/account_id'

      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errorCount'
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'create_time__lt'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/tasks/errors/{error_id}:
    get:
      tags:
      - errors

      summary: get error
      description: get error
      operationId: getTaskError

      parameters:
      - in: path
        name: error_id
        schema:
          type: integer
          minimum: 1
        required: true
        description: error id
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'
      - $ref: '#/components/parameters/account_id'

      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskError'
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'create_time__lt'
        500:
          $ref: '#/components/responses/internal_server_error'
  /2/tasks/linker:
    post:
      tags:
      - task processing

      summary: linker task
      description: |
        Create new linker task.

        Task perfomance.

        - Firstly, it checks existence of specified *list_id* or create new list, if *create_list* parameter
          set to 1

        - It gets face ids from luna-faces or luna-events\* with filters and pagination. Then forms one or several subtasks
          with 1000(or less) face ids for each, and save content for each subtask into luna-image-store.

        - For each subtask: it gets subtask content (*list_id* and *face_ids* from luna-image-store) and
          do request to luna-faces to link specified faces to specified list. Each subtask saves results to
          luna-image-store with its own *result_id*

        - After the last subtask is done, it collect results from all subtasks, merge and put them to luna-image store
          with new *result_id* (as task result)

        \* for luna-events:
          - get event with its descriptor from Luna Events

          - create face, attribute(s) and sample(s) in Luna Faces

          - link created face to the list
      operationId: createLinkerTask

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LinkerTask'
        required: true

      responses:
        202:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  task_id:
                    $ref: '#/components/schemas/task_id'
                required:
                - task_id
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''Additional properties are not allowed (''userdata'' was unexpected)'''
        500:
          $ref: '#/components/responses/internal_server_error'
        504:
          $ref: '#/components/responses/server_timeout_error'
  /2/tasks/gc:
    post:
      tags:
      - task processing

      summary: garbage collecting task
      description: create new garbage collecting task
      operationId: createGCTask

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GcTask'
        required: true

      responses:
        202:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  task_id:
                    $ref: '#/components/schemas/task_id'
                required:
                - task_id
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''Additional properties are not allowed (''userdata'' was unexpected)'''
        500:
          $ref: '#/components/responses/internal_server_error'
        504:
          $ref: '#/components/responses/server_timeout_error'
  /2/tasks/reporter:
    post:
      tags:
      - task processing

      summary: reporter task
      description: |
        Create report in csv format by a task. Now support only clasterization tasks for reporting. Report contains
        additional info about clusterization objects (faces or events). You can set which additional info set to the
        report. First and second columns in report always a number of cluster and an object id.
      operationId: createReporterTask

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReporterTask'
        required: true

      responses:
        202:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  task_id:
                    $ref: '#/components/schemas/task_id'
                required:
                - task_id
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''Additional properties are not allowed (''userdata'' was unexpected)'''
                task_not_foud:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Task with id '147' not found
                bad_task_type:
                  value:
                    error_code: 28013
                    desc: Bad/incomplete input data
                    detail: Tasks with type '0' does not support a build report
                bad_task_status:
                  value:
                    error_code: 28015
                    desc: Bad/incomplete input data
                    detail: Tasks with type '0' does not support a build report


        500:
          $ref: '#/components/responses/internal_server_error'
        504:
          $ref: '#/components/responses/server_timeout_error'
  /2/tasks/additional_extract:
    post:
      tags:
      - task processing

      summary: additional extract task
      description: create new additional extract task, extraction of missing descriptors and base attributes is available.
      operationId: createAdditionalExtractTask

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AdditionalExtractTask'
        required: true

      responses:
        202:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  task_id:
                    $ref: '#/components/schemas/task_id'
                required:
                - task_id
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''Additional properties are not allowed (''userdata'' was unexpected)'''
        501:
          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
        500:
          $ref: '#/components/responses/internal_server_error'
        504:
          $ref: '#/components/responses/server_timeout_error'
  /2/tasks/cross_match:
    post:
      tags:
      - task processing

      summary: cross matching task
      description: Create cross matching task. Match references with candidates.

      operationId: createCrossMatchTask

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CrossMatchTask'
        required: true

      responses:
        202:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  task_id:
                    $ref: '#/components/schemas/task_id'
                required:
                - task_id
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''Additional properties are not allowed (''userdata'' was unexpected)'''
                task_not_foud:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Task with id '147' not found
                bad_task_type:
                  value:
                    error_code: 28013
                    desc: Bad/incomplete input data
                    detail: Tasks with type '0' does not support a build report
                bad_task_status:
                  value:
                    error_code: 28015
                    desc: Bad/incomplete input data
                    detail: Tasks with type '0' does not support a build report


        500:
          $ref: '#/components/responses/internal_server_error'
        504:
          $ref: '#/components/responses/server_timeout_error'
  /2/tasks/roc:
    post:
      tags:
      - task processing

      summary: ROC-curve calculating task
      description: create ROC task. ROC (or Receiver Operating Characteristic) is a performance measurement for classification problem at various thresholds settings. The ROC-curve is plotted with TPR (True Positive Rate) against the FPR (False Positive Rate). TPR is a true positive match pair count divided by a count of total expected positive match pairs, and FPR is a false positive match pair count divided by a count of total expected negative match pairs. Each point (FPR, TPR) of the ROC-cure corresponds to a certain similarity threshold. Using ROC the model performance is determined by looking at the area under the ROC-curve (or AUC) and the ROC-curve and the secondary main diagonal intersection point where type I and type II error rates are equal. The model performance also determined by getting into the top-N probability, i.e. probability of getting a positive match pair into the top-N for any match result group sorted by similarity.
      operationId: createROCTask

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/applicationJsonContent'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ROCTask'
        required: true

      responses:
        202:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                properties:
                  task_id:
                    $ref: '#/components/schemas/task_id'
                required:
                - task_id
        400:
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''Additional properties are not allowed (''userdata'' was unexpected)'''
                task_not_foud:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Task with id '147' not found
                bad_task_type:
                  value:
                    error_code: 28013
                    desc: Bad/incomplete input data
                    detail: Tasks with type '0' does not support a build report
                bad_task_status:
                  value:
                    error_code: 28015
                    desc: Bad/incomplete input data
                    detail: Tasks with type '0' does not support a build report


        500:
          $ref: '#/components/responses/internal_server_error'
        504:
          $ref: '#/components/responses/server_timeout_error'
  /2/docs/spec:
    get:
      tags:
        - documents
      summary: get openapi documentation
      description: |
        Get service OpenApi documentation. If *Accept* request header is of type `application/x-yaml`,
        returns documentation in `yaml` format or returns `html` documentation, if *Accept-Type* is `text/html`
      operationId: getSpec

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/accept_docs_handler'
      responses:
        200:
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/docs_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/x-yaml:
              schema:
                type: string
                description: yaml format documentation
            text/html:
              schema:
                type: string
                description: html format documentation
        415:
          description: Unsupported Media Type
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                unsupported_media_type:
                  value:
                    error_code: 12024
                    detail: 'Bad/incomplete input data'
                    desc: "Unsupported media type"
        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'
