# 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 .tool_call_output_processed_payload_tool import ToolCallOutputProcessedPayloadTool


class ToolCallOutputProcessedPayload(UniversalBaseModel):
    type: typing.Literal["tool_call_output_processed"] = "tool_call_output_processed"
    tool_call_id: str = pydantic.Field()
    """
    ID of the completed tool call
    """

    tool: ToolCallOutputProcessedPayloadTool
    endpoint_url: typing.Optional[str] = pydantic.Field(default=None)
    """
    Webhook endpoint URL (null for WebSocket tools)
    """

    endpoint_timeout_ms: typing.Optional[float] = pydantic.Field(default=None)
    """
    Webhook timeout in milliseconds (null for WebSocket tools)
    """

    endpoint_called_at: typing.Optional[dt.datetime] = pydantic.Field(default=None)
    """
    When webhook was called (null for WebSocket tools)
    """

    request_body: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    Webhook request body (null for WebSocket tools)
    """

    response_body: typing.Optional[typing.Optional[typing.Any]] = None
    parameters: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    WebSocket tool parameters (null for webhook tools)
    """

    output: typing.Optional[typing.Optional[typing.Any]] = None
    response_status_code: typing.Optional[float] = pydantic.Field(default=None)
    """
    Webhook HTTP status code (null for WebSocket tools)
    """

    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 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
