# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, ConfigDict, Field

from ..enums import ScheduleRunStatus


class ScheduleRun(BaseModel):
    """
    Serializer for schedule run list.

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

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

    id: Any = ...
    schedule: Any = ...
    schedule_name: Any = ...
    status: ScheduleRunStatus = Field(description='* `pending` - Pending * `running...')
    scheduled_at: Any = Field(description='When it was supposed to run')
    started_at: Any | None = Field(None, description='When execution started')
    finished_at: Any | None = Field(None, description='When execution finished')
    duration_seconds: float = ...
    items_processed: int = Field(description='Items processed in this run')
    attempt: int = Field(description='Attempt number (1 = first try)')
    error_message: Any = Field(description='Error message if failed')
    created_at: Any = ...



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



class ScheduleRunDetail(BaseModel):
    """
    Serializer for schedule run detail.

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

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

    id: Any = ...
    schedule: Any = ...
    schedule_name: Any = ...
    service_id: Any = ...
    service_name: Any = ...
    status: ScheduleRunStatus = Field(description='* `pending` - Pending * `running...')
    scheduled_at: Any = Field(description='When it was supposed to run')
    started_at: Any | None = Field(None, description='When execution started')
    finished_at: Any | None = Field(None, description='When execution finished')
    duration_seconds: float = ...
    result: dict[str, Any] = Field(description='Execution result data')
    error_message: Any = Field(description='Error message if failed')
    items_processed: int = Field(description='Items processed in this run')
    attempt: int = Field(description='Attempt number (1 = first try)')
    created_at: Any = ...
    updated_at: Any = ...



