# 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
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel
from .created_at import CreatedAt
from .run_usage import RunUsage
from .updated_at import UpdatedAt
from .workflow_run_status import WorkflowRunStatus
from .workflow_summary import WorkflowSummary
from .workflow_version_summary import WorkflowVersionSummary


class WorkflowRunSummary(UncheckedBaseModel):
    object: typing.Literal["workflow_run"] = pydantic.Field(default="workflow_run")
    """
    The type of object. In this case, it will always be `"workflow_run"`.
    """

    id: str = pydantic.Field()
    """
    The ID of the workflow run.
    
    Example: `"workflow_run_Zk9mNP12Qw4-yTv8BdR3H"`
    """

    status: WorkflowRunStatus
    workflow: WorkflowSummary
    workflow_version: typing_extensions.Annotated[WorkflowVersionSummary, FieldMetadata(alias="workflowVersion")] = (
        pydantic.Field(alias="workflowVersion")
    )
    dashboard_url: typing_extensions.Annotated[str, FieldMetadata(alias="dashboardUrl")] = pydantic.Field(
        alias="dashboardUrl"
    )
    """
    A URL to view this workflow run in the Extend dashboard.
    
    Example: `"https://dashboard.extend.ai/workflows/workflow_run_xKm9pNv3qWsY_jL2tR5Dh"`
    """

    reviewed_by_user: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="reviewedByUser")] = (
        pydantic.Field(alias="reviewedByUser", default=None)
    )
    """
    The user of the person who reviewed the workflow run. Will be null if the workflow run has not been reviewed.
    
    Example: `"jane.doe@example.com"`
    """

    reviewed_at: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="reviewedAt")] = (
        pydantic.Field(alias="reviewedAt", default=None)
    )
    """
    The time (in UTC) at which the workflow run was reviewed. Will follow the RFC 3339 format. Will be null if the workflow run has not been reviewed.
    
    Example: `"2024-03-21T16:45:00Z"`
    """

    initial_run_at: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="initialRunAt")] = (
        pydantic.Field(alias="initialRunAt", default=None)
    )
    """
    The time (in UTC) at which the workflow was initially created. Will follow the RFC 3339 format. Will be null if the run hasn't started yet.
    
    Example: `"2024-03-21T15:30:00Z"`
    """

    start_time: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="startTime")] = (
        pydantic.Field(alias="startTime", default=None)
    )
    """
    The start time (in UTC) that the workflow actually started executing. This occurs after the `initialRunAt` time. Will follow the RFC 3339 format. Will be null if not started.
    
    Example: `"2024-03-21T15:30:00Z"`
    """

    end_time: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="endTime")] = (
        pydantic.Field(alias="endTime", default=None)
    )
    """
    The end time (in UTC) that the workflow finished. Will follow the RFC 3339 format. Will be null if not finished.
    
    Example: `"2024-03-21T15:35:00Z"`
    """

    batch_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="batchId")] = pydantic.Field(
        alias="batchId", default=None
    )
    """
    The batch ID of the workflow run. If that workflow run was created from a batch of files, all runs in that batch will have the same batch ID.
    
    Example: `"batch_7Ws31-F5"`
    """

    rejection_note: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="rejectionNote")] = (
        pydantic.Field(alias="rejectionNote", default=None)
    )
    """
    The note that was added when the workflow run was rejected.
    
    Example: `"Invalid invoice format"`
    """

    created_at: typing_extensions.Annotated[CreatedAt, FieldMetadata(alias="createdAt")] = pydantic.Field(
        alias="createdAt"
    )
    updated_at: typing_extensions.Annotated[UpdatedAt, FieldMetadata(alias="updatedAt")] = pydantic.Field(
        alias="updatedAt"
    )
    usage: typing.Optional[RunUsage] = 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
