# Generated by smithplates HTTP codegen. Do not edit.
from datetime import datetime  # noqa: F401
from typing import Annotated

from fastapi import (
    APIRouter,
    Body,
    Depends,
    Path,
)
from pydantic import Field  # noqa: F401

from generated.petstore.api.create_pet_input import CreatePetInput
from generated.petstore.api.create_pet_output import CreatePetOutput
from generated.petstore.api.get_pet_output import GetPetOutput
from generated.petstore.api.pet_location_redirect import PetLocationRedirect
from generated.petstore.api.petstore.api_response import dispatch_api_response
from generated.petstore.api.petstore.app_services import ApiServices, get_api_services
from generated.petstore.api.petstore.operation_bindings import OPERATION_HTTP_BINDINGS
from generated.petstore.api.update_pet_body import UpdatePetBody
from generated.petstore.api.update_pet_output import UpdatePetOutput

router = APIRouter()


@router.post(
    "/pets",
    responses={
        201: {"description": "Response"},
        400: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def create_pet(
    services: Annotated[ApiServices, Depends(get_api_services)],
    create_pet_input: CreatePetInput = Body(...),
) -> CreatePetOutput:
    return dispatch_api_response(
        await services.pets_api.create_pet(create_pet_input=create_pet_input),
        OPERATION_HTTP_BINDINGS["create_pet"],
    )


@router.delete(
    "/pets/{petId}",
    responses={
        204: {"description": "Response"},
        404: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def delete_pet(
    services: Annotated[ApiServices, Depends(get_api_services)],
    pet_id: str = Path(..., alias="petId"),
) -> None:
    return dispatch_api_response(
        await services.pets_api.delete_pet(pet_id=pet_id),
        OPERATION_HTTP_BINDINGS["delete_pet"],
    )


@router.get(
    "/pets/{petId}",
    responses={
        200: {"description": "Response"},
        404: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def get_pet(
    services: Annotated[ApiServices, Depends(get_api_services)],
    pet_id: str = Path(..., alias="petId"),
) -> GetPetOutput:
    return dispatch_api_response(
        await services.pets_api.get_pet(pet_id=pet_id),
        OPERATION_HTTP_BINDINGS["get_pet"],
    )


@router.get(
    "/pets/{petId}/location",
    responses={
        302: {"description": "Response"},
        404: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def resolve_pet_location(
    services: Annotated[ApiServices, Depends(get_api_services)],
    pet_id: str = Path(..., alias="petId"),
) -> PetLocationRedirect:
    return dispatch_api_response(
        await services.pets_api.resolve_pet_location(pet_id=pet_id),
        OPERATION_HTTP_BINDINGS["resolve_pet_location"],
    )


@router.put(
    "/pets/{petId}",
    responses={
        200: {"description": "Response"},
        400: {"description": "Response"},
        404: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def update_pet(
    services: Annotated[ApiServices, Depends(get_api_services)],
    pet_id: str = Path(..., alias="petId"),
    body: UpdatePetBody = Body(...),
) -> UpdatePetOutput:
    return dispatch_api_response(
        await services.pets_api.update_pet(pet_id=pet_id, body=body),
        OPERATION_HTTP_BINDINGS["update_pet"],
    )
