from typing import Any

from aws_lambda_powertools.event_handler.openapi.params import Body
from aws_lambda_powertools.shared.types import Annotated
from aws_lambda_powertools.utilities.typing import LambdaContext

from service.handlers.utils.observability import logger
from service.handlers.utils.rest_api_resolver import app
from service.models.input import CreateOrderRequest
from service.models.output import CreateOrderOutput, InternalServerErrorOutput, InvalidRestApiRequest


@app.post(
    '/api/orders/',
    summary='Create an order',
    description='Create an order identified by the body payload',
    response_description='The created order',
    responses={
        200: {
            'description': 'The created order',
            'content': {'application/json': {'model': CreateOrderOutput}},
        },
        442: {
            'description': 'Invalid create order request',
            'content': {'application/json': {'model': InvalidRestApiRequest}},
        },
        501: {
            'description': 'Internal server error',
            'content': {'application/json': {'model': InternalServerErrorOutput}},
        },
    },
    tags=['CRUD'],
)
def handle_create_order(create_input: Annotated[CreateOrderRequest, 
                        Body(embed=False, media_type='application/json')]) -> CreateOrderOutput:
    logger.info('write handler code here')


def lambda_handler(event: dict[str, Any], context: LambdaContext) -> dict[str, Any]:
    return app.resolve(event, context)