# 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.browser_profile import BrowserProfile
from .raw_client import AsyncRawBrowserProfilesClient, RawBrowserProfilesClient

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


class BrowserProfilesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBrowserProfilesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawBrowserProfilesClient
        """
        return self._raw_client

    def list_browser_profiles(
        self, *, include_deleted: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[BrowserProfile]:
        """
        Get all browser profiles for the organization

        Parameters
        ----------
        include_deleted : typing.Optional[bool]
            Include deleted browser profiles

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

        Returns
        -------
        typing.List[BrowserProfile]
            Successful Response

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.browser_profiles.list_browser_profiles(
            include_deleted=True,
        )
        """
        _response = self._raw_client.list_browser_profiles(
            include_deleted=include_deleted, request_options=request_options
        )
        return _response.data

    def create_browser_profile(
        self,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        browser_session_id: typing.Optional[str] = OMIT,
        workflow_run_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BrowserProfile:
        """
        Parameters
        ----------
        name : str
            Name for the browser profile

        description : typing.Optional[str]
            Optional profile description

        browser_session_id : typing.Optional[str]
            Persistent browser session to convert into a profile

        workflow_run_id : typing.Optional[str]
            Workflow run whose persisted session should be captured

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

        Returns
        -------
        BrowserProfile
            Successful Response

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.browser_profiles.create_browser_profile(
            name="name",
        )
        """
        _response = self._raw_client.create_browser_profile(
            name=name,
            description=description,
            browser_session_id=browser_session_id,
            workflow_run_id=workflow_run_id,
            request_options=request_options,
        )
        return _response.data

    def get_browser_profile(
        self, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> BrowserProfile:
        """
        Get a specific browser profile by ID

        Parameters
        ----------
        profile_id : str
            The ID of the browser profile. browser_profile_id starts with `bp_`

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

        Returns
        -------
        BrowserProfile
            Successfully retrieved browser profile

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.browser_profiles.get_browser_profile(
            profile_id="bp_123456",
        )
        """
        _response = self._raw_client.get_browser_profile(profile_id, request_options=request_options)
        return _response.data

    def delete_browser_profile(
        self, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a browser profile (soft delete)

        Parameters
        ----------
        profile_id : str
            The ID of the browser profile to delete. browser_profile_id starts with `bp_`

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

        Returns
        -------
        None

        Examples
        --------
        from skyvern import Skyvern

        client = Skyvern(
            api_key="YOUR_API_KEY",
        )
        client.browser_profiles.delete_browser_profile(
            profile_id="bp_123456",
        )
        """
        _response = self._raw_client.delete_browser_profile(profile_id, request_options=request_options)
        return _response.data


class AsyncBrowserProfilesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBrowserProfilesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawBrowserProfilesClient
        """
        return self._raw_client

    async def list_browser_profiles(
        self, *, include_deleted: typing.Optional[bool] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[BrowserProfile]:
        """
        Get all browser profiles for the organization

        Parameters
        ----------
        include_deleted : typing.Optional[bool]
            Include deleted browser profiles

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

        Returns
        -------
        typing.List[BrowserProfile]
            Successful Response

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.browser_profiles.list_browser_profiles(
                include_deleted=True,
            )


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

    async def create_browser_profile(
        self,
        *,
        name: str,
        description: typing.Optional[str] = OMIT,
        browser_session_id: typing.Optional[str] = OMIT,
        workflow_run_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BrowserProfile:
        """
        Parameters
        ----------
        name : str
            Name for the browser profile

        description : typing.Optional[str]
            Optional profile description

        browser_session_id : typing.Optional[str]
            Persistent browser session to convert into a profile

        workflow_run_id : typing.Optional[str]
            Workflow run whose persisted session should be captured

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

        Returns
        -------
        BrowserProfile
            Successful Response

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.browser_profiles.create_browser_profile(
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_browser_profile(
            name=name,
            description=description,
            browser_session_id=browser_session_id,
            workflow_run_id=workflow_run_id,
            request_options=request_options,
        )
        return _response.data

    async def get_browser_profile(
        self, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> BrowserProfile:
        """
        Get a specific browser profile by ID

        Parameters
        ----------
        profile_id : str
            The ID of the browser profile. browser_profile_id starts with `bp_`

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

        Returns
        -------
        BrowserProfile
            Successfully retrieved browser profile

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.browser_profiles.get_browser_profile(
                profile_id="bp_123456",
            )


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

    async def delete_browser_profile(
        self, profile_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a browser profile (soft delete)

        Parameters
        ----------
        profile_id : str
            The ID of the browser profile to delete. browser_profile_id starts with `bp_`

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from skyvern import AsyncSkyvern

        client = AsyncSkyvern(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.browser_profiles.delete_browser_profile(
                profile_id="bp_123456",
            )


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