Skip to content

Commit 529a9c5

Browse files
committed
add get_solver_page endpoint
1 parent 62d8244 commit 529a9c5

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

services/api-server/src/simcore_service_api_server/api/routes/solvers.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from common_library.pagination_tools import iter_pagination_params
77
from fastapi import APIRouter, Depends, HTTPException, status
8+
from fastapi_pagination import create_page
89
from httpx import HTTPStatusError
910
from models_library.api_schemas_catalog.services import ServiceListFilters
1011
from models_library.rest_pagination import MAXIMUM_NUMBER_OF_ITEMS_PER_PAGE
@@ -99,14 +100,21 @@ async def list_solvers(
99100
@router.get(
100101
"/page",
101102
response_model=Page[Solver],
102-
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
103-
status_code=status.HTTP_501_NOT_IMPLEMENTED,
104103
)
105104
async def get_solvers_page(
106105
page_params: Annotated[PaginationParams, Depends()],
106+
user_id: Annotated[int, Depends(get_current_user_id)],
107+
product_name: Annotated[str, Depends(get_product_name)],
108+
solver_service: Annotated[SolverService, Depends(SolverService)],
107109
):
108-
msg = f"list solvers with pagination={page_params!r}"
109-
raise NotImplementedError(msg)
110+
"""Lists all available solvers (latest version) with pagination"""
111+
solvers, page_meta = await solver_service.latest_solvers(
112+
user_id=user_id,
113+
product_name=product_name,
114+
offset=page_params.offset,
115+
limit=page_params.limit,
116+
)
117+
return create_page(solvers, total=len(solvers), params=page_params)
110118

111119

112120
@router.get(

services/api-server/tests/unit/api_solvers/test_api_routers_solvers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,12 @@ async def test_list_solver_releases_with_mocked_catalog(
107107
):
108108
response = await client.get(f"/{API_VTAG}/solvers/releases", auth=auth)
109109
assert response.status_code == status.HTTP_200_OK
110+
111+
112+
async def test_list_solver_page_with_mocked_catalog(
113+
client: httpx.AsyncClient,
114+
mocked_rpc_catalog_service_api: dict,
115+
auth: httpx.BasicAuth,
116+
):
117+
response = await client.get(f"/{API_VTAG}/solvers/page", auth=auth)
118+
assert response.status_code == status.HTTP_200_OK

0 commit comments

Comments
 (0)