# Auto-generated by DjangoCFG - see CLAUDE.md
from __future__ import annotations

from datetime import datetime
from typing import Any

from pydantic import BaseModel, ConfigDict, Field

from ..enums import ImageGenerateRequestRequestQuality, ImageGenerateRequestRequestStyle, ImageGenerateResponseStatus


class ImageGenerationList(BaseModel):
    """
    Serializer for listing generations.

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

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

    id: Any = ...
    prompt: str = Field(description='Text prompt for image generation')
    model: str = Field(description="Model ID used for generation (e.g., 'google/gemini-2.5-flash-image')", max_length=100)
    model_alias: str | None = Field(None, description="Original model alias if used (e.g., '@cheap')", max_length=50)
    provider: str = Field(description="Provider used (e.g., 'openrouter')", max_length=50)
    status: ImageGenerateResponseStatus | None = Field(None, description='Generation status\n\n* `pending` - Pending\n* `queued` - Queued\n* `processing` - Processing\n* `completed` - Completed\n* `failed` - Failed\n* `cancelled` - Cancelled')
    image_cdn_url: Any | None = None
    cost_usd: str | None = Field(None, description='Generation cost in USD', pattern='^-?\\d{0,4}(?:\\.\\d{0,6})?$')
    duration_ms: int | None = Field(None, description='Generation duration in milliseconds', ge=0, le=2147483647)
    created_at: Any = ...



class ImageGenerationDetail(BaseModel):
    """
    Serializer for generation detail.

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

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

    id: Any = ...
    prompt: str = Field(description='Text prompt for image generation')
    negative_prompt: str | None = Field(None, description='What to avoid in generation')
    model: str = Field(description="Model ID used for generation (e.g., 'google/gemini-2.5-flash-image')", max_length=100)
    model_alias: str | None = Field(None, description="Original model alias if used (e.g., '@cheap')", max_length=50)
    provider: str = Field(description="Provider used (e.g., 'openrouter')", max_length=50)
    size: str | None = Field(None, description="Image size (e.g., '1024x1024')", max_length=20)
    quality: ImageGenerateRequestRequestQuality | None = Field(None, description='Image quality\n\n* `standard` - Standard\n* `hd` - HD')
    style: ImageGenerateRequestRequestStyle | None = Field(None, description='Image style\n\n* `natural` - Natural\n* `vivid` - Vivid')
    status: ImageGenerateResponseStatus | None = Field(None, description='Generation status\n\n* `pending` - Pending\n* `queued` - Queued\n* `processing` - Processing\n* `completed` - Completed\n* `failed` - Failed\n* `cancelled` - Cancelled')
    image_cdn_url: Any | None = None
    image_url: str | None = Field(None, description='Original image URL from provider (for history)', max_length=2048)
    revised_prompt: str | None = Field(None, description='Revised prompt from the model (if modified)')
    cost_usd: str | None = Field(None, description='Generation cost in USD', pattern='^-?\\d{0,4}(?:\\.\\d{0,6})?$')
    duration_ms: int | None = Field(None, description='Generation duration in milliseconds', ge=0, le=2147483647)
    prompt_hash: str | None = Field(None, description='Hash of prompt for duplicate detection', max_length=64)
    error: str | None = Field(None, description='Error message if generation failed')
    error_type: str | None = Field(None, description='Error type/class name', max_length=100)
    metadata: dict[str, Any] | None = Field(None, description='Additional metadata')
    created_at: Any = ...
    updated_at: Any = ...



class JobStatus(BaseModel):
    """
    Job status response.

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

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

    id: str = Field(description='Generation ID')
    status: ImageGenerateResponseStatus = Field(description='* `pending` - Pending\n* `queued` - Queued\n* `processing` - Processing\n* `completed` - Completed\n* `failed` - Failed\n* `cancelled` - Cancelled')
    job_status: str = Field(description='RQ job status')
    image_cdn_url: str | None = Field(None, description='CDN URL for generated image (if completed)')
    error: str | None = Field(None, description='Error message if failed')



class ImageGenerateRequestRequest(BaseModel):
    """
    Request serializer for image generation.

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

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

    prompt: str = Field(description='Text prompt for image generation', min_length=1, max_length=4000)
    negative_prompt: str | None = Field(None, description='What to avoid in generation', min_length=1, max_length=1000)
    model: str | None = Field(None, description='Model ID or alias (@cheap, @balanced, @smart, @fast)', min_length=1, max_length=100)
    size: str | None = Field(None, description="Image size (e.g., '1024x1024', '1792x1024')", min_length=1, max_length=20)
    quality: ImageGenerateRequestRequestQuality | None = Field(None, description='Image quality\n\n* `standard` - Standard\n* `hd` - HD')
    style: ImageGenerateRequestRequestStyle | None = Field(None, description='Image style\n\n* `natural` - Natural\n* `vivid` - Vivid')



class ImageGenerateResponse(BaseModel):
    """
    Response serializer for image generation.

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

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

    id: str = Field(description='Generation ID')
    prompt: str = Field(description='Original prompt')
    model: str = Field(description='Model used')
    model_alias: str = Field(description='Original alias if used')
    provider: str = Field(description='Provider used')
    status: ImageGenerateResponseStatus = Field(description='* `pending` - Pending\n* `queued` - Queued\n* `processing` - Processing\n* `completed` - Completed\n* `failed` - Failed\n* `cancelled` - Cancelled')
    image_cdn_url: str | None = Field(None, description='CDN URL for generated image')
    image_url: str = Field(description='Original provider URL (for history)')
    cost_usd: str = Field(description='Generation cost in USD', pattern='^-?\\d{0,4}(?:\\.\\d{0,6})?$')
    duration_ms: int = Field(description='Duration in milliseconds')
    error: str = Field(description='Error message if failed')
    created_at: str = ...



class AsyncGenerateResponse(BaseModel):
    """
    Response for async generation request.

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

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

    id: str = Field(description='Generation ID')
    job_id: str = Field(description='RQ Job ID for status tracking')
    status: str = Field(description='Initial status (processing)')



class ChoiceItem(BaseModel):
    """
    Single choice item.

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

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

    value: str = Field(description='Choice value')
    label: str = Field(description='Human-readable label')



class ImageGenOptions(BaseModel):
    """
    Available options for image generation.

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

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

    quality: list[ChoiceItem] = Field(description='Available quality options')
    style: list[ChoiceItem] = Field(description='Available style options')
    model_aliases: list[str] = Field(description='Available model aliases (@cheap, @balanced, etc.)')
    default_model: str = Field(description='Default model alias')



