-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/search-users
- Loading branch information
Showing
22 changed files
with
664 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" Helper script to generate OAS automatically | ||
""" | ||
|
||
# pylint: disable=redefined-outer-name | ||
# pylint: disable=unused-argument | ||
# pylint: disable=unused-variable | ||
# pylint: disable=too-many-arguments | ||
|
||
from typing import Annotated | ||
|
||
from _common import as_query | ||
from fastapi import APIRouter, Depends | ||
from models_library.api_schemas_webserver.licensed_items_purchases import ( | ||
LicensedItemPurchaseGet, | ||
) | ||
from models_library.generics import Envelope | ||
from models_library.rest_error import EnvelopedError | ||
from models_library.rest_pagination import Page | ||
from simcore_service_webserver._meta import API_VTAG | ||
from simcore_service_webserver.licenses._exceptions_handlers import _TO_HTTP_ERROR_MAP | ||
from simcore_service_webserver.licenses._licensed_items_checkouts_models import ( | ||
LicensedItemCheckoutPathParams, | ||
LicensedItemsCheckoutsListQueryParams, | ||
) | ||
from simcore_service_webserver.wallets._handlers import WalletsPathParams | ||
|
||
router = APIRouter( | ||
prefix=f"/{API_VTAG}", | ||
tags=[ | ||
"licenses", | ||
], | ||
responses={ | ||
i.status_code: {"model": EnvelopedError} for i in _TO_HTTP_ERROR_MAP.values() | ||
}, | ||
) | ||
|
||
|
||
@router.get( | ||
"/wallets/{wallet_id}/licensed-items-checkouts", | ||
response_model=Page[LicensedItemPurchaseGet], | ||
tags=["wallets"], | ||
) | ||
async def list_licensed_item_checkouts_for_wallet( | ||
_path: Annotated[WalletsPathParams, Depends()], | ||
_query: Annotated[as_query(LicensedItemsCheckoutsListQueryParams), Depends()], | ||
): | ||
... | ||
|
||
|
||
@router.get( | ||
"/licensed-items-checkouts/{licensed_item_checkout_id}", | ||
response_model=Envelope[LicensedItemPurchaseGet], | ||
) | ||
async def get_licensed_item_checkout( | ||
_path: Annotated[LicensedItemCheckoutPathParams, Depends()], | ||
): | ||
... |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
from fastapi import APIRouter, Depends, Header, HTTPException, status | ||
from models_library.api_schemas_catalog.services import ServiceGet, ServiceUpdate | ||
from models_library.services import ServiceKey, ServiceType, ServiceVersion | ||
from models_library.services_authoring import Author | ||
from models_library.services_metadata_published import ServiceMetaDataPublished | ||
from pydantic import ValidationError | ||
from pydantic.types import PositiveInt | ||
|
@@ -127,7 +128,11 @@ async def list_services( | |
name="nodetails", | ||
description="nodetails", | ||
type=ServiceType.COMPUTATIONAL, | ||
authors=[{"name": "nodetails", "email": "[email protected]"}], | ||
authors=[ | ||
Author.model_construct( | ||
name="nodetails", email="[email protected]" | ||
) | ||
], | ||
contact="[email protected]", | ||
inputs={}, | ||
outputs={}, | ||
|
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
56 changes: 56 additions & 0 deletions
56
...ces/web/server/src/simcore_service_webserver/licenses/_licensed_items_checkouts_models.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,56 @@ | ||
from datetime import datetime | ||
from typing import NamedTuple | ||
|
||
from models_library.basic_types import IDStr | ||
from models_library.licensed_items import LicensedItemID | ||
from models_library.products import ProductName | ||
from models_library.resource_tracker_licensed_items_checkouts import ( | ||
LicensedItemCheckoutID, | ||
) | ||
from models_library.rest_base import RequestParameters, StrictRequestParameters | ||
from models_library.rest_ordering import ( | ||
OrderBy, | ||
OrderDirection, | ||
create_ordering_query_model_class, | ||
) | ||
from models_library.rest_pagination import PageQueryParameters | ||
from models_library.users import UserID | ||
from models_library.wallets import WalletID | ||
from pydantic import BaseModel, PositiveInt | ||
|
||
|
||
class LicensedItemCheckoutGet(BaseModel): | ||
licensed_item_checkout_id: LicensedItemCheckoutID | ||
licensed_item_id: LicensedItemID | ||
wallet_id: WalletID | ||
user_id: UserID | ||
product_name: ProductName | ||
started_at: datetime | ||
stopped_at: datetime | None | ||
num_of_seats: int | ||
|
||
|
||
class LicensedItemCheckoutGetPage(NamedTuple): | ||
items: list[LicensedItemCheckoutGet] | ||
total: PositiveInt | ||
|
||
|
||
class LicensedItemCheckoutPathParams(StrictRequestParameters): | ||
licensed_item_checkout_id: LicensedItemCheckoutID | ||
|
||
|
||
_LicensedItemsCheckoutsListOrderQueryParams: type[ | ||
RequestParameters | ||
] = create_ordering_query_model_class( | ||
ordering_fields={ | ||
"started_at", | ||
}, | ||
default=OrderBy(field=IDStr("started_at"), direction=OrderDirection.DESC), | ||
) | ||
|
||
|
||
class LicensedItemsCheckoutsListQueryParams( | ||
PageQueryParameters, | ||
_LicensedItemsCheckoutsListOrderQueryParams, # type: ignore[misc, valid-type] | ||
): | ||
... |
Oops, something went wrong.