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

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


class CreateConnectorRequestTypedDict(TypedDict):
    name: str
    r"""The name of the connector. Should be 64 char length maximum, alphanumeric, only underscores/dashes."""
    description: str
    r"""The description of the connector."""
    server: str
    r"""The url of the MCP server."""
    icon_url: NotRequired[Nullable[str]]
    r"""The optional url of the icon you want to associate to the connector."""
    visibility: NotRequired[ResourceVisibility]
    headers: NotRequired[Nullable[Dict[str, Any]]]
    r"""Optional organization-level headers to be sent with the request to the mcp server."""
    auth_data: NotRequired[Nullable[AuthDataTypedDict]]
    r"""Optional additional authentication data for the connector."""
    system_prompt: NotRequired[Nullable[str]]
    r"""Optional system prompt for the connector."""


class CreateConnectorRequest(BaseModel):
    name: str
    r"""The name of the connector. Should be 64 char length maximum, alphanumeric, only underscores/dashes."""

    description: str
    r"""The description of the connector."""

    server: str
    r"""The url of the MCP server."""

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

    visibility: Optional[ResourceVisibility] = None

    headers: OptionalNullable[Dict[str, Any]] = UNSET
    r"""Optional organization-level headers to be sent with the request to the mcp server."""

    auth_data: OptionalNullable[AuthData] = UNSET
    r"""Optional additional authentication data for the connector."""

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

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