Skip to content

Commit

Permalink
@GitHK: envelope is done automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Jun 30, 2022
1 parent 348e258 commit e7124b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# Exclusive for simcore-s3 storage -----------------------
from ._meta import api_vtag
from .models import (
DatasetMetaData,
FileMetaData,
FilesMetadataDatasetPathParams,
LocationPathParams,
Expand All @@ -37,8 +36,7 @@ async def get_datasets_metadata(request: web.Request):
)

dsm = get_dsm_provider(request.app).get(path_params.location_id)
data: list[DatasetMetaData] = await dsm.list_datasets(query_params.user_id)
return {"data": data}
return await dsm.list_datasets(query_params.user_id)


@routes.get(f"/{api_vtag}/locations/{{location_id}}/datasets/{{dataset_id}}/metadata", name="get_files_metadata_dataset") # type: ignore
Expand All @@ -56,5 +54,4 @@ async def get_files_metadata_dataset(request: web.Request):
user_id=query_params.user_id,
dataset_id=path_params.dataset_id,
)
py_data = [jsonable_encoder(FileMetaDataGet.from_orm(d)) for d in data]
return {"data": py_data}
return [jsonable_encoder(FileMetaDataGet.from_orm(d)) for d in data]
11 changes: 4 additions & 7 deletions services/storage/src/simcore_service_storage/handlers_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ async def get_files_metadata(request: web.Request):
user_id=query_params.user_id,
uuid_filter=query_params.uuid_filter,
)
py_data = [jsonable_encoder(FileMetaDataGet.from_orm(d)) for d in data]
return {"data": py_data}
return [jsonable_encoder(FileMetaDataGet.from_orm(d)) for d in data]


@routes.get(
Expand All @@ -77,9 +76,7 @@ async def get_file_metadata(request: web.Request):
# TODO: once all legacy services are gone, remove the try except, it will default to 404
return {"error": "No result found", "data": {}}

return {
"data": jsonable_encoder(FileMetaDataGet.from_orm(data)),
}
return jsonable_encoder(FileMetaDataGet.from_orm(data))


@routes.get(f"/{api_vtag}/locations/{{location_id}}/files/{{file_id}}", name="download_file") # type: ignore
Expand All @@ -94,7 +91,7 @@ async def download_file(request: web.Request):
link = await dsm.create_file_download_link(
query_params.user_id, path_params.file_id, query_params.link_type
)
return {"error": None, "data": {"link": link}}
return {"link": link}


@routes.put(f"/{api_vtag}/locations/{{location_id}}/files/{{file_id}}", name="upload_file") # type: ignore
Expand All @@ -114,7 +111,7 @@ async def upload_file(request: web.Request):
link_type=query_params.link_type,
)

return {"data": {"link": jsonable_encoder(link, by_alias=True)}}
return {"link": jsonable_encoder(link, by_alias=True)}


@routes.post(f"/{api_vtag}/locations/{{location_id}}/files/{{file_id}}:abort", name="abort_upload_file") # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,4 @@ async def search_files_starting_with(request: web.Request):
)
log.debug("Found %d files starting with '%s'", len(data), query_params.startswith)

py_data = [jsonable_encoder(FileMetaDataGet.from_orm(d)) for d in data]
return py_data
return [jsonable_encoder(FileMetaDataGet.from_orm(d)) for d in data]

0 comments on commit e7124b3

Please sign in to comment.