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

from __future__ import annotations
from .v3_workflows_actionresponse import (
    V3WorkflowsActionResponse,
    V3WorkflowsActionResponseTypedDict,
)
from .v3_workflows_tag import V3WorkflowsTag, V3WorkflowsTagTypedDict
from .v3_workflows_workflowfilters import (
    V3WorkflowsWorkflowFilters,
    V3WorkflowsWorkflowFiltersTypedDict,
)
from pydantic import model_serializer
from squadcast.types import BaseModel, UNSET_SENTINEL
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict


class V3WorkflowsUpdateWorkflowAPIResponseTypedDict(TypedDict):
    id: NotRequired[int]
    owner_id: NotRequired[str]
    title: NotRequired[str]
    description: NotRequired[str]
    enabled: NotRequired[bool]
    trigger: NotRequired[str]
    filters: NotRequired[V3WorkflowsWorkflowFiltersTypedDict]
    tags: NotRequired[List[V3WorkflowsTagTypedDict]]
    actions: NotRequired[List[V3WorkflowsActionResponseTypedDict]]
    created_at: NotRequired[str]
    created_by: NotRequired[str]
    updated_at: NotRequired[str]
    updated_by: NotRequired[str]


class V3WorkflowsUpdateWorkflowAPIResponse(BaseModel):
    id: Optional[int] = None

    owner_id: Optional[str] = None

    title: Optional[str] = None

    description: Optional[str] = None

    enabled: Optional[bool] = None

    trigger: Optional[str] = None

    filters: Optional[V3WorkflowsWorkflowFilters] = None

    tags: Optional[List[V3WorkflowsTag]] = None

    actions: Optional[List[V3WorkflowsActionResponse]] = None

    created_at: Optional[str] = None

    created_by: Optional[str] = None

    updated_at: Optional[str] = None

    updated_by: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "id",
                "owner_id",
                "title",
                "description",
                "enabled",
                "trigger",
                "filters",
                "tags",
                "actions",
                "created_at",
                "created_by",
                "updated_at",
                "updated_by",
            ]
        )
        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
