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

from fastapi import (
    APIRouter,
    Body,
    Depends,
    Path,
    Query,
)
from generated.example.create_project_input import CreateProjectInput
from generated.example.project_list_output import ProjectListOutput
from generated.example.project_output import ProjectOutput
from generated.project_api.project_api.api_response import dispatch_api_response
from generated.project_api.project_api.app_services import ApiServices, get_api_services
from generated.project_api.project_api.operation_bindings import OPERATION_HTTP_BINDINGS
from pydantic import Field  # noqa: F401

router = APIRouter()


@router.post(
    "/projects",
    responses={
        201: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def create_project(
    services: Annotated[ApiServices, Depends(get_api_services)],
    create_project_input: CreateProjectInput = Body(...),
) -> ProjectOutput:
    return dispatch_api_response(
        await services.projects_api.create_project(create_project_input=create_project_input),
        OPERATION_HTTP_BINDINGS["create_project"],
    )


@router.get(
    "/projects/{projectId}",
    responses={
        200: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def get_project(
    services: Annotated[ApiServices, Depends(get_api_services)],
    project_id: str = Path(..., alias="projectId"),
) -> ProjectOutput:
    return dispatch_api_response(
        await services.projects_api.get_project(project_id=project_id),
        OPERATION_HTTP_BINDINGS["get_project"],
    )


@router.get(
    "/projects",
    responses={
        200: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def list_projects(
    services: Annotated[ApiServices, Depends(get_api_services)],
    limit: int | None = Query(None, alias="limit"),
) -> ProjectListOutput:
    return dispatch_api_response(
        await services.projects_api.list_projects(limit=limit),
        OPERATION_HTTP_BINDINGS["list_projects"],
    )
