diff --git a/packages/models-library/src/models_library/api_schemas_webserver/licensed_items.py b/packages/models-library/src/models_library/api_schemas_webserver/licensed_items.py index 3455e8a81ac..5dafd9d5804 100644 --- a/packages/models-library/src/models_library/api_schemas_webserver/licensed_items.py +++ b/packages/models-library/src/models_library/api_schemas_webserver/licensed_items.py @@ -11,6 +11,7 @@ class LicensedItemGet(OutputSchema): licensed_item_id: LicensedItemID name: str + license_key: str | None licensed_resource_type: LicensedResourceType pricing_plan_id: PricingPlanId created_at: datetime @@ -21,6 +22,7 @@ class LicensedItemGet(OutputSchema): { "licensed_item_id": "0362b88b-91f8-4b41-867c-35544ad1f7a1", "name": "best-model", + "license_key": "license-specific-key", "licensed_resource_type": f"{LicensedResourceType.VIP_MODEL}", "pricing_plan_id": "15", "created_at": "2024-12-12 09:59:26.422140", diff --git a/packages/models-library/src/models_library/licensed_items.py b/packages/models-library/src/models_library/licensed_items.py index 021cf214ce5..79cd4fa87e0 100644 --- a/packages/models-library/src/models_library/licensed_items.py +++ b/packages/models-library/src/models_library/licensed_items.py @@ -24,6 +24,7 @@ class LicensedResourceType(StrAutoEnum): class LicensedItemDB(BaseModel): licensed_item_id: LicensedItemID name: str + license_key: str | None licensed_resource_type: LicensedResourceType pricing_plan_id: PricingPlanId product_name: ProductName diff --git a/packages/postgres-database/src/simcore_postgres_database/migration/versions/d31c23845017_add_license_key.py b/packages/postgres-database/src/simcore_postgres_database/migration/versions/d31c23845017_add_license_key.py new file mode 100644 index 00000000000..59856c49d52 --- /dev/null +++ b/packages/postgres-database/src/simcore_postgres_database/migration/versions/d31c23845017_add_license_key.py @@ -0,0 +1,29 @@ +"""add license key + +Revision ID: d31c23845017 +Revises: aa6da21a0055 +Create Date: 2024-12-18 11:11:52.644534+00:00 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "d31c23845017" +down_revision = "aa6da21a0055" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column( + "licensed_items", sa.Column("license_key", sa.String(), nullable=True) + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("licensed_items", "license_key") + # ### end Alembic commands ### diff --git a/packages/postgres-database/src/simcore_postgres_database/models/licensed_items.py b/packages/postgres-database/src/simcore_postgres_database/models/licensed_items.py index 63301eb9c1d..a0ea136f4bb 100644 --- a/packages/postgres-database/src/simcore_postgres_database/models/licensed_items.py +++ b/packages/postgres-database/src/simcore_postgres_database/models/licensed_items.py @@ -58,6 +58,12 @@ class LicensedResourceType(str, enum.Enum): nullable=False, doc="Product name", ), + sa.Column( + "license_key", + sa.String, + nullable=True, + 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.", + ), column_created_datetime(timezone=True), column_modified_datetime(timezone=True), ) diff --git a/services/api-server/src/simcore_service_api_server/models/schemas/model_adapter.py b/services/api-server/src/simcore_service_api_server/models/schemas/model_adapter.py index e5a04e198c5..06da65580f8 100644 --- a/services/api-server/src/simcore_service_api_server/models/schemas/model_adapter.py +++ b/services/api-server/src/simcore_service_api_server/models/schemas/model_adapter.py @@ -141,4 +141,7 @@ class LicensedItemGet(BaseModel): assert set(LicensedItemGet.model_fields.keys()) == set( _LicensedItemGet.model_fields.keys() + - { + "license_key" + } # NOTE: @bisgaard-itis please expose https://github.com/ITISFoundation/osparc-simcore/issues/6875 ) diff --git a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml index 93cf60aa82c..27bdb777e6f 100644 --- a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml +++ b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml @@ -10342,6 +10342,11 @@ components: name: type: string title: Name + licenseKey: + anyOf: + - type: string + - type: 'null' + title: Licensekey licensedResourceType: $ref: '#/components/schemas/LicensedResourceType' pricingPlanId: @@ -10361,6 +10366,7 @@ components: required: - licensedItemId - name + - licenseKey - licensedResourceType - pricingPlanId - createdAt diff --git a/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_api.py b/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_api.py index 6feacf24b1d..1f839ae31fa 100644 --- a/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_api.py +++ b/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_api.py @@ -45,6 +45,7 @@ async def get_licensed_item( return LicensedItemGet( licensed_item_id=licensed_item_db.licensed_item_id, name=licensed_item_db.name, + license_key=licensed_item_db.license_key, licensed_resource_type=licensed_item_db.licensed_resource_type, pricing_plan_id=licensed_item_db.pricing_plan_id, created_at=licensed_item_db.created, @@ -68,6 +69,7 @@ async def list_licensed_items( LicensedItemGet( licensed_item_id=licensed_item_db.licensed_item_id, name=licensed_item_db.name, + license_key=licensed_item_db.license_key, licensed_resource_type=licensed_item_db.licensed_resource_type, pricing_plan_id=licensed_item_db.pricing_plan_id, created_at=licensed_item_db.created, diff --git a/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_db.py b/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_db.py index 415dec7149d..57861698161 100644 --- a/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_db.py +++ b/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_db.py @@ -36,6 +36,7 @@ _SELECTION_ARGS = ( licensed_items.c.licensed_item_id, licensed_items.c.name, + licensed_items.c.license_key, licensed_items.c.licensed_resource_type, licensed_items.c.pricing_plan_id, licensed_items.c.product_name,