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

from __future__ import annotations
from .networkencodedinput import NetworkEncodedInput, NetworkEncodedInputTypedDict
from mistralai.client.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class WorkflowExecutionRequestTypedDict(TypedDict):
    execution_id: NotRequired[Nullable[str]]
    r"""Allows you to specify a custom execution ID. If not provided, a random ID will be generated."""
    input: NotRequired[Nullable[Any]]
    r"""The input to the workflow. This should be a dictionary or a BaseModel that matches the workflow's input schema."""
    encoded_input: NotRequired[Nullable[NetworkEncodedInputTypedDict]]
    r"""Encoded input to the workflow, used when payload encoding is enabled."""
    wait_for_result: NotRequired[bool]
    r"""If true, wait for the workflow to complete and return the result directly."""
    timeout_seconds: NotRequired[Nullable[float]]
    r"""Maximum time to wait for completion when wait_for_result is true."""
    custom_tracing_attributes: NotRequired[Nullable[Dict[str, str]]]
    extensions: NotRequired[Nullable[Dict[str, Any]]]
    r"""Plugin-specific data to propagate into WorkflowContext.extensions at execution time."""
    task_queue: NotRequired[Nullable[str]]
    r"""Deprecated. Use deployment_name instead."""
    deployment_name: NotRequired[Nullable[str]]
    r"""Name of the deployment to route this execution to"""


class WorkflowExecutionRequest(BaseModel):
    execution_id: OptionalNullable[str] = UNSET
    r"""Allows you to specify a custom execution ID. If not provided, a random ID will be generated."""

    input: OptionalNullable[Any] = UNSET
    r"""The input to the workflow. This should be a dictionary or a BaseModel that matches the workflow's input schema."""

    encoded_input: OptionalNullable[NetworkEncodedInput] = UNSET
    r"""Encoded input to the workflow, used when payload encoding is enabled."""

    wait_for_result: Optional[bool] = False
    r"""If true, wait for the workflow to complete and return the result directly."""

    timeout_seconds: OptionalNullable[float] = UNSET
    r"""Maximum time to wait for completion when wait_for_result is true."""

    custom_tracing_attributes: OptionalNullable[Dict[str, str]] = UNSET

    extensions: OptionalNullable[Dict[str, Any]] = UNSET
    r"""Plugin-specific data to propagate into WorkflowContext.extensions at execution time."""

    task_queue: Annotated[
        OptionalNullable[str],
        pydantic.Field(
            deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
        ),
    ] = UNSET
    r"""Deprecated. Use deployment_name instead."""

    deployment_name: OptionalNullable[str] = UNSET
    r"""Name of the deployment to route this execution to"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "execution_id",
                "input",
                "encoded_input",
                "wait_for_result",
                "timeout_seconds",
                "custom_tracing_attributes",
                "extensions",
                "task_queue",
                "deployment_name",
            ]
        )
        nullable_fields = set(
            [
                "execution_id",
                "input",
                "encoded_input",
                "timeout_seconds",
                "custom_tracing_attributes",
                "extensions",
                "task_queue",
                "deployment_name",
            ]
        )
        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
