// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import { APIPromise } from '../core/api-promise'; import { RequestOptions } from '../internal/request-options'; export class AnnotationTasks extends APIResource { /** * Update many annotation tasks in one request, operating in one of two mutually * exclusive modes. * * In ids mode, provide a list of task IDs together with an `assigned_to` and/or a * `status` (limited to `pending_redo` or `completed`) to apply those field changes * to each listed task; only tasks that currently exist are affected and IDs that * do not resolve are silently skipped. In audit_assignment mode, provide an * evaluation ID, queue ID, and evaluation item IDs to assign Level 1 and/or Level * 2 auditors for those items, creating the underlying audit tasks when they do not * yet exist; a Level 2 auditor cannot be assigned unless a Level 1 auditor is * already present. Exactly one of `ids` or `audit_assignment` must be supplied, * and `assigned_to`/`status` are only valid in ids mode. Access and state checks * run before any write, so the request is rejected as a whole with nothing * persisted if any task is inaccessible, if a status change is attempted without a * modification role, or if an already-completed task would be reassigned; audit * assignment also requires a modification role. Reassigning a task to a new user * emits a task-start lineage event, and the response returns the affected * annotation tasks. */ batchUpdate( body: AnnotationTaskBatchUpdateParams, options?: RequestOptions, ): APIPromise { return this._client.patch('/v5/annotation-tasks/batch', { body, ...options }); } } export interface AnnotationTask { id: string; evaluation_id: string; evaluation_item_id: string; priority: number; queue_id: string; status: 'NOT_READY' | 'PENDING' | 'PENDING_REDO' | 'COMPLETED' | 'FIXED'; task_type: 'EVALUATION_ANNOTATION' | 'EVALUATION_AUDIT' | 'CONTRIBUTOR_ANNOTATION' | 'CONTRIBUTOR_AUDIT'; updated_at: string; assigned_to?: string; assignment_expires_at?: string; duration_seconds?: number; flagged_for_review?: boolean; object?: 'annotation_task'; review_comment?: string; } export interface AnnotationTaskBatchUpdateResponse { items: Array; object?: 'list'; } export interface AnnotationTaskBatchUpdateParams { assigned_to?: string; audit_assignment?: AnnotationTaskBatchUpdateParams.AuditAssignment; ids?: Array; status?: 'PENDING_REDO' | 'COMPLETED'; } export namespace AnnotationTaskBatchUpdateParams { export interface AuditAssignment { evaluation_id: string; evaluation_item_ids: Array; queue_id: string; level_1_assigned_to?: string; level_2_assigned_to?: string; } } export declare namespace AnnotationTasks { export { type AnnotationTask as AnnotationTask, type AnnotationTaskBatchUpdateResponse as AnnotationTaskBatchUpdateResponse, type AnnotationTaskBatchUpdateParams as AnnotationTaskBatchUpdateParams, }; }