# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
import datetime
from typing import Any

from pydantic import BaseModel, ConfigDict, Field


class ChannelStats(BaseModel):
    """
    Statistics per channel.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    channel: str = Field(description='Channel name')
    total: int = Field(description='Total publishes to this channel')
    successful: int = Field(description='Successful publishes')
    failed: int = Field(description='Failed publishes')
    avg_duration_ms: float = Field(description='Average duration')
    avg_acks: float = Field(description='Average ACKs received')
    last_activity_at: str | None = Field(None, description='Last activity timestamp (ISO for...')



class ChannelList(BaseModel):
    """
    List of channel statistics.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    channels: list[ChannelStats] = Field(description='Channel statistics')
    total_channels: int = Field(description='Total number of channels')



class CentrifugoHealthCheck(BaseModel):
    """
    Health check response.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    status: str = Field(description='Health status: healthy or unhealthy')
    wrapper_url: str = Field(description='Configured wrapper URL')
    has_api_key: bool = Field(description='Whether API key is configured')
    timestamp: str = Field(description='Current timestamp')



class CentrifugoOverviewStats(BaseModel):
    """
    Overview statistics for Centrifugo publishes.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    total: int = Field(description='Total publishes in period')
    successful: int = Field(description='Successful publishes')
    failed: int = Field(description='Failed publishes')
    timeout: int = Field(description='Timeout publishes')
    success_rate: float = Field(description='Success rate percentage')
    avg_duration_ms: float = Field(description='Average duration in milliseconds')
    avg_acks_received: float = Field(description='Average ACKs received')
    period_hours: int = Field(description='Statistics period in hours')



class Publish(BaseModel):
    """
    Single publish item for DRF pagination.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    message_id: str = ...
    channel: str = ...
    status: str = ...
    wait_for_ack: bool = ...
    acks_received: int = ...
    acks_expected: int | None = None
    duration_ms: float | None = None
    created_at: datetime.datetime = ...
    completed_at: datetime.datetime | None = None
    error_code: str | None = None
    error_message: str | None = None



class PaginatedPublishList(BaseModel):
    """
    
    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    count: int = Field(description='Total number of items across all...')
    page: int = Field(description='Current page number (1-based)')
    pages: int = Field(description='Total number of pages')
    page_size: int = Field(description='Number of items per page')
    has_next: bool = Field(description='Whether there is a next page')
    has_previous: bool = Field(description='Whether there is a previous page')
    next_page: int | None = Field(None, description='Next page number (null if no nex...')
    previous_page: int | None = Field(None, description='Previous page number (null if no...')
    results: list[Publish] = Field(description='Array of items for current page')



class TimelineItem(BaseModel):
    """
    Single timeline data point for DRF.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    timestamp: str = ...
    count: int = ...
    successful: int = ...
    failed: int = ...
    timeout: int = ...



class TimelineResponse(BaseModel):
    """
    Timeline response with hourly/daily breakdown for DRF.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    timeline: list[TimelineItem] = ...
    period_hours: int = ...
    interval: str = ...



