1212from servicelib .aiohttp .long_running_tasks ._routes import _PathParam
1313from servicelib .long_running_tasks .models import TaskGet , TaskStatus
1414from simcore_service_webserver ._meta import API_VTAG
15- from simcore_service_webserver .tasks ._exception_handlers import (
16- _TO_HTTP_ERROR_MAP as export_data_http_error_map ,
17- )
15+ from simcore_service_webserver .tasks ._exception_handlers import _TO_HTTP_ERROR_MAP
1816
1917router = APIRouter (
2018 prefix = f"/{ API_VTAG } " ,
2321 ],
2422)
2523
26- _export_data_responses : dict [int | str , dict [str , Any ]] = {
27- i .status_code : {"model" : EnvelopedError }
28- for i in export_data_http_error_map .values ()
24+ _responses : dict [int | str , dict [str , Any ]] = {
25+ i .status_code : {"model" : EnvelopedError } for i in _TO_HTTP_ERROR_MAP .values ()
2926}
3027
3128
3229@router .get (
3330 "/tasks" ,
3431 response_model = Envelope [list [TaskGet ]],
35- responses = _export_data_responses ,
32+ responses = _responses ,
3633)
37- def get_async_jobs ():
34+ def list_tasks ():
3835 """Lists all long running tasks"""
3936
4037
4138@router .get (
4239 "/tasks/{task_id}" ,
4340 response_model = Envelope [TaskStatus ],
44- responses = _export_data_responses ,
41+ responses = _responses ,
4542)
46- def get_async_job_status (
43+ def get_task_status (
4744 _path_params : Annotated [_PathParam , Depends ()],
4845):
4946 """Retrieves the status of a task"""
5047
5148
49+ @router .get (
50+ "/tasks/{task_id}/stream" ,
51+ )
52+ def get_task_stream (
53+ _path_params : Annotated [_PathParam , Depends ()],
54+ ):
55+ """Retrieves the stream of a task"""
56+
57+
5258@router .delete (
5359 "/tasks/{task_id}" ,
54- responses = _export_data_responses ,
60+ responses = _responses ,
5561 status_code = status .HTTP_204_NO_CONTENT ,
5662)
57- def cancel_async_job (
63+ def cancel_task (
5864 _path_params : Annotated [_PathParam , Depends ()],
5965):
6066 """Cancels and removes a task"""
@@ -63,9 +69,9 @@ def cancel_async_job(
6369@router .get (
6470 "/tasks/{task_id}/result" ,
6571 response_model = Any ,
66- responses = _export_data_responses ,
72+ responses = _responses ,
6773)
68- def get_async_job_result (
74+ def get_task_result (
6975 _path_params : Annotated [_PathParam , Depends ()],
7076):
7177 """Retrieves the result of a task"""
0 commit comments