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

import datetime as dt
import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata
from .allocation import Allocation
from .google_protobuf_any import GoogleProtobufAny
from .task_error import TaskError
from .task_status_status import TaskStatusStatus


class TaskStatus(UniversalBaseModel):
    """
    TaskStatus is contains information regarding the status of a Task at any given time. Can include related information
      such as any progress towards Task completion, or any associated results if Task completed.
    """

    status: typing.Optional[TaskStatusStatus] = pydantic.Field(default=None)
    """
    Status of the Task.
    """

    task_error: typing_extensions.Annotated[typing.Optional[TaskError], FieldMetadata(alias="taskError")] = (
        pydantic.Field(default=None)
    )
    """
    Any errors associated with the Task.
    """

    progress: typing.Optional[GoogleProtobufAny] = pydantic.Field(default=None)
    """
    Any incremental progress on the Task, should be from the tasks/v* /progress folder.
    """

    result: typing.Optional[GoogleProtobufAny] = pydantic.Field(default=None)
    """
    Any final result of the Task, should be from tasks/v* /result folder.
    """

    start_time: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="startTime")] = (
        pydantic.Field(default=None)
    )
    """
    Time the Task began execution, may not be known even for executing Tasks.
    """

    estimate: typing.Optional[GoogleProtobufAny] = pydantic.Field(default=None)
    """
    Any estimate for how the Task will progress, should be from tasks/v* /estimates folder.
    """

    allocation: typing.Optional[Allocation] = pydantic.Field(default=None)
    """
    Any allocated agents of the Task.
    """

    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
