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

from __future__ import annotations
from .v3_workflows_actionrequest import (
    V3WorkflowsActionRequest,
    V3WorkflowsActionRequestTypedDict,
)
from .v3_workflows_createworkflowfilter import (
    V3WorkflowsCreateWorkflowFilter,
    V3WorkflowsCreateWorkflowFilterTypedDict,
)
from .v3_workflows_entityownerupdate import (
    V3WorkflowsEntityOwnerUpdate,
    V3WorkflowsEntityOwnerUpdateTypedDict,
)
from .v3_workflows_tag import V3WorkflowsTag, V3WorkflowsTagTypedDict
from .v3_workflows_workflowtrigger import V3WorkflowsWorkflowTrigger
from pydantic import model_serializer
from squadcast.types import BaseModel, UNSET_SENTINEL
from typing import List, Literal, Optional
from typing_extensions import NotRequired, TypedDict


V3WorkflowsCreateWorkflowRequestUpdateOwnerType = Literal[
    "user",
    "squad",
]


class V3WorkflowsCreateWorkflowRequestUpdateTypedDict(TypedDict):
    title: NotRequired[str]
    description: NotRequired[str]
    owner_id: NotRequired[str]
    owner_type: NotRequired[V3WorkflowsCreateWorkflowRequestUpdateOwnerType]
    entity_owner: NotRequired[V3WorkflowsEntityOwnerUpdateTypedDict]
    tags: NotRequired[List[V3WorkflowsTagTypedDict]]
    trigger: NotRequired[V3WorkflowsWorkflowTrigger]
    filters: NotRequired[V3WorkflowsCreateWorkflowFilterTypedDict]
    actions: NotRequired[List[V3WorkflowsActionRequestTypedDict]]
    enabled: NotRequired[bool]


class V3WorkflowsCreateWorkflowRequestUpdate(BaseModel):
    title: Optional[str] = None

    description: Optional[str] = None

    owner_id: Optional[str] = None

    owner_type: Optional[V3WorkflowsCreateWorkflowRequestUpdateOwnerType] = None

    entity_owner: Optional[V3WorkflowsEntityOwnerUpdate] = None

    tags: Optional[List[V3WorkflowsTag]] = None

    trigger: Optional[V3WorkflowsWorkflowTrigger] = None

    filters: Optional[V3WorkflowsCreateWorkflowFilter] = None

    actions: Optional[List[V3WorkflowsActionRequest]] = None

    enabled: Optional[bool] = None

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