Skip to content

Commit 47471a5

Browse files
committed
ongoing
1 parent 668446a commit 47471a5

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

api/specs/web-server/_storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from uuid import UUID
99

1010
from fastapi import APIRouter, Depends, Query, status
11-
from fastapi_pagination.cursor import CursorPage
1211
from models_library.api_schemas_storage.storage_schemas import (
1312
FileLocation,
1413
FileMetaDataGet,
@@ -22,6 +21,7 @@
2221
)
2322
from models_library.api_schemas_webserver.storage import (
2423
DataExportPost,
24+
LargeLimitedPage,
2525
ListPathsQueryParams,
2626
StorageAsyncJobGet,
2727
StorageAsyncJobResult,
@@ -59,7 +59,7 @@ async def list_storage_locations():
5959

6060
@router.get(
6161
"/storage/locations/{location_id}/paths",
62-
response_model=CursorPage[PathMetaDataGet],
62+
response_model=LargeLimitedPage[PathMetaDataGet],
6363
)
6464
async def list_storage_paths(
6565
_path: Annotated[StorageLocationPathParams, Depends()],

packages/models-library/src/models_library/api_schemas_webserver/storage.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from datetime import datetime
22
from pathlib import Path
3-
from typing import Any
3+
from typing import Any, TypeVar
44

5+
from fastapi import Query
6+
from fastapi_pagination.cursor import CursorPage
7+
from fastapi_pagination.customization import CustomizedPage, UseParamsFields
58
from pydantic import BaseModel
69

710
from ..api_schemas_rpc_async_jobs.async_jobs import (
@@ -16,6 +19,21 @@
1619
from ..rest_pagination import CursorQueryParameters
1720
from ._base import InputSchema, OutputSchema
1821

22+
_T = TypeVar("_T")
23+
24+
LargeLimitedPage = CustomizedPage[
25+
CursorPage[_T],
26+
# Customizes the maximum value to fit frontend needs
27+
UseParamsFields(
28+
size=Query(
29+
50,
30+
ge=1,
31+
le=1000,
32+
description="Page size",
33+
)
34+
),
35+
]
36+
1937

2038
class StorageLocationPathParams(BaseModel):
2139
location_id: LocationID

services/storage/openapi.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,7 +1060,7 @@
10601060
"content": {
10611061
"application/json": {
10621062
"schema": {
1063-
"$ref": "#/components/schemas/CursorPage__T_Customized_PathMetaDataGet_"
1063+
"$ref": "#/components/schemas/CursorPage___T_Customized_PathMetaDataGet_"
10641064
}
10651065
}
10661066
}
@@ -1419,7 +1419,7 @@
14191419
],
14201420
"title": "AppStatusCheck"
14211421
},
1422-
"CursorPage__T_Customized_PathMetaDataGet_": {
1422+
"CursorPage___T_Customized_PathMetaDataGet_": {
14231423
"properties": {
14241424
"items": {
14251425
"items": {
@@ -1493,7 +1493,7 @@
14931493
"required": [
14941494
"items"
14951495
],
1496-
"title": "CursorPage[~T]Customized[PathMetaDataGet]"
1496+
"title": "CursorPage[~_T]Customized[PathMetaDataGet]"
14971497
},
14981498
"DatasetMetaDataGet": {
14991499
"properties": {

services/storage/src/simcore_service_storage/api/rest/_paths.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import logging
22
from pathlib import Path
3-
from typing import Annotated, TypeVar
3+
from typing import Annotated
44

5-
from fastapi import APIRouter, Depends, Query
5+
from fastapi import APIRouter, Depends
66
from fastapi_pagination import create_page, resolve_params
7-
from fastapi_pagination.cursor import CursorPage
8-
from fastapi_pagination.customization import CustomizedPage, UseParamsFields
97
from models_library.api_schemas_storage.storage_schemas import PathMetaDataGet
8+
from models_library.api_schemas_webserver.storage import LargeLimitedPage
109
from models_library.users import UserID
1110

1211
from ...dsm_factory import BaseDataManager
@@ -20,32 +19,17 @@
2019
],
2120
)
2221

23-
T = TypeVar("T")
24-
25-
Page = CustomizedPage[
26-
CursorPage[T],
27-
# Customizes the maximum value to fit frontend needs
28-
UseParamsFields(
29-
size=Query(
30-
50,
31-
ge=1,
32-
le=1000,
33-
description="Page size",
34-
)
35-
),
36-
]
37-
3822

3923
@router.get(
4024
"/locations/{location_id}/paths",
41-
response_model=Page[PathMetaDataGet],
25+
response_model=LargeLimitedPage[PathMetaDataGet],
4226
)
4327
async def list_paths(
44-
page_params: Annotated[Page.__params_type__, Depends()],
28+
page_params: Annotated[LargeLimitedPage.__params_type__, Depends()],
4529
dsm: Annotated[BaseDataManager, Depends(get_data_manager)],
4630
user_id: UserID,
4731
file_filter: Path | None = None,
48-
) -> Page[PathMetaDataGet]:
32+
) -> LargeLimitedPage[PathMetaDataGet]:
4933
"""Returns one level of files (paginated)"""
5034
page_params = resolve_params()
5135
items, next_cursor, total_number = await dsm.list_paths(

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6035,7 +6035,7 @@ paths:
60356035
content:
60366036
application/json:
60376037
schema:
6038-
$ref: '#/components/schemas/CursorPage_PathMetaDataGet_'
6038+
$ref: '#/components/schemas/CursorPage___T_Customized_PathMetaDataGet_'
60396039
/v0/storage/locations/{location_id}/datasets:
60406040
get:
60416041
tags:
@@ -8404,7 +8404,7 @@ components:
84048404
- usdPerCredit
84058405
- minPaymentAmountUsd
84068406
title: CreditPriceGet
8407-
CursorPage_PathMetaDataGet_:
8407+
CursorPage___T_Customized_PathMetaDataGet_:
84088408
properties:
84098409
items:
84108410
items:
@@ -8444,7 +8444,7 @@ components:
84448444
type: object
84458445
required:
84468446
- items
8447-
title: CursorPage[PathMetaDataGet]
8447+
title: CursorPage[~_T]Customized[PathMetaDataGet]
84488448
DatCoreFileLink:
84498449
properties:
84508450
store:

0 commit comments

Comments
 (0)