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

from fastapi import (
    APIRouter,
    Body,
    Depends,
    Path,
)
from generated.asset_api.asset_api.api_response import dispatch_api_response
from generated.asset_api.asset_api.app_services import ApiServices, get_api_services
from generated.asset_api.asset_api.operation_bindings import OPERATION_HTTP_BINDINGS
from generated.example.asset_output import AssetOutput
from generated.example.asset_state_patch import AssetStatePatch
from generated.example.redirect import Redirect
from pydantic import Field  # noqa: F401

router = APIRouter()


@router.get(
    "/assets/{id}",
    responses={
        200: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def get_asset(
    services: Annotated[ApiServices, Depends(get_api_services)],
    id_: str = Path(..., alias="id"),
) -> AssetOutput:
    return dispatch_api_response(
        await services.assets_api.get_asset(id_=id_),
        OPERATION_HTTP_BINDINGS["get_asset"],
    )


@router.get(
    "/assets/{id}/content",
    responses={
        302: {"description": "Response"},
        404: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def get_asset_content(
    services: Annotated[ApiServices, Depends(get_api_services)],
    id_: str = Path(..., alias="id"),
) -> Redirect:
    return dispatch_api_response(
        await services.assets_api.get_asset_content(id_=id_),
        OPERATION_HTTP_BINDINGS["get_asset_content"],
    )


@router.patch(
    "/assets/{id}/state",
    responses={
        200: {"description": "Response"},
        409: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def update_asset_state(
    services: Annotated[ApiServices, Depends(get_api_services)],
    id_: str = Path(..., alias="id"),
    body: AssetStatePatch = Body(...),
) -> AssetOutput:
    return dispatch_api_response(
        await services.assets_api.update_asset_state(id_=id_, body=body),
        OPERATION_HTTP_BINDINGS["update_asset_state"],
    )
