diff --git a/api/specs/web-server/_long_running_tasks_legacy.py b/api/specs/web-server/_long_running_tasks_legacy.py new file mode 100644 index 000000000000..fcbe3508c4dc --- /dev/null +++ b/api/specs/web-server/_long_running_tasks_legacy.py @@ -0,0 +1,61 @@ +# pylint: disable=redefined-outer-name +# pylint: disable=unused-argument +# pylint: disable=unused-variable +# pylint: disable=too-many-arguments + + +from typing import Annotated + +from fastapi import APIRouter, Depends, status +from models_library.generics import Envelope +from servicelib.aiohttp.long_running_tasks._routes import _PathParam +from servicelib.long_running_tasks._models import TaskGet, TaskStatus +from simcore_service_webserver._meta import API_VTAG + +router = APIRouter( + prefix=f"/{API_VTAG}/tasks-legacy", + tags=[ + "long-running-tasks-legacy", + ], +) + + +@router.get( + "", + response_model=Envelope[list[TaskGet]], + name="list_tasks", + description="Lists all long running tasks", +) +def list_tasks(): ... + + +@router.get( + "/{task_id}", + response_model=Envelope[TaskStatus], + name="get_task_status", + description="Retrieves the status of a task", +) +def get_task_status( + _path_params: Annotated[_PathParam, Depends()], +): ... + + +@router.delete( + "/{task_id}", + name="cancel_and_delete_task", + description="Cancels and deletes a task", + status_code=status.HTTP_204_NO_CONTENT, +) +def cancel_and_delete_task( + _path_params: Annotated[_PathParam, Depends()], +): ... + + +@router.get( + "/{task_id}/result", + name="get_task_result", + description="Retrieves the result of a task", +) +def get_task_result( + _path_params: Annotated[_PathParam, Depends()], +): ... diff --git a/api/specs/web-server/openapi.py b/api/specs/web-server/openapi.py index b6fdf69a8e4e..bb32e30f0520 100644 --- a/api/specs/web-server/openapi.py +++ b/api/specs/web-server/openapi.py @@ -36,6 +36,7 @@ "_exporter", "_folders", "_long_running_tasks", + "_long_running_tasks_legacy", "_licensed_items", "_licensed_items_purchases", "_licensed_items_checkouts", diff --git a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml index cafdb4e16c5d..4ba28dd4bee8 100644 --- a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml +++ b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml @@ -3125,6 +3125,77 @@ paths: schema: $ref: '#/components/schemas/EnvelopedError' description: Internal Server Error + /v0/tasks-legacy: + get: + tags: + - long-running-tasks-legacy + summary: List Tasks + description: Lists all long running tasks + operationId: list_tasks + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/Envelope_list_TaskGet__' + /v0/tasks-legacy/{task_id}: + get: + tags: + - long-running-tasks-legacy + summary: Get Task Status + description: Retrieves the status of a task + operationId: get_task_status + parameters: + - name: task_id + in: path + required: true + schema: + type: string + title: Task Id + responses: + '200': + description: Successful Response + content: + application/json: + schema: + $ref: '#/components/schemas/Envelope_TaskStatus_' + delete: + tags: + - long-running-tasks-legacy + summary: Cancel And Delete Task + description: Cancels and deletes a task + operationId: cancel_and_delete_task + parameters: + - name: task_id + in: path + required: true + schema: + type: string + title: Task Id + responses: + '204': + description: Successful Response + /v0/tasks-legacy/{task_id}/result: + get: + tags: + - long-running-tasks-legacy + summary: Get Task Result + description: Retrieves the result of a task + operationId: get_task_result + parameters: + - name: task_id + in: path + required: true + schema: + type: string + title: Task Id + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} /v0/catalog/licensed-items: get: tags: diff --git a/services/web/server/tests/unit/with_dbs/03/test__openapi_specs.py b/services/web/server/tests/unit/with_dbs/03/test__openapi_specs.py index 9c6ad78f4a8d..886817bbf263 100644 --- a/services/web/server/tests/unit/with_dbs/03/test__openapi_specs.py +++ b/services/web/server/tests/unit/with_dbs/03/test__openapi_specs.py @@ -13,7 +13,6 @@ from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict from pytest_simcore.helpers.typing_env import EnvVarsDict from pytest_simcore.openapi_specs import Entrypoint -from simcore_service_webserver._meta import API_VTAG from simcore_service_webserver.application import create_application from simcore_service_webserver.application_settings import get_application_settings from simcore_service_webserver.rest._utils import get_openapi_specs_path @@ -76,16 +75,7 @@ def test_app_named_resources_against_openapi_specs( openapi_specs_entrypoints: set[Entrypoint], app_rest_entrypoints: set[Entrypoint], ): - # remove task-legacy routes. These should not be exposed. - # this test compares directly against the openapi specs. In future it would be - # cleaner to compare against the fastapi app entry points in specs and - # avoid including the endpoints there - required_entry_points = { - e - for e in app_rest_entrypoints - if not e.path.startswith(f"/{API_VTAG}/tasks-legacy") - } - assert required_entry_points == openapi_specs_entrypoints + assert app_rest_entrypoints == openapi_specs_entrypoints # NOTE: missing here is: # - input schemas (path, query and body)