# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
import datetime
from typing import Any

from pydantic import BaseModel, ConfigDict, Field


class ApiKey(BaseModel):
    """
    API Key information (read-only).

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

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

    id: int = Field(description='Database ID')
    name: str = Field(description='Key name/description')
    masked_key: str = Field(description='Masked API key (first 4 and last...')
    is_active: bool = Field(description='Whether key is active')
    is_valid: bool = Field(description='Whether key is valid (active and...')
    user_id: int = Field(description='User ID')
    username: str = Field(description='Username')
    user_email: str = Field(description='User email')
    request_count: int = Field(description='Total requests made with this key')
    last_used_at: datetime.datetime | None = Field(None, description='When key was last used')
    expires_at: datetime.datetime | None = Field(
    None,
    description='When key expires (null = never)',
)
    created_at: datetime.datetime = Field(description='When key was created')



class PaginatedApiKeyList(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[ApiKey] = Field(description='Array of items for current page')



class ApiKeyStats(BaseModel):
    """
    API Key usage statistics.

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

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

    total_keys: int = Field(description='Total API keys')
    active_keys: int = Field(description='Active API keys')
    expired_keys: int = Field(description='Expired API keys')
    total_requests: int = Field(description='Total requests across all keys')



