# 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 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: str = ...
    prompt: str = Field(description='Text prompt for image generation')
    model: str = Field(description='Model ID used for generation (e....', max_length=100)
    model_alias: str | None = Field(
    None,
    description='Original model alias if used (e....',
    max_length=50,
)
    provider: str = Field(description="Provider used (e.g., 'openrouter')", max_length=50)
    status: ImageGenerateResponseStatus | None = Field(
    None,
    description='Generation status  * `pending` -...',
)
    image_cdn_url: Any | None = None
    cost_usd: Any | 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: datetime.datetime = ...



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

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

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

    id: str = ...
    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....', max_length=100)
    model_alias: str | None = Field(
    None,
    description='Original model alias if used (e....',
    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  * `standard` - St...',
)
    style: ImageGenerateRequestRequestStyle | None = Field(
    None,
    description='Image style  * `natural` - Natur...',
)
    status: ImageGenerateResponseStatus | None = Field(
    None,
    description='Generation status  * `pending` -...',
)
    image_cdn_url: Any | None = None
    image_url: str | None = Field(
    None,
    description='Original image URL from provider...',
    max_length=2048,
)
    revised_prompt: str | None = Field(None, description='Revised prompt from the model (i...')
    cost_usd: Any | 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 det...',
    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: datetime.datetime = ...
    updated_at: datetime.datetime = ...



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 * `queued`...')
    job_status: str = Field(description='RQ job status')
    image_cdn_url: str | None = Field(None, description='CDN URL for generated image (if ...')
    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, @bala...',
    min_length=1,
    max_length=100,
)
    size: str | None = Field(
    None,
    description="Image size (e.g., '1024x1024', '...",
    min_length=1,
    max_length=20,
)
    quality: ImageGenerateRequestRequestQuality | None = Field(
    None,
    description='Image quality  * `standard` - St...',
)
    style: ImageGenerateRequestRequestStyle | None = Field(
    None,
    description='Image style  * `natural` - Natur...',
)



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 * `queued`...')
    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: Any = 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: datetime.datetime = ...



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,...')
    default_model: str = Field(description='Default model alias')



