from typing import Annotated from aws_lambda_powertools.event_handler.api_gateway import Router from aws_lambda_powertools.event_handler.exceptions import ( NotFoundError, ) from aws_lambda_powertools.event_handler.openapi.params import Path from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair from boto3clients import dynamodb_client from config import ORDER_TABLE router = Router() dyn = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client) class CouponNotFoundError(NotFoundError): ... @router.get('/') def coupon(coupon: Annotated[str, Path(min_length=3)]): return dyn.collection.get_item( KeyPair('COUPON', coupon.upper()), exc_cls=CouponNotFoundError, )