Skip to content

Commit 89c8472

Browse files
🎨 add license_key field (🗃️) (#6978)
1 parent 5786896 commit 89c8472

File tree

8 files changed

+50
-0
lines changed

8 files changed

+50
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
class LicensedItemGet(OutputSchema):
1212
licensed_item_id: LicensedItemID
1313
name: str
14+
license_key: str | None
1415
licensed_resource_type: LicensedResourceType
1516
pricing_plan_id: PricingPlanId
1617
created_at: datetime
@@ -21,6 +22,7 @@ class LicensedItemGet(OutputSchema):
2122
{
2223
"licensed_item_id": "0362b88b-91f8-4b41-867c-35544ad1f7a1",
2324
"name": "best-model",
25+
"license_key": "license-specific-key",
2426
"licensed_resource_type": f"{LicensedResourceType.VIP_MODEL}",
2527
"pricing_plan_id": "15",
2628
"created_at": "2024-12-12 09:59:26.422140",

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

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class LicensedResourceType(StrAutoEnum):
2424
class LicensedItemDB(BaseModel):
2525
licensed_item_id: LicensedItemID
2626
name: str
27+
license_key: str | None
2728
licensed_resource_type: LicensedResourceType
2829
pricing_plan_id: PricingPlanId
2930
product_name: ProductName
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""add license key
2+
3+
Revision ID: d31c23845017
4+
Revises: aa6da21a0055
5+
Create Date: 2024-12-18 11:11:52.644534+00:00
6+
7+
"""
8+
import sqlalchemy as sa
9+
from alembic import op
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "d31c23845017"
13+
down_revision = "aa6da21a0055"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade():
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
op.add_column(
21+
"licensed_items", sa.Column("license_key", sa.String(), nullable=True)
22+
)
23+
# ### end Alembic commands ###
24+
25+
26+
def downgrade():
27+
# ### commands auto generated by Alembic - please adjust! ###
28+
op.drop_column("licensed_items", "license_key")
29+
# ### end Alembic commands ###

packages/postgres-database/src/simcore_postgres_database/models/licensed_items.py

+6
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ class LicensedResourceType(str, enum.Enum):
5858
nullable=False,
5959
doc="Product name",
6060
),
61+
sa.Column(
62+
"license_key",
63+
sa.String,
64+
nullable=True,
65+
doc="Purpose: Acts as a mapping key to the internal license server. Usage: The Sim4Life base applications use this key to check out a seat from the internal license server.",
66+
),
6167
column_created_datetime(timezone=True),
6268
column_modified_datetime(timezone=True),
6369
)

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

+3
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,7 @@ class LicensedItemGet(BaseModel):
141141

142142
assert set(LicensedItemGet.model_fields.keys()) == set(
143143
_LicensedItemGet.model_fields.keys()
144+
- {
145+
"license_key"
146+
} # NOTE: @bisgaard-itis please expose https://github.com/ITISFoundation/osparc-simcore/issues/6875
144147
)

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

+6
Original file line numberDiff line numberDiff line change
@@ -10342,6 +10342,11 @@ components:
1034210342
name:
1034310343
type: string
1034410344
title: Name
10345+
licenseKey:
10346+
anyOf:
10347+
- type: string
10348+
- type: 'null'
10349+
title: Licensekey
1034510350
licensedResourceType:
1034610351
$ref: '#/components/schemas/LicensedResourceType'
1034710352
pricingPlanId:
@@ -10361,6 +10366,7 @@ components:
1036110366
required:
1036210367
- licensedItemId
1036310368
- name
10369+
- licenseKey
1036410370
- licensedResourceType
1036510371
- pricingPlanId
1036610372
- createdAt

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

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async def get_licensed_item(
4545
return LicensedItemGet(
4646
licensed_item_id=licensed_item_db.licensed_item_id,
4747
name=licensed_item_db.name,
48+
license_key=licensed_item_db.license_key,
4849
licensed_resource_type=licensed_item_db.licensed_resource_type,
4950
pricing_plan_id=licensed_item_db.pricing_plan_id,
5051
created_at=licensed_item_db.created,
@@ -68,6 +69,7 @@ async def list_licensed_items(
6869
LicensedItemGet(
6970
licensed_item_id=licensed_item_db.licensed_item_id,
7071
name=licensed_item_db.name,
72+
license_key=licensed_item_db.license_key,
7173
licensed_resource_type=licensed_item_db.licensed_resource_type,
7274
pricing_plan_id=licensed_item_db.pricing_plan_id,
7375
created_at=licensed_item_db.created,

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

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
_SELECTION_ARGS = (
3737
licensed_items.c.licensed_item_id,
3838
licensed_items.c.name,
39+
licensed_items.c.license_key,
3940
licensed_items.c.licensed_resource_type,
4041
licensed_items.c.pricing_plan_id,
4142
licensed_items.c.product_name,

0 commit comments

Comments
 (0)