# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .tool_endpoint_method import ToolEndpointMethod
from .tool_execution_mode import ToolExecutionMode
from .tool_parameter import ToolParameter
from .tool_project import ToolProject
from .tool_type import ToolType


class Tool(UniversalBaseModel):
    id: str = pydantic.Field()
    """
    The ID of the tool.
    """

    name: str = pydantic.Field()
    """
    The name of the tool.
    """

    description: str = pydantic.Field()
    """
    Description of what the tool does.
    """

    project: ToolProject
    type: ToolType = pydantic.Field()
    """
    The type of tool.
    """

    execution_mode: ToolExecutionMode = pydantic.Field()
    """
    Mode of operation - sync waits for response, async continues without waiting.
    """

    parameters: typing.List[ToolParameter] = pydantic.Field()
    """
    Array of parameter definitions for the tool.
    """

    endpoint_method: typing.Optional[ToolEndpointMethod] = pydantic.Field(default=None)
    """
    HTTP method for webhook tools.
    """

    endpoint_url: typing.Optional[str] = pydantic.Field(default=None)
    """
    URL for webhook tools.
    """

    endpoint_headers: typing.Optional[typing.Dict[str, str]] = pydantic.Field(default=None)
    """
    Headers for webhook tools.
    """

    endpoint_timeout_ms: typing.Optional[int] = pydantic.Field(default=None)
    """
    Timeout in milliseconds for webhook tools.
    """

    tool_call_output_timeout_ms: typing.Optional[int] = pydantic.Field(default=None)
    """
    Timeout in milliseconds for WebSocket tool responses.
    """

    phone_number: typing.Optional[str] = pydantic.Field(default=None)
    """
    The E.164 formatted phone number to transfer calls to. Required for built_in_transfer_to_phone_number tools.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
