|
| 1 | +""" Helper script to generate OAS automatically |
| 2 | +""" |
| 3 | + |
| 4 | +# pylint: disable=redefined-outer-name |
| 5 | +# pylint: disable=unused-argument |
| 6 | +# pylint: disable=unused-variable |
| 7 | +# pylint: disable=too-many-arguments |
| 8 | + |
| 9 | +from typing import Annotated |
| 10 | + |
| 11 | +from _common import as_query |
| 12 | +from fastapi import APIRouter, Depends, status |
| 13 | +from models_library.api_schemas_webserver.licensed_items import LicensedItemGet |
| 14 | +from models_library.generics import Envelope |
| 15 | +from models_library.rest_error import EnvelopedError |
| 16 | +from simcore_service_webserver._meta import API_VTAG |
| 17 | +from simcore_service_webserver.catalog.licenses._exceptions_handlers import ( |
| 18 | + _TO_HTTP_ERROR_MAP, |
| 19 | +) |
| 20 | +from simcore_service_webserver.catalog.licenses._models import ( |
| 21 | + LicensedItemsBodyParams, |
| 22 | + LicensedItemsListQueryParams, |
| 23 | + LicensedItemsPathParams, |
| 24 | +) |
| 25 | + |
| 26 | +router = APIRouter( |
| 27 | + prefix=f"/{API_VTAG}", |
| 28 | + tags=[ |
| 29 | + "licenses", |
| 30 | + "catalog", |
| 31 | + ], |
| 32 | + responses={ |
| 33 | + i.status_code: {"model": EnvelopedError} for i in _TO_HTTP_ERROR_MAP.values() |
| 34 | + }, |
| 35 | +) |
| 36 | + |
| 37 | + |
| 38 | +@router.get( |
| 39 | + "/catalog/licensed-items", |
| 40 | + response_model=Envelope[list[LicensedItemGet]], |
| 41 | +) |
| 42 | +async def list_licensed_items( |
| 43 | + _query: Annotated[as_query(LicensedItemsListQueryParams), Depends()], |
| 44 | +): |
| 45 | + ... |
| 46 | + |
| 47 | + |
| 48 | +@router.get( |
| 49 | + "/catalog/licensed-items/{licensed_item_id}", |
| 50 | + response_model=Envelope[LicensedItemGet], |
| 51 | +) |
| 52 | +async def get_licensed_item( |
| 53 | + _path: Annotated[LicensedItemsPathParams, Depends()], |
| 54 | +): |
| 55 | + ... |
| 56 | + |
| 57 | + |
| 58 | +@router.post( |
| 59 | + "/catalog/licensed-items/{licensed_item_id}:purchase", |
| 60 | + status_code=status.HTTP_204_NO_CONTENT, |
| 61 | +) |
| 62 | +async def purchase_licensed_item( |
| 63 | + _path: Annotated[LicensedItemsPathParams, Depends()], |
| 64 | + _body: LicensedItemsBodyParams, |
| 65 | +): |
| 66 | + ... |
0 commit comments