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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.tool_approval_response import ToolApprovalResponse
from .raw_client import AsyncRawToolApprovalClient, RawToolApprovalClient

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class ToolApprovalClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawToolApprovalClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawToolApprovalClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawToolApprovalClient
        """
        return self._raw_client

    def approve_tool_call(
        self,
        thread_id: str,
        *,
        tool_call_id: str,
        approved: bool,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ToolApprovalResponse:
        """
        Submit an approval or denial for a tool call that is waiting for user confirmation during a streaming response. The tool_call_id must match an active pending approval from a tool.approval_required stream event.

        Parameters
        ----------
        thread_id : str

        tool_call_id : str
            The tool_call_id from the tool.approval_required event

        approved : bool
            True to approve, False to deny

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ToolApprovalResponse
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.tool_approval.approve_tool_call(
            thread_id="thread_id",
            tool_call_id="tool_call_id",
            approved=True,
        )
        """
        _response = self._raw_client.approve_tool_call(
            thread_id, tool_call_id=tool_call_id, approved=approved, request_options=request_options
        )
        return _response.data


class AsyncToolApprovalClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawToolApprovalClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawToolApprovalClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawToolApprovalClient
        """
        return self._raw_client

    async def approve_tool_call(
        self,
        thread_id: str,
        *,
        tool_call_id: str,
        approved: bool,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ToolApprovalResponse:
        """
        Submit an approval or denial for a tool call that is waiting for user confirmation during a streaming response. The tool_call_id must match an active pending approval from a tool.approval_required stream event.

        Parameters
        ----------
        thread_id : str

        tool_call_id : str
            The tool_call_id from the tool.approval_required event

        approved : bool
            True to approve, False to deny

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        ToolApprovalResponse
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.tool_approval.approve_tool_call(
                thread_id="thread_id",
                tool_call_id="tool_call_id",
                approved=True,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.approve_tool_call(
            thread_id, tool_call_id=tool_call_id, approved=approved, request_options=request_options
        )
        return _response.data
