# 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 AsyncRawBrowserCookiesClient, RawBrowserCookiesClient

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


class BrowserCookiesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBrowserCookiesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawBrowserCookiesClient
        """
        return self._raw_client

    def get_cookies(
        self, *, urls: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> ResponseList:
        """
        Get browser cookies, optionally filtered by URLs (comma-separated).

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

        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_cookies.get_cookies(
            urls="urls",
        )
        """
        _response = self._raw_client.get_cookies(urls=urls, request_options=request_options)
        return _response.data

    def set_cookies(
        self,
        *,
        cookies: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Response:
        """
        Set browser cookies.

        Parameters
        ----------
        cookies : typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]

        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_cookies.set_cookies(
            cookies=[{"key": "value"}],
        )
        """
        _response = self._raw_client.set_cookies(cookies=cookies, request_options=request_options)
        return _response.data

    def clear_cookies(self, *, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Clear all browser cookies.

        Parameters
        ----------
        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_cookies.clear_cookies()
        """
        _response = self._raw_client.clear_cookies(request_options=request_options)
        return _response.data


class AsyncBrowserCookiesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBrowserCookiesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawBrowserCookiesClient
        """
        return self._raw_client

    async def get_cookies(
        self, *, urls: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> ResponseList:
        """
        Get browser cookies, optionally filtered by URLs (comma-separated).

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

        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_cookies.get_cookies(
                urls="urls",
            )


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

    async def set_cookies(
        self,
        *,
        cookies: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Response:
        """
        Set browser cookies.

        Parameters
        ----------
        cookies : typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]

        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_cookies.set_cookies(
                cookies=[{"key": "value"}],
            )


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

    async def clear_cookies(self, *, request_options: typing.Optional[RequestOptions] = None) -> Response:
        """
        Clear all browser cookies.

        Parameters
        ----------
        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_cookies.clear_cookies()


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