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

from __future__ import annotations
from .workflowtype import WorkflowType
from mistralai.client.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict


class WorkflowWithWorkerStatusTypedDict(TypedDict):
    id: str
    r"""Unique identifier of the workflow"""
    name: str
    r"""Name of the workflow"""
    display_name: str
    r"""Display name of the workflow"""
    type: WorkflowType
    customer_id: str
    r"""Customer ID of the workflow"""
    workspace_id: str
    r"""Workspace ID of the workflow"""
    active: bool
    r"""Whether the workflow is active"""
    description: NotRequired[Nullable[str]]
    r"""Description of the workflow"""
    shared_namespace: NotRequired[Nullable[str]]
    r"""Reserved namespace for shared workflows (e.g., 'shared:my-shared-workflow')"""
    available_in_chat_assistant: NotRequired[bool]
    r"""Whether the workflow is available in chat assistant"""
    is_technical: NotRequired[bool]
    r"""Whether the workflow is technical (e.g. SDK-managed)"""
    archived: NotRequired[bool]
    r"""Whether the workflow is archived"""


class WorkflowWithWorkerStatus(BaseModel):
    id: str
    r"""Unique identifier of the workflow"""

    name: str
    r"""Name of the workflow"""

    display_name: str
    r"""Display name of the workflow"""

    type: WorkflowType

    customer_id: str
    r"""Customer ID of the workflow"""

    workspace_id: str
    r"""Workspace ID of the workflow"""

    active: bool
    r"""Whether the workflow is active"""

    description: OptionalNullable[str] = UNSET
    r"""Description of the workflow"""

    shared_namespace: OptionalNullable[str] = UNSET
    r"""Reserved namespace for shared workflows (e.g., 'shared:my-shared-workflow')"""

    available_in_chat_assistant: Optional[bool] = False
    r"""Whether the workflow is available in chat assistant"""

    is_technical: Optional[bool] = False
    r"""Whether the workflow is technical (e.g. SDK-managed)"""

    archived: Optional[bool] = False
    r"""Whether the workflow is archived"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "description",
                "shared_namespace",
                "available_in_chat_assistant",
                "is_technical",
                "archived",
            ]
        )
        nullable_fields = set(["description", "shared_namespace"])
        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))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

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

        return m
