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

from fastapi import (
    APIRouter,
    Body,
    Depends,
    Path,
    Query,
)
from generated.example.task_list_output import TaskListOutput
from generated.example.task_output import TaskOutput
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/{projectId}/tasks",
    responses={
        201: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def create_project_task(
    services: Annotated[ApiServices, Depends(get_api_services)],
    project_id: str = Path(..., alias="projectId"),
    title: str = Body(...),
) -> TaskOutput:
    return dispatch_api_response(
        await services.project_tasks_api.create_project_task(project_id=project_id, title=title),
        OPERATION_HTTP_BINDINGS["create_project_task"],
    )


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


@router.get(
    "/projects/{projectId}/tasks",
    responses={
        200: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def list_project_tasks(
    services: Annotated[ApiServices, Depends(get_api_services)],
    project_id: str = Path(..., alias="projectId"),
    page: str | None = Query(None, alias="page"),
) -> TaskListOutput:
    return dispatch_api_response(
        await services.project_tasks_api.list_project_tasks(project_id=project_id, page=page),
        OPERATION_HTTP_BINDINGS["list_project_tasks"],
    )
