"""Health check response schemas."""

from typing import Literal

from pydantic import BaseModel, Field


class DependencyHealth(BaseModel):
    """Health status of an individual dependency.

    Attributes:
        status: Whether the dependency is healthy or unhealthy.
        latency_ms: Response time in milliseconds for the health check.
        error: Error message if the dependency is unhealthy.
    """

    status: Literal["healthy", "unhealthy"]
    latency_ms: int | None = Field(default=None, ge=0)
    error: str | None = None


class HealthResponse(BaseModel):
    """Overall API health response.

    Attributes:
        status: Overall health status - healthy, degraded, or unhealthy.
        version: Application version string.
        dependencies: Health status of each dependency.
    """

    status: Literal["healthy", "degraded", "unhealthy"]
    version: str
    dependencies: dict[str, DependencyHealth]
