Skip to content

Commit 06c4640

Browse files
fix: oas
1 parent f8b5729 commit 06c4640

File tree

6 files changed

+57
-34
lines changed

6 files changed

+57
-34
lines changed

api/specs/web-server/_long_running_tasks.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from servicelib.long_running_tasks.models import TaskGet, TaskStatus
1414
from simcore_service_webserver._meta import API_VTAG
1515
from simcore_service_webserver.tasks._exception_handlers import (
16-
_TO_HTTP_ERROR_MAP as export_data_http_error_map,
16+
_TO_HTTP_ERROR_MAP,
1717
)
1818

1919
router = APIRouter(
@@ -23,16 +23,15 @@
2323
],
2424
)
2525

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()
26+
_responses: dict[int | str, dict[str, Any]] = {
27+
i.status_code: {"model": EnvelopedError} for i in _TO_HTTP_ERROR_MAP.values()
2928
}
3029

3130

3231
@router.get(
3332
"/tasks",
3433
response_model=Envelope[list[TaskGet]],
35-
responses=_export_data_responses,
34+
responses=_responses,
3635
)
3736
def get_async_jobs():
3837
"""Lists all long running tasks"""
@@ -41,7 +40,7 @@ def get_async_jobs():
4140
@router.get(
4241
"/tasks/{task_id}",
4342
response_model=Envelope[TaskStatus],
44-
responses=_export_data_responses,
43+
responses=_responses,
4544
)
4645
def get_async_job_status(
4746
_path_params: Annotated[_PathParam, Depends()],
@@ -51,7 +50,7 @@ def get_async_job_status(
5150

5251
@router.delete(
5352
"/tasks/{task_id}",
54-
responses=_export_data_responses,
53+
responses=_responses,
5554
status_code=status.HTTP_204_NO_CONTENT,
5655
)
5756
def cancel_async_job(
@@ -63,7 +62,7 @@ def cancel_async_job(
6362
@router.get(
6463
"/tasks/{task_id}/result",
6564
response_model=Any,
66-
responses=_export_data_responses,
65+
responses=_responses,
6766
)
6867
def get_async_job_result(
6968
_path_params: Annotated[_PathParam, Depends()],

api/specs/web-server/_storage.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
from typing import Annotated, Any, TypeAlias
88

99
from fastapi import APIRouter, Depends, Query, status
10-
from models_library.api_schemas_long_running_tasks.tasks import (
11-
TaskGet,
12-
)
10+
from models_library.api_schemas_long_running_tasks.tasks import TaskGet
1311
from models_library.api_schemas_storage.storage_schemas import (
1412
FileLocation,
1513
FileMetaDataGet,
@@ -25,9 +23,9 @@
2523
BatchDeletePathsBodyParams,
2624
DataExportPost,
2725
ListPathsQueryParams,
26+
SearchBodyParams,
2827
StorageLocationPathParams,
2928
StoragePathComputeSizeParams,
30-
SearchBodyParams
3129
)
3230
from models_library.generics import Envelope
3331
from models_library.projects_nodes_io import LocationID
@@ -37,7 +35,7 @@
3735
from simcore_service_webserver._meta import API_VTAG
3836
from simcore_service_webserver.storage.schemas import DatasetMetaData, FileMetaData
3937
from simcore_service_webserver.tasks._exception_handlers import (
40-
_TO_HTTP_ERROR_MAP as export_data_http_error_map,
38+
_TO_HTTP_ERROR_MAP,
4139
)
4240

4341
router = APIRouter(
@@ -221,29 +219,30 @@ async def is_completed_upload_file(
221219
"""Returns state of upload completion"""
222220

223221

224-
# data export
225-
_export_data_responses: dict[int | str, dict[str, Any]] = {
226-
i.status_code: {"model": EnvelopedError}
227-
for i in export_data_http_error_map.values()
222+
_responses: dict[int | str, dict[str, Any]] = {
223+
i.status_code: {"model": EnvelopedError} for i in _TO_HTTP_ERROR_MAP.values()
228224
}
229225

230226

231227
@router.post(
232228
"/storage/locations/{location_id}/export-data",
229+
status_code=status.HTTP_202_ACCEPTED,
233230
response_model=Envelope[TaskGet],
234231
name="export_data",
235232
description="Export data",
236-
responses=_export_data_responses,
233+
responses=_responses,
237234
)
238235
async def export_data(export_data: DataExportPost, location_id: LocationID):
239236
"""Trigger data export. Returns async job id for getting status and results"""
240237

241238

242239
@router.post(
243240
"/storage/locations/{location_id}/search",
241+
status_code=status.HTTP_202_ACCEPTED,
244242
response_model=Envelope[TaskGet],
245243
name="search",
246244
description="Starts a files/folders search",
245+
responses=_responses,
247246
)
248247
async def search(
249248
_path: Annotated[StorageLocationPathParams, Depends()],

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7939,7 +7939,7 @@ paths:
79397939
schema:
79407940
$ref: '#/components/schemas/DataExportPost'
79417941
responses:
7942-
'200':
7942+
'202':
79437943
description: Successful Response
79447944
content:
79457945
application/json:
@@ -7974,7 +7974,7 @@ paths:
79747974
tags:
79757975
- storage
79767976
summary: Search
7977-
description: Search
7977+
description: Starts a files/folders search
79787978
operationId: search
79797979
parameters:
79807980
- name: location_id
@@ -7990,12 +7990,36 @@ paths:
79907990
schema:
79917991
$ref: '#/components/schemas/SearchBodyParams'
79927992
responses:
7993-
'200':
7993+
'202':
79947994
description: Successful Response
79957995
content:
79967996
application/json:
79977997
schema:
79987998
$ref: '#/components/schemas/Envelope_TaskGet_'
7999+
'404':
8000+
content:
8001+
application/json:
8002+
schema:
8003+
$ref: '#/components/schemas/EnvelopedError'
8004+
description: Not Found
8005+
'403':
8006+
content:
8007+
application/json:
8008+
schema:
8009+
$ref: '#/components/schemas/EnvelopedError'
8010+
description: Forbidden
8011+
'410':
8012+
content:
8013+
application/json:
8014+
schema:
8015+
$ref: '#/components/schemas/EnvelopedError'
8016+
description: Gone
8017+
'500':
8018+
content:
8019+
application/json:
8020+
schema:
8021+
$ref: '#/components/schemas/EnvelopedError'
8022+
description: Internal Server Error
79998023
/v0/trash:empty:
80008024
post:
80018025
tags:

services/web/server/src/simcore_service_webserver/storage/_rest.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@
4747
from servicelib.rabbitmq.rpc_interfaces.storage.paths import (
4848
delete_paths as remote_delete_paths,
4949
)
50-
from servicelib.rabbitmq.rpc_interfaces.storage.simcore_s3 import start_export_data, start_search
50+
from servicelib.rabbitmq.rpc_interfaces.storage.simcore_s3 import (
51+
start_export_data,
52+
start_search,
53+
)
5154
from servicelib.request_keys import RQT_USERID_KEY
5255
from servicelib.rest_responses import unwrap_envelope
5356
from yarl import URL
@@ -57,7 +60,7 @@
5760
from ..models import AuthenticatedRequestContext
5861
from ..rabbitmq import get_rabbitmq_rpc_client
5962
from ..security.decorators import permission_required
60-
from ..tasks._exception_handlers import handle_export_data_exceptions
63+
from ..tasks._exception_handlers import handle_exceptions
6164
from ..utils import get_job_filter
6265
from .schemas import StorageFileIDStr
6366
from .settings import StorageSettings, get_plugin_settings
@@ -481,7 +484,7 @@ class _PathParams(BaseModel):
481484
)
482485
@login_required
483486
@permission_required("storage.files.*")
484-
@handle_export_data_exceptions
487+
@handle_exceptions
485488
async def export_data(request: web.Request) -> web.Response:
486489
class _PathParams(BaseModel):
487490
location_id: LocationID
@@ -521,12 +524,10 @@ def allow_only_simcore(cls, v: int) -> int:
521524
)
522525

523526

524-
@routes.post(
525-
_storage_locations_prefix + "/{location_id}/search", name="search"
526-
)
527+
@routes.post(_storage_locations_prefix + "/{location_id}/search", name="search")
527528
@login_required
528529
@permission_required("storage.files.*")
529-
@handle_export_data_exceptions
530+
@handle_exceptions
530531
async def search(request: web.Request) -> web.Response:
531532
class _PathParams(BaseModel):
532533
location_id: LocationID

services/web/server/src/simcore_service_webserver/tasks/_exception_handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@
6969
}
7070

7171

72-
handle_export_data_exceptions = exception_handling_decorator(
72+
handle_exceptions = exception_handling_decorator(
7373
to_exceptions_handlers_map(_TO_HTTP_ERROR_MAP)
7474
)

services/web/server/src/simcore_service_webserver/tasks/_rest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from ..rabbitmq import get_rabbitmq_rpc_client
3838
from ..security.decorators import permission_required
3939
from ..utils import get_job_filter
40-
from ._exception_handlers import handle_export_data_exceptions
40+
from ._exception_handlers import handle_exceptions
4141

4242
log = logging.getLogger(__name__)
4343

@@ -53,7 +53,7 @@
5353
)
5454
@login_required
5555
@permission_required("storage.files.*")
56-
@handle_export_data_exceptions
56+
@handle_exceptions
5757
@webserver_request_context_decorator
5858
async def get_async_jobs(request: web.Request) -> web.Response:
5959
inprocess_long_running_manager = get_long_running_manager(request.app)
@@ -108,7 +108,7 @@ class _StorageAsyncJobId(BaseModel):
108108
name="get_async_job_status",
109109
)
110110
@login_required
111-
@handle_export_data_exceptions
111+
@handle_exceptions
112112
async def get_async_job_status(request: web.Request) -> web.Response:
113113

114114
_req_ctx = AuthenticatedRequestContext.model_validate(request)
@@ -143,7 +143,7 @@ async def get_async_job_status(request: web.Request) -> web.Response:
143143
)
144144
@login_required
145145
@permission_required("storage.files.*")
146-
@handle_export_data_exceptions
146+
@handle_exceptions
147147
async def cancel_async_job(request: web.Request) -> web.Response:
148148

149149
_req_ctx = AuthenticatedRequestContext.model_validate(request)
@@ -170,7 +170,7 @@ async def cancel_async_job(request: web.Request) -> web.Response:
170170
)
171171
@login_required
172172
@permission_required("storage.files.*")
173-
@handle_export_data_exceptions
173+
@handle_exceptions
174174
async def get_async_job_result(request: web.Request) -> web.Response:
175175
class _PathParams(BaseModel):
176176
task_id: UUID

0 commit comments

Comments
 (0)