# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
import datetime
from typing import Any

from pydantic import BaseModel, ConfigDict, Field

from ..enums import CDNJobStatusStatus


class CDNFileList(BaseModel):
    """
    Serializer for listing CDN files.

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

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

    id: str = ...
    uuid: str = Field(description='Unique file identifier for URLs')
    filename: Any = Field(description='Original filename')
    content_type: Any = Field(description='MIME type of the file')
    size_bytes: int = Field(description='File size in bytes')
    is_public: bool = Field(description='Whether file is publicly accessible')
    is_expired: bool = ...
    is_image: bool = ...
    access_count: int = Field(description='Number of times the file was acc...')
    expires_at: datetime.datetime | None = Field(
    None,
    description='When the file expires (null = ne...',
)
    url: Any = ...
    created_at: datetime.datetime = ...



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



class CDNFileUploadRequest(BaseModel):
    """
    Serializer for file upload request. Supports two modes: - file: Direct file
    upload - url: Server downloads from URL

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

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

    file: Any | None = None
    url: str | None = Field(None, description='URL to download file from (alter...', min_length=1)
    filename: str | None = Field(
    None,
    description='Filename (optional, extracted fr...',
    min_length=1,
)
    ttl: str | None = Field(None, description='TTL (e.g., 30d, 7d, 24h, 0=forev...', min_length=1)
    is_public: bool | None = None
    metadata: dict[str, Any] | None = None



class CDNFileUploadResponse(BaseModel):
    """
    Serializer for upload response. Returns full file data for immediate
    uploads. For async URL downloads, use CDNUploadAsyncResponseSerializer.

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

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

    id: str = ...
    uuid: str = Field(description='Unique file identifier for URLs')
    filename: Any = Field(description='Original filename')
    content_type: Any = Field(description='MIME type of the file')
    size_bytes: int = Field(description='File size in bytes')
    is_public: bool = Field(description='Whether file is publicly accessible')
    is_expired: bool = ...
    is_image: bool = ...
    access_count: int = Field(description='Number of times the file was acc...')
    expires_at: datetime.datetime | None = Field(
    None,
    description='When the file expires (null = ne...',
)
    url: Any = ...
    created_at: datetime.datetime = ...
    checksum_sha256: str = Field(description='SHA256 checksum for deduplication', max_length=64)
    storage_backend: str | None = Field(
    None,
    description='Storage backend (local, s3, etc.)',
    max_length=50,
)
    last_accessed_at: datetime.datetime | None = Field(
    None,
    description='Last time the file was accessed',
)
    metadata: dict[str, Any] | None = Field(None, description='Additional file metadata')
    updated_at: datetime.datetime = ...



class CDNUploadAsyncResponse(BaseModel):
    """
    Serializer for async upload response (URL download via RQ). Used when file
    download is queued for background processing.

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

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

    status: str = Field(description='Job status (processing)')
    job_id: str = Field(description='Background job ID for status pol...')
    message: str = Field(description='Human-readable status message')



class CDNFileDetail(BaseModel):
    """
    Serializer for CDN file details.

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

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

    id: str = ...
    uuid: str = Field(description='Unique file identifier for URLs')
    filename: Any = Field(description='Original filename')
    content_type: Any = Field(description='MIME type of the file')
    size_bytes: int = Field(description='File size in bytes')
    is_public: bool = Field(description='Whether file is publicly accessible')
    is_expired: bool = ...
    is_image: bool = ...
    access_count: int = Field(description='Number of times the file was acc...')
    expires_at: datetime.datetime | None = Field(
    None,
    description='When the file expires (null = ne...',
)
    url: Any = ...
    created_at: datetime.datetime = ...
    checksum_sha256: str = Field(description='SHA256 checksum for deduplication', max_length=64)
    storage_backend: str | None = Field(
    None,
    description='Storage backend (local, s3, etc.)',
    max_length=50,
)
    last_accessed_at: datetime.datetime | None = Field(
    None,
    description='Last time the file was accessed',
)
    metadata: dict[str, Any] | None = Field(None, description='Additional file metadata')
    updated_at: datetime.datetime = ...



class CDNJobStatus(BaseModel):
    """
    Serializer for job status response.

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

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

    job_id: str = Field(description='Background job ID')
    status: CDNJobStatusStatus = Field(description='Job status  * `queued` - queued ...')
    result: CDNFileUploadResponse | None = None
    error: str | None = None



class CDNStats(BaseModel):
    """
    Serializer for CDN storage statistics.

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

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

    total_files: int = Field(description='Total number of files')
    total_size_bytes: int = Field(description='Total size in bytes')
    total_access_count: int = Field(description='Total access count')



