# 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, UnionMetadata
from ...types.edit_run_config import EditRunConfig
from ...types.edit_run_edited_file import EditRunEditedFile
from ...types.edit_run_metrics import EditRunMetrics
from ...types.edit_run_status import EditRunStatus
from ...types.edit_run_status_status import EditRunStatusStatus
from ...types.edit_run_usage import EditRunUsage


class EditGetResponseEditRun_EditRunStatus(UncheckedBaseModel):
    object: typing.Literal["edit_run_status"] = "edit_run_status"
    id: str
    status: EditRunStatusStatus
    failure_reason: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="failureReason")] = (
        pydantic.Field(alias="failureReason", default=None)
    )

    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


class EditGetResponseEditRun_EditRun(UncheckedBaseModel):
    object: typing.Literal["edit_run"] = "edit_run"
    id: str
    file_id: typing_extensions.Annotated[str, FieldMetadata(alias="fileId")] = pydantic.Field(alias="fileId")
    edited_file: typing_extensions.Annotated[typing.Optional[EditRunEditedFile], FieldMetadata(alias="editedFile")] = (
        pydantic.Field(alias="editedFile", default=None)
    )
    status: EditRunStatus
    failure_reason: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="failureReason")] = (
        pydantic.Field(alias="failureReason", default=None)
    )
    config: EditRunConfig
    output: typing.Optional[typing.Dict[str, typing.Any]] = None
    metrics: EditRunMetrics
    usage: typing.Optional[EditRunUsage] = None

    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


EditGetResponseEditRun = typing_extensions.Annotated[
    typing.Union[EditGetResponseEditRun_EditRunStatus, EditGetResponseEditRun_EditRun],
    UnionMetadata(discriminant="object"),
]
update_forward_refs(EditGetResponseEditRun_EditRun)
