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

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


class UpdateConnectorRequestTypedDict(TypedDict):
    name: NotRequired[Nullable[str]]
    r"""The name of the connector."""
    description: NotRequired[Nullable[str]]
    r"""The description of the connector."""
    icon_url: NotRequired[Nullable[str]]
    r"""The optional url of the icon you want to associate to the connector."""
    system_prompt: NotRequired[Nullable[str]]
    r"""Optional system prompt for the connector."""
    connection_config: NotRequired[Nullable[Dict[str, Any]]]
    r"""Optional new connection config."""
    connection_secrets: NotRequired[Nullable[Dict[str, Any]]]
    r"""Optional new connection secrets"""
    server: NotRequired[Nullable[str]]
    r"""New server url for your mcp connector."""
    headers: NotRequired[Nullable[Dict[str, Any]]]
    r"""New headers for your mcp connector."""
    auth_data: NotRequired[Nullable[AuthDataTypedDict]]
    r"""New authentication data for your mcp connector."""


class UpdateConnectorRequest(BaseModel):
    name: OptionalNullable[str] = UNSET
    r"""The name of the connector."""

    description: OptionalNullable[str] = UNSET
    r"""The description of the connector."""

    icon_url: OptionalNullable[str] = UNSET
    r"""The optional url of the icon you want to associate to the connector."""

    system_prompt: OptionalNullable[str] = UNSET
    r"""Optional system prompt for the connector."""

    connection_config: OptionalNullable[Dict[str, Any]] = UNSET
    r"""Optional new connection config."""

    connection_secrets: OptionalNullable[Dict[str, Any]] = UNSET
    r"""Optional new connection secrets"""

    server: OptionalNullable[str] = UNSET
    r"""New server url for your mcp connector."""

    headers: OptionalNullable[Dict[str, Any]] = UNSET
    r"""New headers for your mcp connector."""

    auth_data: OptionalNullable[AuthData] = UNSET
    r"""New authentication data for your mcp connector."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "name",
                "description",
                "icon_url",
                "system_prompt",
                "connection_config",
                "connection_secrets",
                "server",
                "headers",
                "auth_data",
            ]
        )
        nullable_fields = set(
            [
                "name",
                "description",
                "icon_url",
                "system_prompt",
                "connection_config",
                "connection_secrets",
                "server",
                "headers",
                "auth_data",
            ]
        )
        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
