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

from __future__ import annotations

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, update_forward_refs
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel
from .edit_run_config import EditRunConfig
from .edit_run_edited_file import EditRunEditedFile
from .edit_run_metrics import EditRunMetrics
from .edit_run_status import EditRunStatus
from .edit_run_usage import EditRunUsage


class EditRun(UncheckedBaseModel):
    """
    Full edit run object with complete editing results
    """

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

    id: str = pydantic.Field()
    """
    A unique identifier for the edit run. Will always start with `"edit_run_"`
    
    Example: `"edit_run_xK9mLPqRtN3vS8wF5hB2cQ"`
    """

    file_id: typing_extensions.Annotated[str, FieldMetadata(alias="fileId")] = pydantic.Field(alias="fileId")
    """
    The identifier of the input file that was edited.
    """

    edited_file: typing_extensions.Annotated[typing.Optional[EditRunEditedFile], FieldMetadata(alias="editedFile")] = (
        pydantic.Field(alias="editedFile", default=None)
    )
    """
    Information about the edited output file. Only present when status is "PROCESSED".
    """

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

    config: EditRunConfig = pydantic.Field()
    """
    The configuration used for this edit run.
    """

    output: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    The extracted/detected field values from the edited document.
    """

    metrics: EditRunMetrics = pydantic.Field()
    """
    Metrics about the editing process.
    """

    usage: typing.Optional[EditRunUsage] = pydantic.Field(default=None)
    """
    Usage credits consumed by this edit run.
    """

    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


update_forward_refs(EditRun)
