Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into pr-osparc-orphane…
Browse files Browse the repository at this point in the history
…d-containers-removal
  • Loading branch information
Andrei Neagu committed Dec 13, 2024
2 parents 688f10d + 4eeaa5c commit 2354e68
Show file tree
Hide file tree
Showing 259 changed files with 6,529 additions and 2,192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
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 (
from simcore_service_webserver.licenses._exceptions_handlers import _TO_HTTP_ERROR_MAP
from simcore_service_webserver.licenses._models import (
LicensedItemsBodyParams,
LicensedItemsListQueryParams,
LicensedItemsPathParams,
Expand Down
57 changes: 57 additions & 0 deletions api/specs/web-server/_licensed_items_purchases.py
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._models import (
LicensedItemsPurchasesListQueryParams,
LicensedItemsPurchasesPathParams,
)
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-purchases",
response_model=Page[LicensedItemPurchaseGet],
tags=["wallets"],
)
async def list_wallet_licensed_items_purchases(
_path: Annotated[WalletsPathParams, Depends()],
_query: Annotated[as_query(LicensedItemsPurchasesListQueryParams), Depends()],
):
...


@router.get(
"/licensed-items-purchases/{licensed_item_purchase_id}",
response_model=Envelope[LicensedItemPurchaseGet],
)
async def get_licensed_item_purchase(
_path: Annotated[LicensedItemsPurchasesPathParams, Depends()],
):
...
2 changes: 1 addition & 1 deletion api/specs/web-server/_projects_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
ServiceResourcesDict,
)
from models_library.generics import Envelope
from models_library.groups import GroupID
from models_library.projects import ProjectID
from models_library.projects_nodes_io import NodeID
from models_library.users import GroupID
from simcore_service_webserver._meta import API_VTAG
from simcore_service_webserver.projects._crud_handlers import ProjectPathParams
from simcore_service_webserver.projects._nodes_handlers import (
Expand Down
2 changes: 1 addition & 1 deletion api/specs/web-server/_wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
WalletPaymentInitiated,
)
from models_library.generics import Envelope
from models_library.groups import GroupID
from models_library.rest_pagination import Page, PageQueryParameters
from models_library.users import GroupID
from models_library.wallets import WalletID
from simcore_service_webserver._meta import API_VTAG
from simcore_service_webserver.wallets._groups_api import WalletGroupGet
Expand Down
3 changes: 2 additions & 1 deletion api/specs/web-server/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
"_announcements",
"_catalog",
"_catalog_tags", # MUST BE after _catalog
"_catalog_licensed_items",
"_computations",
"_exporter",
"_folders",
"_long_running_tasks",
"_licensed_items",
"_licensed_items_purchases",
"_metamodeling",
"_nih_sparc",
"_nih_sparc_redirections",
Expand Down
3 changes: 2 additions & 1 deletion packages/aws-library/src/aws_library/ec2/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ async def launch_instances(
)
instance_ids = [i["InstanceId"] for i in instances["Instances"]]
_logger.info(
"New instances launched: %s, waiting for them to start now...",
"%s New instances launched: %s, waiting for them to start now...",
len(instance_ids),
instance_ids,
)

Expand Down
13 changes: 13 additions & 0 deletions packages/common-library/src/common_library/groups_enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import enum


class GroupType(enum.Enum):
"""
standard: standard group, e.g. any group that is not a primary group or special group such as the everyone group
primary: primary group, e.g. the primary group is the user own defined group that typically only contain the user (same as in linux)
everyone: the only group for all users
"""

STANDARD = "standard"
PRIMARY = "primary"
EVERYONE = "everyone"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic import BaseModel

from ..groups import GroupID
from ..services import ServiceKey, ServiceVersion
from ..users import GroupID


class ServiceAccessRightsGet(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from ..boot_options import BootOptions
from ..emails import LowerCaseEmailStr
from ..groups import GroupID
from ..services_access import ServiceAccessRights, ServiceGroupAccessRightsV2
from ..services_authoring import Author
from ..services_enums import ServiceType
Expand All @@ -18,7 +19,6 @@
)
from ..services_resources import ServiceResourcesDict
from ..services_types import ServiceKey, ServiceVersion
from ..users import GroupID
from ..utils.change_case import snake_to_camel


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from datetime import datetime
from decimal import Decimal
from typing import NamedTuple

from models_library.licensed_items import LicensedItemID
from models_library.products import ProductName
from models_library.resource_tracker import PricingUnitCostId
from models_library.resource_tracker_licensed_items_purchases import (
LicensedItemPurchaseID,
)
from models_library.users import UserID
from models_library.wallets import WalletID
from pydantic import BaseModel, ConfigDict, PositiveInt


class LicensedItemPurchaseGet(BaseModel):
licensed_item_purchase_id: LicensedItemPurchaseID
product_name: ProductName
licensed_item_id: LicensedItemID
wallet_id: WalletID
wallet_name: str
pricing_unit_cost_id: PricingUnitCostId
pricing_unit_cost: Decimal
start_at: datetime
expire_at: datetime
num_of_seats: int
purchased_by_user: UserID
purchased_at: datetime
modified: datetime

model_config = ConfigDict(
json_schema_extra={
"examples": [
{
"licensed_item_purchase_id": "beb16d18-d57d-44aa-a638-9727fa4a72ef",
"product_name": "osparc",
"licensed_item_id": "303942ef-6d31-4ba8-afbe-dbb1fce2a953",
"wallet_id": 1,
"wallet_name": "My Wallet",
"pricing_unit_cost_id": 1,
"pricing_unit_cost": 10,
"start_at": "2023-01-11 13:11:47.293595",
"expire_at": "2023-01-11 13:11:47.293595",
"num_of_seats": 1,
"purchased_by_user": 1,
"purchased_at": "2023-01-11 13:11:47.293595",
"modified": "2023-01-11 13:11:47.293595",
}
]
}
)


