# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
from typing import Any

from pydantic import BaseModel, ConfigDict, Field

from ..enums import QuickActionColor, StatCardChangeType, SystemHealthOverallStatus


class SystemMetrics(BaseModel):
    """
    Serializer for system performance metrics.

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

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

    cpu_usage: float = Field(description='CPU usage percentage')
    memory_usage: float = Field(description='Memory usage percentage')
    disk_usage: float = Field(description='Disk usage percentage')
    network_in: str = Field(description='Network incoming bandwidth')
    network_out: str = Field(description='Network outgoing bandwidth')
    response_time: str = Field(description='Average response time')
    uptime: str = Field(description='System uptime')



class ModelStatistics(BaseModel):
    """
    Serializer for individual model statistics.

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

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

    model_name: str = Field(description='Model name (key)')
    name: str = Field(description='Model verbose name')
    count: int = Field(description='Number of records in this model')
    fields_count: int = Field(description='Number of fields in model')
    admin_url: str = Field(description='Django admin URL name')



class AppStatisticsData(BaseModel):
    """
    Serializer for application statistics data.

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

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

    name: str = Field(description='Human-readable app name')
    models: list[ModelStatistics] = Field(description='List of model statistics')
    total_records: int = Field(description='Total records count')
    model_count: int = Field(description='Number of models')



class AppStatistics(BaseModel):
    """
    Serializer for application-specific statistics.

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

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

    app_name: str = Field(description='Application name')
    statistics: AppStatisticsData = ...



class StatCard(BaseModel):
    """
    Serializer for dashboard statistics cards. Maps to StatCard Pydantic model.

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

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

    title: str = Field(description='Card title')
    value: str = Field(description='Main value to display')
    icon: str = Field(description='Material icon name')
    change: str | None = Field(None, description="Change indicator (e.g., '+12%')")
    change_type: StatCardChangeType | None = Field(
    None,
    description='Change type  * `positive` - posi...',
)
    description: str | None = Field(None, description='Additional description')
    color: str | None = Field(None, description='Card color theme')



class UserStatistics(BaseModel):
    """
    Serializer for user statistics.

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

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

    total_users: int = Field(description='Total number of users')
    active_users: int = Field(description='Active users (last 30 days)')
    new_users: int = Field(description='New users (last 7 days)')
    superusers: int = Field(description='Number of superusers')



class ActivityEntry(BaseModel):
    """
    Serializer for recent activity entries.

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

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

    id: int = Field(description='Activity ID')
    user: str = Field(description='User who performed the action')
    action: str = Field(description='Action type (created, updated, d...')
    resource: str = Field(description='Resource affected')
    timestamp: str = Field(description='Activity timestamp (ISO format)')
    icon: str = Field(description='Material icon name')
    color: str = Field(description='Icon color')



class ExtensionInfo(BaseModel):
    """
    Extension information for frontend menu filtering.

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

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

    name: str = Field(description="Extension name (e.g., 'support',...")
    type: str = Field(description="Extension type: 'app' or 'module'")
    version: str | None = Field(None, description='Extension version')
    is_valid: bool = Field(description='Whether extension is properly co...')
    description: str | None = Field(None, description='Extension description')



class QuickAction(BaseModel):
    """
    Serializer for quick action buttons. Maps to QuickAction Pydantic model.

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

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

    title: str = Field(description='Action title')
    description: str = Field(description='Action description')
    icon: str = Field(description='Material icon name')
    link: str = Field(description='Action URL')
    color: QuickActionColor | None = Field(None, description='Button color theme  * `primary` ...')
    category: str | None = Field(None, description='Action category')



class SystemHealthItem(BaseModel):
    """
    Serializer for system health status items. Maps to SystemHealthItem Pydantic
    model.

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

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

    component: str = Field(description='Component name')
    status: SystemHealthOverallStatus = Field(description='Health status  * `healthy` - hea...')
    description: str = Field(description='Status description')
    last_check: str = Field(description='Last check time (ISO format)')
    health_percentage: int | None = Field(
    None,
    description='Health percentage (0-100)',
    ge=0,
    le=100,
)



class SystemHealth(BaseModel):
    """
    Serializer for overall system health status.

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

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

    overall_status: SystemHealthOverallStatus = Field(
    description='Overall system health status  * ...',
)
    overall_health_percentage: int = Field(description='Overall health percentage', ge=0, le=100)
    components: list[SystemHealthItem] = Field(description='Health status of individual comp...')
    timestamp: str = Field(description='Check timestamp (ISO format)')



class DashboardOverview(BaseModel):
    """
    Main serializer for dashboard overview endpoint. Uses typed serializers for
    proper OpenAPI schema generation.

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

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

    stat_cards: list[StatCard] = Field(description='Dashboard statistics cards')
    system_health: SystemHealth = ...
    quick_actions: list[QuickAction] = Field(description='Quick action buttons')
    recent_activity: list[ActivityEntry] = Field(description='Recent activity entries')
    system_metrics: SystemMetrics = ...
    user_statistics: UserStatistics = ...
    app_statistics: list[AppStatistics] | None = Field(None, description='Application statistics')
    extensions: list[ExtensionInfo] | None = Field(
    None,
    description='Installed extensions info for me...',
)
    timestamp: str = Field(description='Data timestamp (ISO format)')



