forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start developing an webapi rpc client
- Loading branch information
1 parent
a41e126
commit deed91a
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
services/api-server/src/simcore_service_api_server/services_rpc/wb_api_server.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from dataclasses import dataclass | ||
|
||
from fastapi_pagination import Page, create_page | ||
from servicelib.rabbitmq._client_rpc import RabbitMQRPCClient | ||
from servicelib.rabbitmq.rpc_interfaces.webserver.licenses.licensed_items import ( | ||
get_licensed_items as _get_licensed_items, | ||
) | ||
from simcore_service_api_server.models.pagination import PaginationParams | ||
|
||
from ..models.schemas.model_adapter import LicensedItemGet | ||
|
||
|
||
@dataclass | ||
class WbApiRpcClient: | ||
_rabbitmq_rpc_client: RabbitMQRPCClient | ||
|
||
async def get_licensed_items( | ||
self, product_name: str, page_params: PaginationParams | ||
) -> Page[LicensedItemGet]: | ||
licensed_items_page = await _get_licensed_items( | ||
rabbitmq_rpc_client=self._rabbitmq_rpc_client, | ||
product_name=product_name, | ||
offset=page_params.offset, | ||
limit=page_params.limit, | ||
) | ||
return create_page( | ||
[ | ||
LicensedItemGet.model_validate(elm.model_dump()) | ||
for elm in licensed_items_page.items | ||
], | ||
total=licensed_items_page.total, | ||
params=page_params, | ||
) |