# Generated by smithplates HTTP codegen. Do not edit.

from __future__ import annotations

from dataclasses import dataclass
from typing import TYPE_CHECKING, Protocol, cast

from fastapi import HTTPException, Request

if TYPE_CHECKING:
    from generated.example.auth_api.apis.auth_api_base import AuthApiServiceProtocol


@dataclass(frozen=True)
class AuthCredential:
    scheme_id: str
    value: str


@dataclass(frozen=True)
class AuthContext:
    scheme_id: str
    identity: object


class AuthVerifier(Protocol):
    async def verify(self, credential: AuthCredential) -> object | None: ...


@dataclass(frozen=True)
class ApiServices:
    auth_api: AuthApiServiceProtocol


def get_api_services(request: Request) -> ApiServices:
    services = getattr(request.app.state, "api_services", None)
    if not isinstance(services, ApiServices):
        raise HTTPException(status_code=500, detail="API services are not configured")
    return services


def get_auth_verifier(request: Request) -> AuthVerifier | None:
    return cast(
        "AuthVerifier | None",
        getattr(request.app.state, "auth_verifier", None),
    )
