Skip to content

Commit 2d68532

Browse files
committed
ensure price and meta endpoints are backwards compatible
1 parent 42711d9 commit 2d68532

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

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
@@ -1,8 +1,8 @@
11
from typing import Annotated
22

33
from fastapi import APIRouter, Depends, status
4-
from models_library.api_schemas_webserver.product import GetCreditPrice
54

5+
from ...models.schemas.backwards_compatibility import GetCreditPriceApiServer
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=GetCreditPriceApiServer,
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/models/schemas/meta.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
from typing import Annotated
22

33
from models_library.api_schemas__common.meta import BaseMeta
4-
from pydantic import AnyHttpUrl, ConfigDict, StringConstraints
4+
from models_library.basic_types import VersionStr
5+
from pydantic import AnyHttpUrl, ConfigDict, Field, StringConstraints
56

67

78
class Meta(BaseMeta):
89
docs_url: Annotated[AnyHttpUrl, StringConstraints(max_length=65536)]
910
docs_dev_url: Annotated[AnyHttpUrl, StringConstraints(max_length=65536)]
11+
released: dict[str, VersionStr] = Field(
12+
default=None, description="Maps every route's path tag with a released version"
13+
)
1014
model_config = ConfigDict(
1115
json_schema_extra={
1216
"example": {

services/api-server/src/simcore_service_api_server/services/webserver.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from models_library.api_schemas_api_server.pricing_plans import ServicePricingPlanGet
1414
from models_library.api_schemas_long_running_tasks.tasks import TaskGet
1515
from models_library.api_schemas_webserver.computations import ComputationStart
16-
from models_library.api_schemas_webserver.product import GetCreditPrice
1716
from models_library.api_schemas_webserver.projects import (
1817
ProjectCreateNew,
1918
ProjectGet,
@@ -64,6 +63,9 @@
6463
SolverOutputNotFoundError,
6564
WalletNotFoundError,
6665
)
66+
from simcore_service_api_server.models.schemas.backwards_compatibility import (
67+
GetCreditPriceApiServer,
68+
)
6769
from tenacity import TryAgain
6870
from tenacity.asyncio import AsyncRetrying
6971
from tenacity.before_sleep import before_sleep_log
@@ -573,13 +575,13 @@ async def get_project_wallet(self, *, project_id: ProjectID) -> WalletGet:
573575
# PRODUCTS -------------------------------------------------
574576

575577
@_exception_mapper({status.HTTP_404_NOT_FOUND: ProductPriceNotFoundError})
576-
async def get_product_price(self) -> GetCreditPrice:
578+
async def get_product_price(self) -> GetCreditPriceApiServer:
577579
response = await self.client.get(
578580
"/credits-price",
579581
cookies=self.session_cookies,
580582
)
581583
response.raise_for_status()
582-
data = Envelope[GetCreditPrice].model_validate_json(response.text).data
584+
data = Envelope[GetCreditPriceApiServer].model_validate_json(response.text).data
583585
assert data is not None # nosec
584586
return data
585587

0 commit comments

Comments
 (0)