"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
# @generated-id: 584e0a98082a

from __future__ import annotations
from .eventtype import EventType
from .workflowexecutiontracesummaryattributesvalues import (
    WorkflowExecutionTraceSummaryAttributesValues,
    WorkflowExecutionTraceSummaryAttributesValuesTypedDict,
)
from mistralai.client.types import BaseModel, Nullable, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict


class WorkflowExecutionTraceEventTypedDict(TypedDict):
    name: str
    r"""Name of the event"""
    id: str
    r"""The ID of the event"""
    timestamp_unix_nano: int
    r"""The timestamp of the event in nanoseconds since the Unix epoch"""
    attributes: Dict[
        str, Nullable[WorkflowExecutionTraceSummaryAttributesValuesTypedDict]
    ]
    r"""The attributes of the event"""
    type: NotRequired[EventType]
    internal: NotRequired[bool]
    r"""Whether the event is internal"""


class WorkflowExecutionTraceEvent(BaseModel):
    name: str
    r"""Name of the event"""

    id: str
    r"""The ID of the event"""

    timestamp_unix_nano: int
    r"""The timestamp of the event in nanoseconds since the Unix epoch"""

    attributes: Dict[str, Nullable[WorkflowExecutionTraceSummaryAttributesValues]]
    r"""The attributes of the event"""

    type: Optional[EventType] = None

    internal: Optional[bool] = False
    r"""Whether the event is internal"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["type", "internal"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m
