# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .batch_progress_response_status import BatchProgressResponseStatus


class BatchProgressResponse(UniversalBaseModel):
    version: str
    batch_id: str = pydantic.Field()
    """
    The batch identifier
    """

    progress: float = pydantic.Field()
    """
    Fraction of tasks completed (0.0 to 1.0). Value of 1.0 means all tasks have finished (success or failure).
    """

    tasks_count: int = pydantic.Field()
    """
    Total number of tasks in the batch
    """

    tasks_completed: int = pydantic.Field()
    """
    Number of tasks that completed successfully
    """

    tasks_failed: int = pydantic.Field()
    """
    Number of tasks that failed
    """

    status: BatchProgressResponseStatus = pydantic.Field()
    """
    `processing` while tasks are running; `completed` when all tasks have finished (regardless of individual success/failure)
    """

    results_url: typing.Optional[str] = pydantic.Field(default=None)
    """
    URL to fetch per-task results. Present only when `status` is `completed`.
    """

    error: typing.Optional[str] = pydantic.Field(default=None)
    """
    Error message when all tasks in the batch failed. Null otherwise.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