class LicensedItemsPurchasesPage(NamedTuple):
items: list[LicensedItemPurchaseGet]
total: PositiveInt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from models_library.basic_types import IDStr
from models_library.folders import FolderID
from models_library.groups import GroupID
from models_library.projects_access import AccessRights
from models_library.users import GroupID
from models_library.utils.common_validators import null_or_none_str_to_none_validator
from pydantic import ConfigDict, PositiveInt, field_validator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ..access_rights import AccessRights
from ..basic_types import IDStr
from ..folders import FolderID
from ..users import GroupID
from ..groups import GroupID
from ..utils.common_validators import null_or_none_str_to_none_validator
from ..workspaces import WorkspaceID
from ._base import InputSchema, OutputSchema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Annotated, Any, Self, TypeVar

from common_library.basic_types import DEFAULT_FACTORY
from models_library.groups import EVERYONE_GROUP_ID
from pydantic import (
AnyHttpUrl,
AnyUrl,
Expand All @@ -14,16 +15,16 @@
model_validator,
)

from ..basic_types import IDStr
from ..emails import LowerCaseEmailStr
from ..groups import (
AccessRightsDict,
Group,
GroupID,
GroupMember,
StandardGroupCreate,
StandardGroupUpdate,
)
from ..users import UserID
from ..users import UserID, UserNameID
from ..utils.common_validators import create__check_only_one_is_set__root_validator
from ._base import InputSchema, OutputSchema

Expand Down Expand Up @@ -55,7 +56,7 @@ class GroupAccessRights(BaseModel):


class GroupGet(OutputSchema):
gid: int = Field(..., description="the group ID")
gid: GroupID = Field(..., description="the group ID")
label: str = Field(..., description="the group name")
description: str = Field(..., description="the group description")
thumbnail: AnyUrl | None = Field(
Expand Down Expand Up @@ -114,7 +115,7 @@ def from_model(cls, group: Group, access_rights: AccessRightsDict) -> Self:
"accessRights": {"read": True, "write": False, "delete": False},
},
{
"gid": "0",
"gid": "1",
"label": "All",
"description": "Open to all users",
"accessRights": {"read": True, "write": True, "delete": True},
Expand Down Expand Up @@ -214,7 +215,7 @@ class MyGroupsGet(OutputSchema):
},
],
"all": {
"gid": "0",
"gid": EVERYONE_GROUP_ID,
"label": "All",
"description": "Open to all users",
"accessRights": {"read": True, "write": False, "delete": False},
Expand All @@ -228,13 +229,11 @@ class GroupUserGet(BaseModel):
# OutputSchema

# Identifiers
id: Annotated[
str | None, Field(description="the user id", coerce_numbers_to_str=True)
] = None
user_name: Annotated[IDStr, Field(alias="userName")]
id: Annotated[UserID | None, Field(description="the user's id")] = None
user_name: Annotated[UserNameID, Field(alias="userName")]
gid: Annotated[
str | None,
Field(description="the user primary gid", coerce_numbers_to_str=True),
GroupID | None,
Field(description="the user primary gid"),
] = None

# Private Profile
Expand Down Expand Up @@ -296,7 +295,7 @@ class GroupUserAdd(InputSchema):
"""

uid: UserID | None = None
user_name: Annotated[IDStr | None, Field(alias="userName")] = None
user_name: Annotated[UserNameID | None, Field(alias="userName")] = None
email: Annotated[
LowerCaseEmailStr | None,
Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

from ._base import OutputSchema

Expand All @@ -15,6 +15,20 @@ class LicensedItemGet(OutputSchema):
pricing_plan_id: PricingPlanId
created_at: datetime
modified_at: datetime
model_config = ConfigDict(
json_schema_extra={
"examples": [
{
"licensed_item_id": "0362b88b-91f8-4b41-867c-35544ad1f7a1",
"name": "best-model",
"licensed_resource_type": f"{LicensedResourceType.VIP_MODEL}",
"pricing_plan_id": "15",
"created_at": "2024-12-12 09:59:26.422140",
"modified_at": "2024-12-12 09:59:26.422140",
}
]
}
)


class LicensedItemGetPage(NamedTuple):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from datetime import datetime
from decimal import Decimal
from typing import NamedTuple

from models_library.licensed_items import LicensedItemID
from models_library.products import ProductName
from models_library.resource_tracker import PricingUnitCostId
from models_library.resource_tracker_licensed_items_purchases import (
LicensedItemPurchaseID,
)
from models_library.users import UserID
from models_library.wallets import WalletID
from pydantic import PositiveInt

from ._base import OutputSchema


class LicensedItemPurchaseGet(OutputSchema):
licensed_item_purchase_id: LicensedItemPurchaseID
product_name: ProductName
licensed_item_id: LicensedItemID
wallet_id: WalletID
pricing_unit_cost_id: PricingUnitCostId
pricing_unit_cost: Decimal
start_at: datetime
expire_at: datetime
num_of_seats: int
purchased_by_user: UserID
purchased_at: datetime
modified_at: datetime


class LicensedItemPurchaseGetPage(NamedTuple):
items: list[LicensedItemPurchaseGet]
total: PositiveInt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ..basic_types import IDStr
from ..users import GroupID, UserID
from ..groups import GroupID
from ..users import UserID


class SocketIORoomStr(IDStr):
Expand Down
Loading

0 comments on commit 2354e68

Please sign in to comment.