@@ -291,14 +291,15 @@ const api = new Api({ apiUrl: 'https://example.com' })`);
291291 }
292292 }
293293
294- async getTasks ( { page = 1 , perPage, withResults = false , parentTaskId } : { page ?: number ; perPage ?: number ; withResults ?: boolean ; parentTaskId ?: number } = { page : 1 , withResults : true } ) : Promise < PaginatedResponse < Task > > {
294+ async getTasks ( { page = 1 , perPage, withResults = false , parentTaskId, status } : { page ?: number ; perPage ?: number ; withResults ?: boolean ; parentTaskId ?: number ; status ?: string } = { page : 1 , withResults : true } ) : Promise < PaginatedResponse < Task > > {
295295 /**
296296 * Fetches tasks from the server, with optional result inclusion, pagination, and filtering.
297297 *
298298 * @param page The page number for pagination.
299299 * @param perPage The number of tasks to return per page.
300300 * @param withResults Whether to include the task results in the response.
301301 * @param parentTaskId Filter tasks by parent task ID.
302+ * @param status Filter tasks by status (pending, in_progress, completed, failed, aborted).
302303 * @return A dictionary containing the task results and pagination information.
303304 */
304305 const url = this . _makeApiUrl ( "tasks" ) ;
@@ -308,6 +309,7 @@ const api = new Api({ apiUrl: 'https://example.com' })`);
308309 if ( page !== undefined && page !== null ) params . page = page ;
309310 if ( perPage !== undefined && perPage !== null ) params . per_page = perPage ;
310311 if ( parentTaskId !== undefined && parentTaskId !== null ) params . parent_task_id = parentTaskId ;
312+ if ( status !== undefined && status !== null ) params . status = status ;
311313 try {
312314 const response = await axios . get ( url , { params } ) ;
313315
@@ -333,6 +335,10 @@ const api = new Api({ apiUrl: 'https://example.com' })`);
333335 }
334336 }
335337
338+ async getFailedTasks ( { page = 1 , perPage, withResults = false , parentTaskId } : { page ?: number ; perPage ?: number ; withResults ?: boolean ; parentTaskId ?: number } = { page : 1 , withResults : true } ) : Promise < PaginatedResponse < Task > > {
339+ return this . getTasks ( { page, perPage, withResults, parentTaskId, status : 'failed' } ) ;
340+ }
341+
336342 async getTask ( taskId : number ) : Promise < Task > {
337343 /**
338344 * Retrieves a specific task by ID.
@@ -572,4 +578,26 @@ const api = new Api({ apiUrl: 'https://example.com' })`);
572578 throw error ;
573579 }
574580 }
581+
582+ async retryTasks ( { taskIds } : { taskIds : number [ ] } ) : Promise < OkResponse > {
583+ /**
584+ * Bulk retries failed tasks.
585+ *
586+ * @param taskIds A list of task IDs to be retried.
587+ * @return A success message.
588+ */
589+ const url = this . _makeApiUrl ( "tasks/bulk-retry" ) ;
590+ const payload = { task_ids : taskIds } ;
591+ try {
592+ const response = await axios . post ( url , payload ) ;
593+
594+ this . _writeJson ( "retry_tasks" , response . data ) ;
595+ return response . data ;
596+ } catch ( error ) {
597+ if ( axios . isAxiosError ( error ) ) {
598+ raiseIfBadException ( error . response as AxiosResponse ) ;
599+ }
600+ throw error ;
601+ }
602+ }
575603}
0 commit comments