Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Introduce vip models pricing 1 of 2 parts #6897

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3bd4e3b
refactor RUT to use new transactional context
matusdrobuliak66 Dec 1, 2024
fd4a43f
fix
matusdrobuliak66 Dec 1, 2024
f5b73d7
Merge branch 'master' into introduce-vip-models-pricing
matusdrobuliak66 Dec 2, 2024
936027e
Merge branch 'master' into introduce-vip-models-pricing
matusdrobuliak66 Dec 2, 2024
88fdede
Merge branch 'master' into introduce-vip-models-pricing
matusdrobuliak66 Dec 2, 2024
5d0c6f7
Merge branch 'master' into introduce-vip-models-pricing-2-part
matusdrobuliak66 Dec 3, 2024
20fa686
Merge branch 'master' into introduce-vip-models-pricing-2-part
matusdrobuliak66 Dec 3, 2024
561c284
adding shortuuid
matusdrobuliak66 Dec 3, 2024
9f060de
add license db tables
matusdrobuliak66 Dec 3, 2024
6f9c844
upgrade postgres package - shortuuid
matusdrobuliak66 Dec 3, 2024
c296b0d
upgrade postgres package - shortuuid
matusdrobuliak66 Dec 3, 2024
af4642b
Merge branch 'master' into introduce-vip-models-pricing-2-part
matusdrobuliak66 Dec 3, 2024
00fce00
Merge branch 'master' into introduce-vip-models-pricing-2-part
matusdrobuliak66 Dec 4, 2024
bc83eb0
license goods DB layer
matusdrobuliak66 Dec 4, 2024
f2113ec
exeption handling
matusdrobuliak66 Dec 4, 2024
e570beb
open api specs
matusdrobuliak66 Dec 4, 2024
60b3132
adding db test
matusdrobuliak66 Dec 4, 2024
10988aa
remove db migration:
matusdrobuliak66 Dec 4, 2024
9b24815
add db migration:
matusdrobuliak66 Dec 4, 2024
28c86ff
open api specs
matusdrobuliak66 Dec 4, 2024
03c5f08
adding db test
matusdrobuliak66 Dec 4, 2024
e6c8d5c
Merge branch 'master' into introduce-vip-models-pricing-2-part
matusdrobuliak66 Dec 4, 2024
d0107ad
fix naming
matusdrobuliak66 Dec 4, 2024
44fbf75
open api specs
matusdrobuliak66 Dec 4, 2024
deeb0f1
fix test
matusdrobuliak66 Dec 4, 2024
fb06946
propagate downstream dependencies everywhere
matusdrobuliak66 Dec 4, 2024
8c00993
Merge branch 'master' into introduce-vip-models-pricing-2-part
matusdrobuliak66 Dec 5, 2024
b8c918b
PR reviews
matusdrobuliak66 Dec 5, 2024
c629b0a
PR reviews
matusdrobuliak66 Dec 5, 2024
50204c3
fix test
matusdrobuliak66 Dec 5, 2024
68ecfe5
fix test
matusdrobuliak66 Dec 5, 2024
9896a91
PR reviews
matusdrobuliak66 Dec 5, 2024
f919e4c
remove shortuuid
matusdrobuliak66 Dec 5, 2024
519c2ed
fix
matusdrobuliak66 Dec 5, 2024
894b636
Merge branch 'master' into introduce-vip-models-pricing-2-part
matusdrobuliak66 Dec 5, 2024
038ea39
fix
matusdrobuliak66 Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions api/specs/web-server/_catalog_licensed_items.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
""" 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, status
from models_library.api_schemas_webserver.licensed_items import LicensedItemGet
from models_library.generics import Envelope
from models_library.rest_error import EnvelopedError
from simcore_service_webserver._meta import API_VTAG
from simcore_service_webserver.catalog.licenses._exceptions_handlers import (
_TO_HTTP_ERROR_MAP,
)
from simcore_service_webserver.catalog.licenses._models import (
LicensedItemsBodyParams,
LicensedItemsListQueryParams,
LicensedItemsPathParams,
)

router = APIRouter(
prefix=f"/{API_VTAG}",
tags=[
"licenses",
"catalog",
],
responses={
i.status_code: {"model": EnvelopedError} for i in _TO_HTTP_ERROR_MAP.values()
},
)


@router.get(
"/catalog/licensed-items",
response_model=Envelope[list[LicensedItemGet]],
)
async def list_licensed_items(
_query: Annotated[as_query(LicensedItemsListQueryParams), Depends()],
):
...


@router.get(
"/catalog/licensed-items/{licensed_item_id}",
response_model=Envelope[LicensedItemGet],
)
async def get_licensed_item(
_path: Annotated[LicensedItemsPathParams, Depends()],
):
...


@router.post(
"/catalog/licensed-items/{licensed_item_id}:purchase",
status_code=status.HTTP_204_NO_CONTENT,
)
async def purchase_licensed_item(
_path: Annotated[LicensedItemsPathParams, Depends()],
_body: LicensedItemsBodyParams,
):
...
1 change: 1 addition & 0 deletions api/specs/web-server/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"_announcements",
"_catalog",
"_catalog_tags", # MUST BE after _catalog
"_catalog_licensed_items",
"_computations",
"_exporter",
"_folders",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from datetime import datetime
from typing import NamedTuple

from models_library.licensed_items import LicensedItemID, LicensedResourceType
from models_library.resource_tracker import PricingPlanId
from pydantic import PositiveInt

from ._base import OutputSchema


class LicensedItemGet(OutputSchema):
licensed_item_id: LicensedItemID
name: str
licensed_resource_type: LicensedResourceType
pricing_plan_id: PricingPlanId
created_at: datetime
modified_at: datetime


class LicensedItemGetPage(NamedTuple):
items: list[LicensedItemGet]
total: PositiveInt
44 changes: 44 additions & 0 deletions packages/models-library/src/models_library/licensed_items.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from datetime import datetime
from enum import auto
from typing import TypeAlias
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

from .products import ProductName
from .resource_tracker import PricingPlanId
from .utils.enums import StrAutoEnum

LicensedItemID: TypeAlias = UUID


class LicensedResourceType(StrAutoEnum):
VIP_MODEL = auto()


#
# DB
#


class LicensedItemDB(BaseModel):
licensed_item_id: LicensedItemID
name: str
licensed_resource_type: LicensedResourceType
pricing_plan_id: PricingPlanId
product_name: ProductName
created: datetime = Field(
...,
description="Timestamp on creation",
)
modified: datetime = Field(
...,
description="Timestamp of last modification",
)
# ----
model_config = ConfigDict(from_attributes=True)


class LicensedItemUpdateDB(BaseModel):
name: str | None = None
pricing_plan_id: PricingPlanId | None = None
2 changes: 1 addition & 1 deletion packages/postgres-database/requirements/_base.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
--requirement ../../../packages/common-library/requirements/_base.in

alembic
opentelemetry-instrumentation-asyncpg
pydantic
sqlalchemy[postgresql_psycopg2binary,postgresql_asyncpg] # SEE extras in https://github.com/sqlalchemy/sqlalchemy/blob/main/setup.cfg#L43
opentelemetry-instrumentation-asyncpg
yarl
2 changes: 1 addition & 1 deletion packages/postgres-database/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pydantic-core==2.27.1
# via pydantic
pydantic-extra-types==2.10.0
# via -r requirements/../../../packages/common-library/requirements/_base.in
setuptools==75.2.0
setuptools==75.6.0
# via opentelemetry-instrumentation
sqlalchemy==1.4.54
# via
Expand Down
2 changes: 1 addition & 1 deletion packages/postgres-database/requirements/_migration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ certifi==2024.8.30
# via
# -c requirements/../../../requirements/constraints.txt
# requests
charset-normalizer==3.3.2
charset-normalizer==3.4.0
# via requests
click==8.1.7
# via -r requirements/_migration.in
Expand Down
17 changes: 9 additions & 8 deletions packages/postgres-database/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ async-timeout==4.0.3
# aiopg
attrs==24.2.0
# via pytest-docker
coverage==7.6.1
coverage==7.6.8
# via
# -r requirements/_test.in
# pytest-cov
faker==29.0.0
faker==33.1.0
# via -r requirements/_test.in
greenlet==3.1.1
# via
Expand All @@ -19,11 +19,11 @@ greenlet==3.1.1
# sqlalchemy
iniconfig==2.0.0
# via pytest
mypy==1.12.0
mypy==1.13.0
# via sqlalchemy
mypy-extensions==1.0.0
# via mypy
packaging==24.1
packaging==24.2
# via pytest
pluggy==1.5.0
# via pytest
Expand All @@ -32,7 +32,7 @@ psycopg2-binary==2.9.9
# -c requirements/_base.txt
# aiopg
# sqlalchemy
pytest==8.3.3
pytest==8.3.4
# via
# -r requirements/_test.in
# pytest-asyncio
Expand All @@ -43,7 +43,7 @@ pytest-asyncio==0.23.8
# via
# -c requirements/../../../requirements/constraints.txt
# -r requirements/_test.in
pytest-cov==5.0.0
pytest-cov==6.0.0
# via -r requirements/_test.in
pytest-docker==3.1.1
# via -r requirements/_test.in
Expand All @@ -70,14 +70,15 @@ sqlalchemy2-stubs==0.0.2a38
# via sqlalchemy
types-docker==7.1.0.20240827
# via -r requirements/_test.in
types-psycopg2==2.9.21.20240819
types-psycopg2==2.9.21.20241019
# via -r requirements/_test.in
types-requests==2.32.0.20240914
types-requests==2.32.0.20241016
# via types-docker
typing-extensions==4.12.2
# via
# -c requirements/_base.txt
# -c requirements/_migration.txt
# faker
# mypy
# sqlalchemy2-stubs
urllib3==2.2.3
Expand Down
32 changes: 16 additions & 16 deletions packages/postgres-database/requirements/_tools.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
astroid==3.3.4
astroid==3.3.5
# via pylint
black==24.8.0
black==24.10.0
# via -r requirements/../../../requirements/devenv.txt
build==1.2.2
build==1.2.2.post1
# via pip-tools
bump2version==1.0.1
# via -r requirements/../../../requirements/devenv.txt
Expand All @@ -12,21 +12,21 @@ click==8.1.7
# via
# black
# pip-tools
dill==0.3.8
dill==0.3.9
# via pylint
distlib==0.3.8
distlib==0.3.9
# via virtualenv
filelock==3.16.1
# via virtualenv
identify==2.6.1
identify==2.6.3
# via pre-commit
isort==5.13.2
# via
# -r requirements/../../../requirements/devenv.txt
# pylint
mccabe==0.7.0
# via pylint
mypy==1.12.0
mypy==1.13.0
# via
# -c requirements/_test.txt
# -r requirements/../../../requirements/devenv.txt
Expand All @@ -37,14 +37,14 @@ mypy-extensions==1.0.0
# mypy
nodeenv==1.9.1
# via pre-commit
packaging==24.1
packaging==24.2
# via
# -c requirements/_test.txt
# black
# build
pathspec==0.12.1
# via black
pip==24.2
pip==24.3.1
# via pip-tools
pip-tools==7.4.1
# via -r requirements/../../../requirements/devenv.txt
Expand All @@ -53,11 +53,11 @@ platformdirs==4.3.6
# black
# pylint
# virtualenv
pre-commit==3.8.0
pre-commit==4.0.1
# via -r requirements/../../../requirements/devenv.txt
pylint==3.3.0
pylint==3.3.2
# via -r requirements/../../../requirements/devenv.txt
pyproject-hooks==1.1.0
pyproject-hooks==1.2.0
# via
# build
# pip-tools
Expand All @@ -66,9 +66,9 @@ pyyaml==6.0.2
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_test.txt
# pre-commit
ruff==0.6.7
ruff==0.8.1
# via -r requirements/../../../requirements/devenv.txt
setuptools==75.2.0
setuptools==75.6.0
# via
# -c requirements/_base.txt
# pip-tools
Expand All @@ -79,7 +79,7 @@ typing-extensions==4.12.2
# -c requirements/_base.txt
# -c requirements/_test.txt
# mypy
virtualenv==20.26.5
virtualenv==20.28.0
# via pre-commit
wheel==0.44.0
wheel==0.45.1
# via pip-tools
Loading
Loading