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

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel
from .parse_run_status_status import ParseRunStatusStatus


class ParseRunStatus(UncheckedBaseModel):
    """
    Minimal parse run status object sent in webhook notifications.
    Contains only the essential status information, without the full output data.
    """

    object: typing.Literal["parse_run_status"] = pydantic.Field(default="parse_run_status")
    """
    The type of object. Will always be `"parse_run_status"`.
    """

    id: str = pydantic.Field()
    """
    A unique identifier for the parse run.
    
    Example: `"pr_xK9mLPqRtN3vS8wF5hB2cQ"`
    """

    status: ParseRunStatusStatus = pydantic.Field()
    """
    The status of the parse run:
    * `"PROCESSING"` - The file is still being processed
    * `"PROCESSED"` - The file was successfully processed
    * `"FAILED"` - The processing failed (see `failureReason` for details)
    """

    failure_reason: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="failureReason")] = (
        pydantic.Field(alias="failureReason", default=None)
    )
    """
    The reason for failure.
    
    **Availability:** Present when `status` is `"FAILED"`.
    """

    failure_message: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="failureMessage")] = (
        pydantic.Field(alias="failureMessage", default=None)
    )
    """
    A human-readable description of the failure.
    
    **Availability:** Present when `status` is `"FAILED"`.
    """

    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
