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

from __future__ import annotations
from ..core.unchecked_base_model import UncheckedBaseModel
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 .block_state_updated_environment import BlockStateUpdatedEnvironment
from .block_state_updated_data import BlockStateUpdatedData
from .workflow_run_completed_environment import WorkflowRunCompletedEnvironment
from .workflow_run_completed_data import WorkflowRunCompletedData
from .workflow_run_failed_environment import WorkflowRunFailedEnvironment
from .workflow_run_failed_data import WorkflowRunFailedData
from .workflow_run_started_environment import WorkflowRunStartedEnvironment
from .workflow_run_started_data import WorkflowRunStartedData
import typing_extensions
from ..core.unchecked_base_model import UnionMetadata


class WorkflowRunEventData_BlockRunCompleted(UncheckedBaseModel):
    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(UncheckedBaseModel):
    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(UncheckedBaseModel):
    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_BlockStateUpdated(UncheckedBaseModel):
    name: typing.Literal["block_state_updated"] = "block_state_updated"
    organization_id: str
    id: typing.Optional[str] = None
    correlation_id: typing.Optional[str] = None
    version: typing.Optional[EventVersion] = None
    environment: BlockStateUpdatedEnvironment
    timestamp: typing.Optional[str] = None
    data: BlockStateUpdatedData

    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(UncheckedBaseModel):
    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: WorkflowRunCompletedData

    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(UncheckedBaseModel):
    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: WorkflowRunFailedData

    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(UncheckedBaseModel):
    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: WorkflowRunStartedData

    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_extensions.Annotated[
    typing.Union[
        WorkflowRunEventData_BlockRunCompleted,
        WorkflowRunEventData_BlockRunFailed,
        WorkflowRunEventData_BlockRunStarted,
        WorkflowRunEventData_BlockStateUpdated,
        WorkflowRunEventData_WorkflowRunCompleted,
        WorkflowRunEventData_WorkflowRunFailed,
        WorkflowRunEventData_WorkflowRunStarted,
    ],
    UnionMetadata(discriminant="name"),
]
