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

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


class ToolAnnotationsTypedDict(TypedDict):
    r"""Additional properties describing a Tool to clients.

    NOTE: all properties in ToolAnnotations are **hints**.
    They are not guaranteed to provide a faithful description of
    tool behavior (including descriptive properties like `title`).

    Clients should never make tool use decisions based on ToolAnnotations
    received from untrusted servers.
    """

    title: NotRequired[Nullable[str]]
    read_only_hint: NotRequired[Nullable[bool]]
    destructive_hint: NotRequired[Nullable[bool]]
    idempotent_hint: NotRequired[Nullable[bool]]
    open_world_hint: NotRequired[Nullable[bool]]


class ToolAnnotations(BaseModel):
    r"""Additional properties describing a Tool to clients.

    NOTE: all properties in ToolAnnotations are **hints**.
    They are not guaranteed to provide a faithful description of
    tool behavior (including descriptive properties like `title`).

    Clients should never make tool use decisions based on ToolAnnotations
    received from untrusted servers.
    """

    model_config = ConfigDict(
        populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
    )
    __pydantic_extra__: Dict[str, Any] = pydantic.Field(init=False)

    title: OptionalNullable[str] = UNSET

    read_only_hint: Annotated[
        OptionalNullable[bool], pydantic.Field(alias="readOnlyHint")
    ] = UNSET

    destructive_hint: Annotated[
        OptionalNullable[bool], pydantic.Field(alias="destructiveHint")
    ] = UNSET

    idempotent_hint: Annotated[
        OptionalNullable[bool], pydantic.Field(alias="idempotentHint")
    ] = UNSET

    open_world_hint: Annotated[
        OptionalNullable[bool], pydantic.Field(alias="openWorldHint")
    ] = UNSET

    @property
    def additional_properties(self):
        return self.__pydantic_extra__

    @additional_properties.setter
    def additional_properties(self, value):
        self.__pydantic_extra__ = value  # pyright: ignore[reportIncompatibleVariableOverride]

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "title",
                "readOnlyHint",
                "destructiveHint",
                "idempotentHint",
                "openWorldHint",
            ]
        )
        nullable_fields = set(
            [
                "title",
                "readOnlyHint",
                "destructiveHint",
                "idempotentHint",
                "openWorldHint",
            ]
        )
        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))
            serialized.pop(k, serialized.pop(n, None))
            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
        for k, v in serialized.items():
            m[k] = v

        return m


try:
    ToolAnnotations.model_rebuild()
except NameError:
    pass
