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

from fastapi import (
    APIRouter,
    Depends,
    Request,
)
from generated.example.auth_api.api_response import dispatch_api_response
from generated.example.auth_api.app_services import (
    ApiServices,
    get_api_services,
    get_auth_verifier,
)
from generated.example.auth_api.operation_bindings import (
    OPERATION_AUTH_BINDINGS,
    OPERATION_HTTP_BINDINGS,
    authenticate_optional_request,
    authenticate_required_request,
)
from generated.example.auth_output import AuthOutput
from pydantic import Field  # noqa: F401

router = APIRouter()


@router.get(
    "/optional",
    responses={
        200: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def optional(
    services: Annotated[ApiServices, Depends(get_api_services)],
    request: Request,
) -> AuthOutput:
    auth = await authenticate_optional_request(
        request,
        OPERATION_AUTH_BINDINGS["optional"],
        get_auth_verifier(request),
    )
    return cast(
        AuthOutput,
        dispatch_api_response(
            await services.auth_api.optional(auth=auth),
            OPERATION_HTTP_BINDINGS["optional"],
        ),
    )


@router.get(
    "/public",
    responses={
        200: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def public(
    services: Annotated[ApiServices, Depends(get_api_services)],
) -> AuthOutput:
    return cast(
        AuthOutput,
        dispatch_api_response(
            await services.auth_api.public(),
            OPERATION_HTTP_BINDINGS["public"],
        ),
    )


@router.get(
    "/required",
    responses={
        200: {"description": "Response"},
    },
    response_model_by_alias=True,
)
async def required(
    services: Annotated[ApiServices, Depends(get_api_services)],
    request: Request,
) -> AuthOutput:
    auth = await authenticate_required_request(
        request,
        OPERATION_AUTH_BINDINGS["required"],
        get_auth_verifier(request),
    )
    return cast(
        AuthOutput,
        dispatch_api_response(
            await services.auth_api.required(auth=auth),
            OPERATION_HTTP_BINDINGS["required"],
        ),
    )
