# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
import datetime
from typing import Any

from pydantic import BaseModel, ConfigDict, Field


class ScheduledJob(BaseModel):
    """
    Serializer for scheduled job information.

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

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

    id: str = Field(description='Job ID')
    func: str = Field(description='Function path')
    args: list[dict[str, Any]] | None = Field(
    None,
    description='Function arguments (array of any...',
)
    kwargs: dict[str, Any] | None = Field(None, description='Function keyword arguments')
    queue_name: str = Field(description='Queue name')
    scheduled_time: datetime.datetime | None = Field(None, description='Next scheduled time')
    interval: int | None = Field(None, description='Repeat interval in seconds')
    cron: str | None = Field(None, description='Cron expression')
    timeout: int | None = Field(None, description='Job timeout in seconds')
    result_ttl: int | None = Field(None, description='Result TTL in seconds')
    repeat: int | None = Field(None, description='Times to repeat (None = infinite)')
    description: str | None = Field(None, description='Job description')
    created_at: datetime.datetime | None = Field(None, description='Job creation time')
    meta: dict[str, Any] | None = Field(None, description='Job metadata')



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



class ScheduleCreateRequest(BaseModel):
    """
    Serializer for creating a scheduled job. Supports three scheduling methods:
    1. scheduled_time: Schedule job at specific time 2. interval: Schedule job
    to repeat at intervals 3. cron: Schedule job with cron expression

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

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

    func: str = Field(description="Function path (e.g., 'myapp.task...", min_length=1)
    args: list[dict[str, Any]] | None = Field(
    None,
    description='Function arguments (array of any...',
)
    kwargs: dict[str, Any] | None = Field(None, description='Function keyword arguments')
    queue_name: str | None = Field(None, description='Queue name to schedule job in', min_length=1)
    scheduled_time: datetime.datetime | None = Field(
    None,
    description='Schedule job at specific time (I...',
)
    interval: int | None = Field(None, description='Schedule job to repeat every N s...', ge=1)
    cron: str | None = Field(None, description="Cron expression (e.g., '0 0 * * ...", min_length=1)
    timeout: int | None = Field(None, description='Job timeout in seconds')
    result_ttl: int | None = Field(None, description='Result TTL in seconds')
    repeat: int | None = Field(None, description='Number of times to repeat (None ...')
    description: str | None = Field(
    None,
    description='Job description',
    min_length=1,
    max_length=255,
)



class ScheduleActionResponse(BaseModel):
    """
    Response serializer for schedule actions (create/delete).

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

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

    success: bool = Field(description='Action success status')
    message: str = Field(description='Action result message')
    job_id: str | None = Field(None, description='Job ID (for create action)')
    action: str = Field(description='Action performed (create/delete/...')



