from __future__ import annotations

from typing import Generic, TypeVar

from pydantic import BaseModel

T = TypeVar("T")


class ErrorResponse(BaseModel):
    detail: str


class PaginatedResponse(BaseModel, Generic[T]):
    items: list[T]
    total: int
    page: int
    page_size: int
    total_pages: int
    has_next: bool
    has_previous: bool


class RootStatusRead(BaseModel):
    message: str


class HealthDatabaseStatusRead(BaseModel):
    configured: bool
    ok: bool
    error: str | None = None


class HealthRedisStatusRead(BaseModel):
    configured: bool
    enabled: bool


class HealthCheckRead(BaseModel):
    status: str
    database: HealthDatabaseStatusRead
    redis: HealthRedisStatusRead
