"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from flexprice.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class DTOWorkflowExecutionDTOTypedDict(TypedDict):
    close_time: NotRequired[str]
    created_by: NotRequired[str]
    duration_ms: NotRequired[int]
    entity: NotRequired[str]
    r"""e.g. plan, invoice, subscription"""
    entity_id: NotRequired[str]
    r"""e.g. plan ID, invoice ID"""
    run_id: NotRequired[str]
    start_time: NotRequired[str]
    status: NotRequired[str]
    task_queue: NotRequired[str]
    total_duration: NotRequired[str]
    workflow_id: NotRequired[str]
    workflow_type: NotRequired[str]


class DTOWorkflowExecutionDTO(BaseModel):
    close_time: Optional[str] = None

    created_by: Optional[str] = None

    duration_ms: Optional[int] = None

    entity: Optional[str] = None
    r"""e.g. plan, invoice, subscription"""

    entity_id: Optional[str] = None
    r"""e.g. plan ID, invoice ID"""

    run_id: Optional[str] = None

    start_time: Optional[str] = None

    status: Optional[str] = None

    task_queue: Optional[str] = None

    total_duration: Optional[str] = None

    workflow_id: Optional[str] = None

    workflow_type: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "close_time",
                "created_by",
                "duration_ms",
                "entity",
                "entity_id",
                "run_id",
                "start_time",
                "status",
                "task_queue",
                "total_duration",
                "workflow_id",
                "workflow_type",
            ]
        )
        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
