# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
import datetime
from typing import Any

from pydantic import BaseModel, ConfigDict, Field


class ShortLinkList(BaseModel):
    """
    Serializer for listing short links.

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

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

    id: str = ...
    code: Any = Field(description='Short code for the URL')
    custom_slug: Any | None = Field(None, description='Custom slug (optional)')
    target_url: str = Field(description='Target URL to redirect to')
    short_url: Any = ...
    is_active: bool = Field(description='Whether the link is active')
    is_expired: bool = ...
    is_valid: bool = ...
    hit_count: int = Field(description='Number of times the link was acc...')
    max_hits: int | None = Field(None, description='Maximum number of redirects (nul...')
    expires_at: datetime.datetime | None = Field(
    None,
    description='When the link expires (null = ne...',
)
    created_at: datetime.datetime = ...



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



class ShortLinkCreateRequest(BaseModel):
    """
    Serializer for creating short links.

    Request model (no read-only fields).
    """

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

    target_url: str = Field(min_length=1, max_length=2000)
    custom_slug: str | None = Field(None, min_length=1, max_length=50)
    expires_at: datetime.datetime | None = None
    max_hits: int | None = Field(None, ge=1)
    metadata: dict[str, Any] | None = None



class ShortLinkCreate(BaseModel):
    """
    Serializer for creating short links.

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

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

    target_url: str = Field(max_length=2000)
    custom_slug: str | None = Field(None, max_length=50)
    expires_at: datetime.datetime | None = None
    max_hits: int | None = Field(None, ge=1)
    metadata: dict[str, Any] | None = None



class ShortLinkDetail(BaseModel):
    """
    Serializer for short link details.

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

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

    id: str = ...
    code: Any = Field(description='Short code for the URL')
    custom_slug: Any | None = Field(None, description='Custom slug (optional)')
    target_url: str = Field(description='Target URL to redirect to')
    short_url: Any = ...
    is_active: bool = Field(description='Whether the link is active')
    is_expired: bool = ...
    is_valid: bool = ...
    hit_count: int = Field(description='Number of times the link was acc...')
    max_hits: int | None = Field(None, description='Maximum number of redirects (nul...')
    expires_at: datetime.datetime | None = Field(
    None,
    description='When the link expires (null = ne...',
)
    created_at: datetime.datetime = ...
    last_hit_at: datetime.datetime | None = Field(
    None,
    description='Last time the link was accessed',
)
    metadata: dict[str, Any] | None = Field(
    None,
    description='Additional metadata (e.g., title...',
)
    updated_at: datetime.datetime = ...



class ShortLinkStats(BaseModel):
    """
    Serializer for shortlink statistics.

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

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

    total_links: int = Field(description='Total number of short links')
    active_links: int = Field(description='Number of active links')
    total_hits: int = Field(description='Total hit count across all links')



