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

from __future__ import annotations
from ..core.pydantic_utilities import UniversalBaseModel
import typing
from .event_version import EventVersion
from .block_run_completed_environment import BlockRunCompletedEnvironment
from .block_run_completed_data import BlockRunCompletedData
from ..core.pydantic_utilities import IS_PYDANTIC_V2
import pydantic
from .block_run_failed_environment import BlockRunFailedEnvironment
from .block_run_failed_data import BlockRunFailedData
from .block_run_started_environment import BlockRunStartedEnvironment
from .block_run_started_data import BlockRunStartedData
from .workflow_run_completed_environment import WorkflowRunCompletedEnvironment
from .app_run_completed_data import AppRunCompletedData
from .workflow_run_failed_environment import WorkflowRunFailedEnvironment
from .app_run_failed_data import AppRunFailedData
from .workflow_run_started_environment import WorkflowRunStartedEnvironment
from .app_run_started_data import AppRunStartedData


class WorkflowRunEventData_BlockRunCompleted(UniversalBaseModel):
    name: typing.Literal["block_run_completed"] = "block_run_completed"
    organization_id: str
    id: typing.Optional[str] = None
    correlation_id: typing.Optional[str] = None
    version: typing.Optional[EventVersion] = None
    environment: BlockRunCompletedEnvironment
    timestamp: typing.Optional[str] = None
    data: BlockRunCompletedData

    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 WorkflowRunEventData_BlockRunFailed(UniversalBaseModel):
    name: typing.Literal["block_run_failed"] = "block_run_failed"
    organization_id: str
    id: typing.Optional[str] = None
    correlation_id: typing.Optional[str] = None
    version: typing.Optional[EventVersion] = None
    environment: BlockRunFailedEnvironment
    timestamp: typing.Optional[str] = None
    data: BlockRunFailedData

    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 WorkflowRunEventData_BlockRunStarted(UniversalBaseModel):
    name: typing.Literal["block_run_started"] = "block_run_started"
    organization_id: str
    id: typing.Optional[str] = None
    correlation_id: typing.Optional[str] = None
    version: typing.Optional[EventVersion] = None
    environment: BlockRunStartedEnvironment
    timestamp: typing.Optional[str] = None
    data: BlockRunStartedData

    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 WorkflowRunEventData_WorkflowRunCompleted(UniversalBaseModel):
    name: typing.Literal["workflow_run_completed"] = "workflow_run_completed"
    organization_id: str
    id: typing.Optional[str] = None
    correlation_id: typing.Optional[str] = None
    version: typing.Optional[EventVersion] = None
    environment: WorkflowRunCompletedEnvironment
    timestamp: typing.Optional[str] = None
    data: AppRunCompletedData

    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 WorkflowRunEventData_WorkflowRunFailed(UniversalBaseModel):
    name: typing.Literal["workflow_run_failed"] = "workflow_run_failed"
    organization_id: str
    id: typing.Optional[str] = None
    correlation_id: typing.Optional[str] = None
    version: typing.Optional[EventVersion] = None
    environment: WorkflowRunFailedEnvironment
    timestamp: typing.Optional[str] = None
    data: AppRunFailedData

    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 WorkflowRunEventData_WorkflowRunStarted(UniversalBaseModel):
    name: typing.Literal["workflow_run_started"] = "workflow_run_started"
    organization_id: str
    id: typing.Optional[str] = None
    correlation_id: typing.Optional[str] = None
    version: typing.Optional[EventVersion] = None
    environment: WorkflowRunStartedEnvironment
    timestamp: typing.Optional[str] = None
    data: AppRunStartedData

    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


WorkflowRunEventData = typing.Union[
    WorkflowRunEventData_BlockRunCompleted,
    WorkflowRunEventData_BlockRunFailed,
    WorkflowRunEventData_BlockRunStarted,
    WorkflowRunEventData_WorkflowRunCompleted,
    WorkflowRunEventData_WorkflowRunFailed,
    WorkflowRunEventData_WorkflowRunStarted,
]
