# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations

from typing import Any

from pydantic import BaseModel, ConfigDict, Field

from ..enums import ProcessJobJobType, ProcessJobStatus


class ProcessJobDetail(BaseModel):
    """
    Serializer for ProcessJob detail view.

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

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

    id: Any = ...
    service: Any = Field(description='Service being operated on')
    service_name: Any = ...
    job_type: ProcessJobJobType = Field(description='Type of operation  * `start` - S...')
    status: ProcessJobStatus = Field(description='Current job status  * `pending` ...')
    rq_job_id: Any = Field(description='RQ job ID for tracking')
    queue_name: Any = Field(description='RQ queue name')
    initiated_by: int | None = Field(None, description='User who initiated the action')
    initiated_by_username: Any = ...
    created_at: Any = ...
    started_at: Any | None = Field(None, description='When job started executing')
    completed_at: Any | None = Field(None, description='When job completed')
    duration_seconds: float | None = Field(None, description='Calculate job duration in seconds.')
    result: dict[str, Any] | None = Field(None, description='Job result data')
    error_message: str | None = Field(None, description='Error message if failed')
    params: dict[str, Any] | None = Field(None, description='Job parameters')



class ProcessControlRequestRequest(BaseModel):
    """
    Serializer for process control requests (start/stop/restart).

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

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

    graceful: bool | None = Field(None, description='For stop/restart: use graceful s...')
    timeout: int | None = Field(
    None,
    description='Timeout in seconds for graceful ...',
    ge=5,
    le=300,
)
    params: dict[str, Any] | None = Field(None, description='Additional parameters for the op...')



class ProcessControlResponse(BaseModel):
    """
    Serializer for process control response.

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

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

    job_id: str = Field(description='ProcessJob UUID')
    status: str = Field(description='Job status (queued, running, etc.)')
    message: str | None = None



class CancelJobResponse(BaseModel):
    """
    Serializer for job cancellation response.

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

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

    job_id: str = Field(description='ProcessJob UUID')
    status: str = Field(description='Cancellation status')
    message: str | None = None



