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

from __future__ import annotations
from .workflowlistresponse import WorkflowListResponse, WorkflowListResponseTypedDict
from mistralai.client.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from mistralai.client.utils import FieldMetadata, QueryParamMetadata
from pydantic import model_serializer
from typing import Awaitable, Callable, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict


class GetWorkflowsV1WorkflowsGetRequestTypedDict(TypedDict):
    active_only: NotRequired[bool]
    r"""Whether to only return active workflows"""
    include_shared: NotRequired[bool]
    r"""Whether to include shared workflows"""
    available_in_chat_assistant: NotRequired[Nullable[bool]]
    r"""Whether to only return workflows available in chat assistant"""
    archived: NotRequired[Nullable[bool]]
    r"""Filter by archived state. False=exclude archived, True=only archived, None=include all"""
    cursor: NotRequired[Nullable[str]]
    r"""The cursor for pagination"""
    limit: NotRequired[int]
    r"""The maximum number of workflows to return"""


class GetWorkflowsV1WorkflowsGetRequest(BaseModel):
    active_only: Annotated[
        Optional[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = False
    r"""Whether to only return active workflows"""

    include_shared: Annotated[
        Optional[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = True
    r"""Whether to include shared workflows"""

    available_in_chat_assistant: Annotated[
        OptionalNullable[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = UNSET
    r"""Whether to only return workflows available in chat assistant"""

    archived: Annotated[
        OptionalNullable[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = UNSET
    r"""Filter by archived state. False=exclude archived, True=only archived, None=include all"""

    cursor: Annotated[
        OptionalNullable[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = UNSET
    r"""The cursor for pagination"""

    limit: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 50
    r"""The maximum number of workflows to return"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "active_only",
                "include_shared",
                "available_in_chat_assistant",
                "archived",
                "cursor",
                "limit",
            ]
        )
        nullable_fields = set(["available_in_chat_assistant", "archived", "cursor"])
        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


class GetWorkflowsV1WorkflowsGetResponseTypedDict(TypedDict):
    result: WorkflowListResponseTypedDict


class GetWorkflowsV1WorkflowsGetResponse(BaseModel):
    next: Union[
        Callable[[], Optional[GetWorkflowsV1WorkflowsGetResponse]],
        Callable[[], Awaitable[Optional[GetWorkflowsV1WorkflowsGetResponse]]],
    ]

    result: WorkflowListResponse
