"""# Summary Vets route handlers — names must match openapi.yaml operationIds. """ from fastapi import Request, Response from interfaces._common import delete_or_404, dump, paginate, read_or_404, svc async def list_vets(request: Request, limit: int = 20, offset: int = 0) -> dict: """List vets (paginated). ``limit=0`` returns all remaining items. Args: request (Request): Incoming request. limit (int): Page size. Defaults to 20. offset (int): Items to skip. Defaults to 0. Returns: dict: ``{"total": int, "items": list[Vet]}``. """ docs = await svc(request, "vet").search({}) return paginate([dump(d) for d in docs], limit, offset) async def create_vet(request: Request, body: dict, response: Response) -> dict: """Create a vet. Args: request (Request): Incoming request. body (dict): Vet fields (``id`` ignored). response (Response): Response object; set to 201 on success. Returns: dict: The created vet. """ response.status_code = 201 body.pop("id", None) doc = await svc(request, "vet").create(body) return dump(doc) async def get_vet(request: Request, id: int) -> dict: """Fetch one vet by id. Args: request (Request): Incoming request. id (int): Vet identifier. Returns: dict: The vet document. Raises: HTTPException: 404 when the vet does not exist. """ return dump(await read_or_404(svc(request, "vet"), id, "vet")) async def update_vet(request: Request, id: int, body: dict) -> dict: """Replace a vet by id. Args: request (Request): Incoming request. id (int): Vet identifier. body (dict): Full replacement payload. Returns: dict: The updated vet. Raises: HTTPException: 404 when the vet does not exist. """ await read_or_404(svc(request, "vet"), id, "vet") body.pop("id", None) doc = await svc(request, "vet").update(id, body) return dump(doc) async def delete_vet(request: Request, id: int, response: Response) -> None: """Delete a vet by id. Args: request (Request): Incoming request. id (int): Vet identifier. response (Response): Response object; set to 204 on success. Raises: HTTPException: 404 when the vet does not exist. """ await delete_or_404(svc(request, "vet"), id, "vet") response.status_code = 204