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

import datetime as dt
import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .conversation_item_tool_calls_item_tool import ConversationItemToolCallsItemTool


class ConversationItemToolCallsItem(UniversalBaseModel):
    id: str = pydantic.Field()
    """
    The tool call ID.
    """

    tool: ConversationItemToolCallsItemTool
    endpoint_method: typing.Optional[str] = pydantic.Field(default=None)
    """
    HTTP method for webhook tool calls.
    """

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

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

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

    endpoint_called_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    When the webhook endpoint was called (null on error).
    """

    query_params: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    Query parameters for webhook tool calls (null on error or when no params).
    """

    response_status_code: typing.Optional[float] = pydantic.Field(default=None)
    """
    HTTP response status code for webhook tool calls (null on error).
    """

    tool_call_output_timeout_ms: typing.Optional[float] = pydantic.Field(default=None)
    """
    Timeout in milliseconds for websocket tool calls.
    """

    request_body: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    The request body sent to the tool.
    """

    response_body: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    The response body received from the tool.
    """

    timed_out: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether the tool call timed out.
    """

    error_message: typing.Optional[str] = pydantic.Field(default=None)
    """
    Error message if the tool call failed.
    """

    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
