# 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.response import Response
from ..types.response_list import ResponseList
from .raw_client import AsyncRawBrowserTabsClient, RawBrowserTabsClient

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


class BrowserTabsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBrowserTabsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawBrowserTabsClient
        """
        return self._raw_client

    def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ResponseList:
        """
        List all open browser tabs.

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

        Returns
        -------
        ResponseList
            Successful Response

        Examples
        --------
        from agent_sandbox import Sandbox

        client = Sandbox(
            base_url="https://yourhost.com/path/to/api",
        )
        client.browser_tabs.list()
        """
        _response = self._raw_client.list(request_options=request_options)
        return _response.data

    def create(
        self, *, url: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None
    ) -> Response:
        """
        Create a new browser tab.

        Parameters
        ----------
        url : typing.Optional[str]

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

        Returns
        -------
        Response
            Successful Response

        Examples
        --------
        from agent_sandbox import Sandbox

        client = Sandbox(
            base_url="https://yourhost.com/path/to/api",
        )
        client.browser_tabs.create()
        """
        _response = self._raw_client.create(url=url, request_options=request_options)
        return _response.data

    def close(self, index: int, *, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Close a browser tab by index.

        Parameters
        ----------
        index : int

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

        Returns
        -------
        Response
            Successful Response

        Examples
        --------
        from agent_sandbox import Sandbox

        client = Sandbox(
            base_url="https://yourhost.com/path/to/api",
        )
        client.browser_tabs.close(
            index=1,
        )
        """
        _response = self._raw_client.close(index, request_options=request_options)
        return _response.data

    def activate(self, index: int, *, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Activate (bring to front) a browser tab by index.

        Parameters
        ----------
        index : int

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

        Returns
        -------
        Response
            Successful Response

        Examples
        --------
        from agent_sandbox import Sandbox

        client = Sandbox(
            base_url="https://yourhost.com/path/to/api",
        )
        client.browser_tabs.activate(
            index=1,
        )
        """
        _response = self._raw_client.activate(index, request_options=request_options)
        return _response.data


class AsyncBrowserTabsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBrowserTabsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawBrowserTabsClient
        """
        return self._raw_client

    async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ResponseList:
        """
        List all open browser tabs.

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

        Returns
        -------
        ResponseList
            Successful Response

        Examples
        --------
        import asyncio

        from agent_sandbox import AsyncSandbox

        client = AsyncSandbox(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.browser_tabs.list()


        asyncio.run(main())
        """
        _response = await self._raw_client.list(request_options=request_options)
        return _response.data

    async def create(
        self, *, url: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None
    ) -> Response:
        """
        Create a new browser tab.

        Parameters
        ----------
        url : typing.Optional[str]

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

        Returns
        -------
        Response
            Successful Response

        Examples
        --------
        import asyncio

        from agent_sandbox import AsyncSandbox

        client = AsyncSandbox(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.browser_tabs.create()


        asyncio.run(main())
        """
        _response = await self._raw_client.create(url=url, request_options=request_options)
        return _response.data

    async def close(self, index: int, *, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Close a browser tab by index.

        Parameters
        ----------
        index : int

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

        Returns
        -------
        Response
            Successful Response

        Examples
        --------
        import asyncio

        from agent_sandbox import AsyncSandbox

        client = AsyncSandbox(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.browser_tabs.close(
                index=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.close(index, request_options=request_options)
        return _response.data

    async def activate(self, index: int, *, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Activate (bring to front) a browser tab by index.

        Parameters
        ----------
        index : int

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

        Returns
        -------
        Response
            Successful Response

        Examples
        --------
        import asyncio

        from agent_sandbox import AsyncSandbox

        client = AsyncSandbox(
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.browser_tabs.activate(
                index=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.activate(index, request_options=request_options)
        return _response.data
