Skip to content

Commit 24d8791

Browse files
1 parent 2e01957 commit 24d8791

File tree

10 files changed

+44
-36
lines changed

10 files changed

+44
-36
lines changed

packages/models-library/src/models_library/api_schemas_resource_usage_tracker/licensed_items_checkouts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from datetime import datetime
22
from typing import NamedTuple
33

4-
from models_library.licenses import LicensedItemID
4+
from models_library.licenses import LicensedItemID, LicensedItemKey, LicensedItemVersion
55
from models_library.products import ProductName
66
from models_library.resource_tracker_licensed_items_checkouts import (
77
LicensedItemCheckoutID,
@@ -15,8 +15,8 @@
1515
class LicensedItemCheckoutGet(BaseModel):
1616
licensed_item_checkout_id: LicensedItemCheckoutID
1717
licensed_item_id: LicensedItemID
18-
key: str
19-
version: str
18+
key: LicensedItemKey
19+
version: LicensedItemVersion
2020
wallet_id: WalletID
2121
user_id: UserID
2222
user_email: str

packages/models-library/src/models_library/api_schemas_resource_usage_tracker/licensed_items_purchases.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from decimal import Decimal
33
from typing import NamedTuple
44

5-
from models_library.licenses import LicensedItemID
5+
from models_library.licenses import LicensedItemID, LicensedItemKey, LicensedItemVersion
66
from models_library.products import ProductName
77
from models_library.resource_tracker import PricingUnitCostId
88
from models_library.resource_tracker_licensed_items_purchases import (
@@ -17,8 +17,8 @@ class LicensedItemPurchaseGet(BaseModel):
1717
licensed_item_purchase_id: LicensedItemPurchaseID
1818
product_name: ProductName
1919
licensed_item_id: LicensedItemID
20-
key: str
21-
version: str
20+
key: LicensedItemKey
21+
version: LicensedItemVersion
2222
wallet_id: WalletID
2323
wallet_name: str
2424
pricing_unit_cost_id: PricingUnitCostId

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
FeaturesDict,
1212
LicensedItem,
1313
LicensedItemID,
14+
LicensedItemKey,
15+
LicensedItemVersion,
1416
LicensedResourceType,
1517
)
1618
from ._base import OutputSchema
@@ -71,8 +73,8 @@ class _ItisVipResourceRestData(OutputSchema):
7173

7274
class LicensedItemRestGet(OutputSchema):
7375
licensed_item_id: LicensedItemID
74-
key: str
75-
version: str
76+
key: LicensedItemKey
77+
version: LicensedItemVersion
7678

7779
display_name: str
7880
licensed_resource_type: LicensedResourceType

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from models_library.emails import LowerCaseEmailStr
55
from pydantic import BaseModel, ConfigDict, PositiveInt
66

7-
from ..licenses import LicensedItemID
7+
from ..licenses import LicensedItemID, LicensedItemKey, LicensedItemVersion
88
from ..products import ProductName
99
from ..resource_tracker_licensed_items_checkouts import LicensedItemCheckoutID
1010
from ..users import UserID
@@ -17,8 +17,8 @@
1717
class LicensedItemCheckoutRpcGet(BaseModel):
1818
licensed_item_checkout_id: LicensedItemCheckoutID
1919
licensed_item_id: LicensedItemID
20-
key: str
21-
version: str
20+
key: LicensedItemKey
21+
version: LicensedItemVersion
2222
wallet_id: WalletID
2323
user_id: UserID
2424
product_name: ProductName

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from models_library.emails import LowerCaseEmailStr
66
from pydantic import PositiveInt
77

8-
from ..licenses import LicensedItemID
8+
from ..licenses import LicensedItemID, LicensedItemKey, LicensedItemVersion
99
from ..products import ProductName
1010
from ..resource_tracker import PricingUnitCostId
1111
from ..resource_tracker_licensed_items_purchases import LicensedItemPurchaseID
@@ -18,8 +18,8 @@ class LicensedItemPurchaseGet(OutputSchema):
1818
licensed_item_purchase_id: LicensedItemPurchaseID
1919
product_name: ProductName
2020
licensed_item_id: LicensedItemID
21-
key: str
22-
version: str
21+
key: LicensedItemKey
22+
version: LicensedItemVersion
2323
wallet_id: WalletID
2424
pricing_unit_cost_id: PricingUnitCostId
2525
pricing_unit_cost: Decimal

packages/models-library/src/models_library/licenses.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from datetime import datetime
22
from enum import auto
3-
from typing import Any, NamedTuple, NotRequired, TypeAlias, cast
3+
from typing import Any, NamedTuple, NewType, NotRequired, TypeAlias, cast
44
from uuid import UUID
55

66
from models_library.resource_tracker import PricingPlanId
@@ -15,6 +15,9 @@
1515
LicensedItemID: TypeAlias = UUID
1616
LicensedResourceID: TypeAlias = UUID
1717

18+
LicensedItemKey = NewType("LicensedItemKey", str)
19+
LicensedItemVersion = NewType("LicensedItemVersion", str)
20+
1821

1922
class LicensedResourceType(StrAutoEnum):
2023
VIP_MODEL = auto()
@@ -69,8 +72,8 @@ class LicensedItemDB(BaseModel):
6972
licensed_item_id: LicensedItemID
7073
display_name: str
7174

72-
key: str
73-
version: str
75+
key: LicensedItemKey
76+
version: LicensedItemVersion
7477
licensed_resource_type: LicensedResourceType
7578

7679
pricing_plan_id: PricingPlanId
@@ -88,10 +91,6 @@ class LicensedItemPatchDB(BaseModel):
8891
pricing_plan_id: PricingPlanId | None = None
8992

9093

91-
class LicensedResourcePatchDB(BaseModel):
92-
trash: bool | None = None
93-
94-
9594
class LicensedResourceDB(BaseModel):
9695
licensed_resource_id: LicensedResourceID
9796
display_name: str
@@ -116,8 +115,8 @@ class LicensedResourcePatchDB(BaseModel):
116115

117116
class LicensedItem(BaseModel):
118117
licensed_item_id: LicensedItemID
119-
key: str
120-
version: str
118+
key: LicensedItemKey
119+
version: LicensedItemVersion
121120
display_name: str
122121
licensed_resource_type: LicensedResourceType
123122
licensed_resources: list[dict[str, Any]]

packages/models-library/src/models_library/resource_tracker_licensed_items_purchases.py

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

66
from pydantic import BaseModel, ConfigDict
77

8-
from .licenses import LicensedItemID
8+
from .licenses import LicensedItemID, LicensedItemKey, LicensedItemVersion
99
from .products import ProductName
1010
from .resource_tracker import PricingPlanId, PricingUnitCostId, PricingUnitId
1111
from .users import UserID
@@ -17,8 +17,8 @@
1717
class LicensedItemsPurchasesCreate(BaseModel):
1818
product_name: ProductName
1919
licensed_item_id: LicensedItemID
20-
key: str
21-
version: str
20+
key: LicensedItemKey
21+
version: LicensedItemVersion
2222
wallet_id: WalletID
2323
wallet_name: str
2424
pricing_plan_id: PricingPlanId

services/api-server/src/simcore_service_api_server/models/schemas/model_adapter.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
)
2525
from models_library.basic_types import IDStr, NonNegativeDecimal
2626
from models_library.groups import GroupID
27-
from models_library.licenses import LicensedItemID, LicensedResourceType
27+
from models_library.licenses import (
28+
LicensedItemID,
29+
LicensedItemKey,
30+
LicensedItemVersion,
31+
LicensedResourceType,
32+
)
2833
from models_library.products import ProductName
2934
from models_library.resource_tracker import (
3035
PricingPlanClassification,
@@ -137,8 +142,8 @@ class ServicePricingPlanGetLegacy(BaseModel):
137142

138143
class LicensedItemGet(BaseModel):
139144
licensed_item_id: LicensedItemID
140-
key: str
141-
version: str
145+
key: LicensedItemKey
146+
version: LicensedItemVersion
142147
display_name: str
143148
licensed_resource_type: LicensedResourceType
144149
licensed_resources: list[dict[str, Any]]

services/resource-usage-tracker/src/simcore_service_resource_usage_tracker/services/licensed_items_checkouts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async def get_licensed_item_checkout(
107107
async def checkout_licensed_item(
108108
db_engine: Annotated[AsyncEngine, Depends(get_resource_tracker_db_engine)],
109109
*,
110-
licensed_item_id: LicensedItemID, # MD: maybe not needed?
110+
licensed_item_id: LicensedItemID,
111111
key: str,
112112
version: str,
113113
wallet_id: WalletID,

services/web/server/src/simcore_service_webserver/licenses/_licensed_items_repository.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
LicensedItem,
77
LicensedItemDB,
88
LicensedItemID,
9+
LicensedItemKey,
910
LicensedItemPatchDB,
11+
LicensedItemVersion,
1012
LicensedResourceType,
1113
)
1214
from models_library.products import ProductName
@@ -39,8 +41,8 @@
3941

4042
def _create_insert_query(
4143
display_name: str,
42-
key: str,
43-
version: str,
44+
key: LicensedItemKey,
45+
version: LicensedItemVersion,
4446
licensed_resource_type: LicensedResourceType,
4547
product_name: ProductName,
4648
pricing_plan_id: PricingPlanId,
@@ -65,8 +67,8 @@ async def create(
6567
app: web.Application,
6668
connection: AsyncConnection | None = None,
6769
*,
68-
key: str,
69-
version: str,
70+
key: LicensedItemKey,
71+
version: LicensedItemVersion,
7072
display_name: str,
7173
licensed_resource_type: LicensedResourceType,
7274
product_name: ProductName,
@@ -231,8 +233,8 @@ async def get_licensed_item_by_key_version(
231233
app: web.Application,
232234
connection: AsyncConnection | None = None,
233235
*,
234-
key: str,
235-
version: str,
236+
key: LicensedItemKey,
237+
version: LicensedItemVersion,
236238
product_name: ProductName,
237239
) -> LicensedItem:
238240

0 commit comments

Comments
 (0)