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

import datetime as dt
import typing

import typing_extensions
from ..core.serialization import FieldMetadata
from ..types.run_metadata import RunMetadata
from ..types.workflow_run_status import WorkflowRunStatus
from .file_summary import FileSummaryParams
from .run_usage import RunUsageParams
from .step_run import StepRunParams
from .workflow_summary import WorkflowSummaryParams
from .workflow_version_summary import WorkflowVersionSummaryParams


class WorkflowRunParams(typing_extensions.TypedDict):
    """
    Workflow run object.
    """

    object: typing.Literal["workflow_run"]
    """
    The type of object. In this case, it will always be `"workflow_run"`.
    """

    id: str
    """
    The ID of the workflow run.
    
    Example: `"workflow_run_xKm9pNv3qWsY_jL2tR5Dh"`
    """

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

    status: WorkflowRunStatus
    metadata: RunMetadata
    """
    The metadata that was passed in when running the Workflow.
    """

    batch_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="batchId")]
    """
    The batch ID of the WorkflowRun. If this WorkflowRun was created as part of a batch of files, all runs in that batch will have the same batch ID.
    
    Example: `"batch_7Ws31-F5"`
    """

    files: typing.Sequence[FileSummaryParams]
    failure_reason: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="failureReason")]
    """
    The reason why the workflow run failed. Will only be included if the workflow run status is "FAILED".
    """

    failure_message: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="failureMessage")]
    """
    A more detailed message about the failure. Will only be included if the workflow run status is "FAILED".
    """

    initial_run_at: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="initialRunAt")]
    """
    The time (in UTC) at which the workflow run was created. Will follow the RFC 3339 format. Will be null if the run hasn't started yet.
    
    Example: `"2025-04-28T17:01:39.285Z"`
    """

    reviewed_by_user: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="reviewedByUser")]
    """
    The email address 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: bool
    """
    Whether the workflow run has been reviewed.
    """

    rejection_note: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="rejectionNote")]
    """
    A note that is added if a workflow run is rejected.
    
    Example: `"Invalid invoice format"`
    """

    reviewed_at: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="reviewedAt")]
    """
    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"`
    """

    start_time: typing_extensions.Annotated[typing.Optional[dt.datetime], FieldMetadata(alias="startTime")]
    """
    The time (in UTC) at which the workflow run started executing. This will always be after the `initialRunAt` time. Will follow the RFC 3339 format. Will be null if the workflow run has not started executing.
    
    Example: `"2024-03-21T15:30:00Z"`
    """

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

    step_runs: typing_extensions.Annotated[typing.Sequence[StepRunParams], FieldMetadata(alias="stepRuns")]
    """
    An array of WorkflowStepRun objects. Each WorkflowStepRun represents a single run of a WorkflowStep and contains details about the step's execution and result.
    """

    usage: typing.Optional[RunUsageParams]
