# Generated by smithplates HTTP codegen. Do not edit.
from typing import Annotated

from fastapi import (
    APIRouter,
    Body,
    Depends,
    Path,
)
from generated.example.widget_api.api_response import dispatch_api_response
from generated.example.widget_api.app_services import ApiServices, get_api_services
from generated.example.widget_api.operation_bindings import OPERATION_HTTP_BINDINGS
from generated.example.widget_output import WidgetOutput
from generated.example.widget_patch import WidgetPatch
from pydantic import Field  # noqa: F401

router = APIRouter()


@router.delete(
    "/v1/widgets/{id}",
    responses={
        204: {"description": "Response"},
        404: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def delete_widget(
    services: Annotated[ApiServices, Depends(get_api_services)],
    id_: str = Path(..., alias="id"),
) -> None:
    return dispatch_api_response(
        await services.v1_widgets_api.delete_widget(id_=id_),
        OPERATION_HTTP_BINDINGS["delete_widget"],
    )


@router.patch(
    "/v1/widgets/{id}",
    responses={
        200: {"description": "Response"},
        404: {"description": "Response"},
        409: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def mutate_widget(
    services: Annotated[ApiServices, Depends(get_api_services)],
    id_: str = Path(..., alias="id"),
    body: WidgetPatch = Body(...),
) -> WidgetOutput:
    return dispatch_api_response(
        await services.v1_widgets_api.mutate_widget(id_=id_, body=body),
        OPERATION_HTTP_BINDINGS["mutate_widget"],
    )
