# Generated by smithplates HTTP codegen. Do not edit.

from __future__ import annotations

from dataclasses import dataclass

from fastapi import HTTPException, Request
from generated.widget_api.widget_api.apis.v1_widgets_api_base import V1WidgetsApiServiceProtocol


@dataclass(frozen=True)
class ApiServices:
    v1_widgets_api: V1WidgetsApiServiceProtocol


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
