Skip to content

Commit 9f20961

Browse files
committed
move to legacy notation
1 parent fe31052 commit 9f20961

File tree

10 files changed

+96
-78
lines changed

10 files changed

+96
-78
lines changed

services/api-server/openapi.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,7 @@
19311931
"content": {
19321932
"application/json": {
19331933
"schema": {
1934-
"$ref": "#/components/schemas/ServicePricingPlanGet"
1934+
"$ref": "#/components/schemas/ServicePricingPlanGetLegacy"
19351935
}
19361936
}
19371937
}
@@ -3790,7 +3790,7 @@
37903790
"content": {
37913791
"application/json": {
37923792
"schema": {
3793-
"$ref": "#/components/schemas/WalletGetWithAvailableCredits"
3793+
"$ref": "#/components/schemas/WalletGetWithAvailableCreditsLegacy"
37943794
}
37953795
}
37963796
}
@@ -3929,7 +3929,7 @@
39293929
"content": {
39303930
"application/json": {
39313931
"schema": {
3932-
"$ref": "#/components/schemas/PricingUnitGet"
3932+
"$ref": "#/components/schemas/PricingUnitGetLegacy"
39333933
}
39343934
}
39353935
}
@@ -5121,7 +5121,7 @@
51215121
"content": {
51225122
"application/json": {
51235123
"schema": {
5124-
"$ref": "#/components/schemas/WalletGetWithAvailableCredits"
5124+
"$ref": "#/components/schemas/WalletGetWithAvailableCreditsLegacy"
51255125
}
51265126
}
51275127
}
@@ -5234,7 +5234,7 @@
52345234
"content": {
52355235
"application/json": {
52365236
"schema": {
5237-
"$ref": "#/components/schemas/WalletGetWithAvailableCredits"
5237+
"$ref": "#/components/schemas/WalletGetWithAvailableCreditsLegacy"
52385238
}
52395239
}
52405240
}
@@ -5336,7 +5336,7 @@
53365336
"content": {
53375337
"application/json": {
53385338
"schema": {
5339-
"$ref": "#/components/schemas/GetCreditPrice"
5339+
"$ref": "#/components/schemas/GetCreditPriceLegacy"
53405340
}
53415341
}
53425342
}
@@ -5565,7 +5565,7 @@
55655565
],
55665566
"title": "FileUploadData"
55675567
},
5568-
"GetCreditPrice": {
5568+
"GetCreditPriceLegacy": {
55695569
"properties": {
55705570
"productName": {
55715571
"type": "string",
@@ -5604,7 +5604,7 @@
56045604
"usdPerCredit",
56055605
"minPaymentAmountUsd"
56065606
],
5607-
"title": "GetCreditPrice"
5607+
"title": "GetCreditPriceLegacy"
56085608
},
56095609
"Groups": {
56105610
"properties": {
@@ -6473,7 +6473,7 @@
64736473
],
64746474
"title": "PricingPlanClassification"
64756475
},
6476-
"PricingUnitGet": {
6476+
"PricingUnitGetLegacy": {
64776477
"properties": {
64786478
"pricingUnitId": {
64796479
"type": "integer",
@@ -6506,7 +6506,7 @@
65066506
"currentCostPerUnit",
65076507
"default"
65086508
],
6509-
"title": "PricingUnitGet"
6509+
"title": "PricingUnitGetLegacy"
65106510
},
65116511
"Profile": {
65126512
"properties": {
@@ -6648,7 +6648,7 @@
66486648
"title": "RunningState",
66496649
"description": "State of execution of a project's computational workflow\n\nSEE StateType for task state"
66506650
},
6651-
"ServicePricingPlanGet": {
6651+
"ServicePricingPlanGetLegacy": {
66526652
"properties": {
66536653
"pricingPlanId": {
66546654
"type": "integer",
@@ -6678,7 +6678,7 @@
66786678
},
66796679
"pricingUnits": {
66806680
"items": {
6681-
"$ref": "#/components/schemas/PricingUnitGet"
6681+
"$ref": "#/components/schemas/PricingUnitGetLegacy"
66826682
},
66836683
"type": "array",
66846684
"title": "Pricingunits"
@@ -6694,7 +6694,7 @@
66946694
"pricingPlanKey",
66956695
"pricingUnits"
66966696
],
6697-
"title": "ServicePricingPlanGet"
6697+
"title": "ServicePricingPlanGetLegacy"
66986698
},
66996699
"Solver": {
67006700
"properties": {
@@ -7035,7 +7035,7 @@
70357035
],
70367036
"title": "ValidationError"
70377037
},
7038-
"WalletGetWithAvailableCredits": {
7038+
"WalletGetWithAvailableCreditsLegacy": {
70397039
"properties": {
70407040
"walletId": {
70417041
"type": "integer",
@@ -7106,7 +7106,7 @@
71067106
"modified",
71077107
"availableCredits"
71087108
],
7109-
"title": "WalletGetWithAvailableCredits"
7109+
"title": "WalletGetWithAvailableCreditsLegacy"
71107110
},
71117111
"WalletStatus": {
71127112
"type": "string",

services/api-server/src/simcore_service_api_server/api/routes/credits.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from fastapi import APIRouter, Depends, status
44

5-
from ...models.schemas.model_adapter import GetCreditPrice
5+
from ...models.schemas.model_adapter import GetCreditPriceLegacy
66
from ..dependencies.webserver import AuthSession, get_webserver_session
77
from ._constants import FMSG_CHANGELOG_NEW_IN_VERSION
88

@@ -12,7 +12,7 @@
1212
@router.get(
1313
"/price",
1414
status_code=status.HTTP_200_OK,
15-
response_model=GetCreditPrice,
15+
response_model=GetCreditPriceLegacy,
1616
description=FMSG_CHANGELOG_NEW_IN_VERSION.format("0.6.0"),
1717
)
1818
async def get_credits_price(

services/api-server/src/simcore_service_api_server/api/routes/solvers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ...models.basic_types import VersionStr
1212
from ...models.pagination import OnePage, Page, PaginationParams
1313
from ...models.schemas.errors import ErrorGet
14-
from ...models.schemas.model_adapter import ServicePricingPlanGet
14+
from ...models.schemas.model_adapter import ServicePricingPlanGetLegacy
1515
from ...models.schemas.solvers import Solver, SolverKeyId, SolverPort
1616
from ...services.catalog import CatalogApi
1717
from ..dependencies.application import get_reverse_url_mapper
@@ -262,7 +262,7 @@ async def list_solver_ports(
262262

263263
@router.get(
264264
"/{solver_key:path}/releases/{version}/pricing_plan",
265-
response_model=ServicePricingPlanGet,
265+
response_model=ServicePricingPlanGetLegacy,
266266
description="Gets solver pricing plan\n\n"
267267
+ FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7"),
268268
responses=_SOLVER_STATUS_CODES,

services/api-server/src/simcore_service_api_server/api/routes/solvers_jobs_getters.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
JobOutputs,
3535
)
3636
from ...models.schemas.model_adapter import (
37-
PricingUnitGet,
38-
WalletGetWithAvailableCredits,
37+
PricingUnitGetLegacy,
38+
WalletGetWithAvailableCreditsLegacy,
3939
)
4040
from ...models.schemas.solvers import SolverKeyId
4141
from ...services.catalog import CatalogApi
@@ -378,7 +378,7 @@ async def get_job_custom_metadata(
378378

379379
@router.get(
380380
"/{solver_key:path}/releases/{version}/jobs/{job_id:uuid}/wallet",
381-
response_model=WalletGetWithAvailableCredits,
381+
response_model=WalletGetWithAvailableCreditsLegacy,
382382
responses=WALLET_STATUS_CODES,
383383
description=("Get job wallet\n\n" + FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7")),
384384
)
@@ -387,7 +387,7 @@ async def get_job_wallet(
387387
version: VersionStr,
388388
job_id: JobID,
389389
webserver_api: Annotated[AuthSession, Depends(get_webserver_session)],
390-
) -> WalletGetWithAvailableCredits:
390+
) -> WalletGetWithAvailableCreditsLegacy:
391391
job_name = _compose_job_resource_name(solver_key, version, job_id)
392392
_logger.debug("Getting wallet for job '%s'", job_name)
393393

@@ -398,7 +398,7 @@ async def get_job_wallet(
398398

399399
@router.get(
400400
"/{solver_key:path}/releases/{version}/jobs/{job_id:uuid}/pricing_unit",
401-
response_model=PricingUnitGet,
401+
response_model=PricingUnitGetLegacy,
402402
responses=_PRICING_UNITS_STATUS_CODES,
403403
description=(
404404
"Get job pricing unit\n\n" + FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7")

services/api-server/src/simcore_service_api_server/api/routes/wallets.py

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

66
from ...exceptions.service_errors_utils import DEFAULT_BACKEND_SERVICE_STATUS_CODES
77
from ...models.schemas.errors import ErrorGet
8-
from ...models.schemas.model_adapter import WalletGetWithAvailableCredits
8+
from ...models.schemas.model_adapter import WalletGetWithAvailableCreditsLegacy
99
from ..dependencies.webserver import AuthSession, get_webserver_session
1010
from ._constants import FMSG_CHANGELOG_NEW_IN_VERSION
1111

@@ -29,7 +29,7 @@
2929
@router.get(
3030
"/default",
3131
description="Get default wallet\n\n" + FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7"),
32-
response_model=WalletGetWithAvailableCredits,
32+
response_model=WalletGetWithAvailableCreditsLegacy,
3333
responses=WALLET_STATUS_CODES,
3434
)
3535
async def get_default_wallet(
@@ -40,7 +40,7 @@ async def get_default_wallet(
4040

4141
@router.get(
4242
"/{wallet_id}",
43-
response_model=WalletGetWithAvailableCredits,
43+
response_model=WalletGetWithAvailableCreditsLegacy,
4444
responses=WALLET_STATUS_CODES,
4545
description="Get wallet\n\n" + FMSG_CHANGELOG_NEW_IN_VERSION.format("0.7"),
4646
)

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

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,85 +7,98 @@
77
from models_library.api_schemas_api_server.pricing_plans import (
88
ServicePricingPlanGet as _ServicePricingPlanGet,
99
)
10-
from models_library.api_schemas_webserver._base import OutputSchema
1110
from models_library.api_schemas_webserver.product import (
1211
GetCreditPrice as _GetCreditPrice,
1312
)
1413
from models_library.api_schemas_webserver.resource_usage import (
1514
PricingUnitGet as _PricingUnitGet,
1615
)
17-
from models_library.api_schemas_webserver.wallets import WalletGet
1816
from models_library.api_schemas_webserver.wallets import (
1917
WalletGetWithAvailableCredits as _WalletGetWithAvailableCredits,
2018
)
21-
from models_library.basic_types import NonNegativeDecimal
19+
from models_library.basic_types import IDStr, NonNegativeDecimal
2220
from models_library.resource_tracker import (
2321
PricingPlanClassification,
2422
PricingPlanId,
2523
PricingUnitId,
2624
UnitExtraInfo,
2725
)
28-
from pydantic import Field, NonNegativeFloat, NonNegativeInt, PlainSerializer
29-
30-
31-
class GetCreditPrice(OutputSchema):
32-
product_name: str
33-
usd_per_credit: Annotated[
34-
NonNegativeDecimal,
35-
PlainSerializer(float, return_type=NonNegativeFloat, when_used="json"),
36-
] | None = Field(
26+
from models_library.users import GroupID
27+
from models_library.wallets import WalletID, WalletStatus
28+
from pydantic import BaseModel, Field, NonNegativeFloat, NonNegativeInt, PlainSerializer
29+
30+
31+
class GetCreditPriceLegacy(BaseModel):
32+
product_name: str = Field(alias="productName")
33+
usd_per_credit: (
34+
Annotated[
35+
NonNegativeDecimal,
36+
PlainSerializer(float, return_type=NonNegativeFloat, when_used="json"),
37+
]
38+
| None
39+
) = Field(
3740
...,
3841
description="Price of a credit in USD. "
3942
"If None, then this product's price is UNDEFINED",
43+
alias="usdPerCredit",
4044
)
4145
min_payment_amount_usd: NonNegativeInt | None = Field(
4246
...,
4347
description="Minimum amount (included) in USD that can be paid for this product"
4448
"Can be None if this product's price is UNDEFINED",
49+
alias="minPaymentAmountUsd",
4550
)
4651

4752

48-
assert set(GetCreditPrice.model_fields.keys()) == set(
53+
assert set(GetCreditPriceLegacy.model_fields.keys()) == set(
4954
_GetCreditPrice.model_fields.keys()
5055
)
5156

5257

53-
class PricingUnitGet(OutputSchema):
54-
pricing_unit_id: PricingUnitId
55-
unit_name: str
56-
unit_extra_info: UnitExtraInfo
58+
class PricingUnitGetLegacy(BaseModel):
59+
pricing_unit_id: PricingUnitId = Field(alias="pricingUnitId")
60+
unit_name: str = Field(alias="unitName")
61+
unit_extra_info: UnitExtraInfo = Field(alias="unitExtraInfo")
5762
current_cost_per_unit: Annotated[
5863
Decimal, PlainSerializer(float, return_type=NonNegativeFloat, when_used="json")
59-
]
64+
] = Field(alias="currentCostPerUnit")
6065
default: bool
6166

6267

63-
assert set(PricingUnitGet.model_fields.keys()) == set(
68+
assert set(PricingUnitGetLegacy.model_fields.keys()) == set(
6469
_PricingUnitGet.model_fields.keys()
6570
)
6671

6772

68-
class WalletGetWithAvailableCredits(WalletGet):
73+
class WalletGetWithAvailableCreditsLegacy(BaseModel):
74+
wallet_id: WalletID = Field(alias="walletId")
75+
name: IDStr
76+
description: str | None = None
77+
owner: GroupID
78+
thumbnail: str | None = None
79+
status: WalletStatus
80+
created: datetime
81+
modified: datetime
6982
available_credits: Annotated[
7083
Decimal, PlainSerializer(float, return_type=NonNegativeFloat, when_used="json")
71-
]
84+
] = Field(alias="availableCredits")
7285

7386

74-
assert set(WalletGetWithAvailableCredits.model_fields.keys()) == set(
87+
assert set(WalletGetWithAvailableCreditsLegacy.model_fields.keys()) == set(
7588
_WalletGetWithAvailableCredits.model_fields.keys()
7689
)
7790

7891

79-
class ServicePricingPlanGet(OutputSchema):
80-
pricing_plan_id: PricingPlanId
81-
display_name: str
92+
class ServicePricingPlanGetLegacy(BaseModel):
93+
pricing_plan_id: PricingPlanId = Field(alias="pricingPlanId")
94+
display_name: str = Field(alias="displayName")
8295
description: str
8396
classification: PricingPlanClassification
84-
created_at: datetime
85-
pricing_plan_key: str
86-
pricing_units: list[PricingUnitGet]
97+
created_at: datetime = Field(alias="createdAt")
98+
pricing_plan_key: str = Field(alias="pricingPlanKey")
99+
pricing_units: list[PricingUnitGetLegacy] = Field(alias="pricingUnits")
87100

88101

89-
assert set(ServicePricingPlanGet.model_fields.keys()) == set(
102+
assert set(ServicePricingPlanGetLegacy.model_fields.keys()) == set(
90103
_ServicePricingPlanGet.model_fields.keys()
91104
)

0 commit comments

Comments
 (0)