# 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_parameter_item_type import ToolParameterItemType
from .tool_parameter_location import ToolParameterLocation
from .tool_parameter_type import ToolParameterType


class ToolParameter(UniversalBaseModel):
    type: ToolParameterType = pydantic.Field()
    """
    The parameter type.
    """

    item_type: typing.Optional[ToolParameterItemType] = pydantic.Field(default=None)
    """
    Required only when type is "array". The type of items in the array.
    """

    name: str = pydantic.Field()
    """
    The parameter name.
    """

    description: str = pydantic.Field()
    """
    Description of the parameter.
    """

    is_required: bool = pydantic.Field()
    """
    Whether the parameter is required.
    """

    location: typing.Optional[ToolParameterLocation] = pydantic.Field(default=None)
    """
    Only applicable for `custom_webhook` tools. Specifies where the parameter should be sent in the webhook request.
    - For GET webhooks: defaults to `"query_string"` and `"request_body"` is not allowed.
    - For POST webhooks: required, can be either `"request_body"` or `"query_string"`.
    - Not allowed for `custom_websocket` or `built_in_transfer_to_phone_number` tools.
    When updating a tool's type or endpoint_method, all parameters must include explicit `location` values.
    """

    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
