# 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.list_auth_connections_response import ListAuthConnectionsResponse
from .raw_client import AsyncRawAuthConnectionsClient, RawAuthConnectionsClient
from .types.auth_connections_create_request_body import AuthConnectionsCreateRequestBody
from .types.auth_connections_create_response import AuthConnectionsCreateResponse
from .types.auth_connections_update_request_body import AuthConnectionsUpdateRequestBody
from .types.auth_connections_update_response import AuthConnectionsUpdateResponse

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


class AuthConnectionsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAuthConnectionsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawAuthConnectionsClient
        """
        return self._raw_client

    def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ListAuthConnectionsResponse:
        """
        Get all auth connections for the workspace

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

        Returns
        -------
        ListAuthConnectionsResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.workspace.auth_connections.list()
        """
        _response = self._raw_client.list(request_options=request_options)
        return _response.data

    def create(
        self, *, request: AuthConnectionsCreateRequestBody, request_options: typing.Optional[RequestOptions] = None
    ) -> AuthConnectionsCreateResponse:
        """
        Create a new OAuth2 auth connection for the workspace

        Parameters
        ----------
        request : AuthConnectionsCreateRequestBody

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

        Returns
        -------
        AuthConnectionsCreateResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs
        from elevenlabs.workspace.auth_connections import (
            AuthConnectionsCreateRequestBody_Oauth2ClientCredentials,
        )

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.workspace.auth_connections.create(
            request=AuthConnectionsCreateRequestBody_Oauth2ClientCredentials(
                name="name",
                provider="provider",
                client_id="client_id",
                token_url="token_url",
                client_secret="client_secret",
            ),
        )
        """
        _response = self._raw_client.create(request=request, request_options=request_options)
        return _response.data

    def delete(self, auth_connection_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
        """
        Delete an auth connection

        Parameters
        ----------
        auth_connection_id : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.workspace.auth_connections.delete(
            auth_connection_id="auth_connection_id",
        )
        """
        _response = self._raw_client.delete(auth_connection_id, request_options=request_options)
        return _response.data

    def update(
        self,
        auth_connection_id: str,
        *,
        request: AuthConnectionsUpdateRequestBody,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AuthConnectionsUpdateResponse:
        """
        Update an auth connection

        Parameters
        ----------
        auth_connection_id : str

        request : AuthConnectionsUpdateRequestBody

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

        Returns
        -------
        AuthConnectionsUpdateResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs
        from elevenlabs.workspace.auth_connections import (
            AuthConnectionsUpdateRequestBody_Oauth2ClientCredentials,
        )

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.workspace.auth_connections.update(
            auth_connection_id="auth_connection_id",
            request=AuthConnectionsUpdateRequestBody_Oauth2ClientCredentials(),
        )
        """
        _response = self._raw_client.update(auth_connection_id, request=request, request_options=request_options)
        return _response.data


class AsyncAuthConnectionsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAuthConnectionsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawAuthConnectionsClient
        """
        return self._raw_client

    async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> ListAuthConnectionsResponse:
        """
        Get all auth connections for the workspace

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

        Returns
        -------
        ListAuthConnectionsResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


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


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

    async def create(
        self, *, request: AuthConnectionsCreateRequestBody, request_options: typing.Optional[RequestOptions] = None
    ) -> AuthConnectionsCreateResponse:
        """
        Create a new OAuth2 auth connection for the workspace

        Parameters
        ----------
        request : AuthConnectionsCreateRequestBody

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

        Returns
        -------
        AuthConnectionsCreateResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs
        from elevenlabs.workspace.auth_connections import (
            AuthConnectionsCreateRequestBody_Oauth2ClientCredentials,
        )

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.workspace.auth_connections.create(
                request=AuthConnectionsCreateRequestBody_Oauth2ClientCredentials(
                    name="name",
                    provider="provider",
                    client_id="client_id",
                    token_url="token_url",
                    client_secret="client_secret",
                ),
            )


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

    async def delete(
        self, auth_connection_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Delete an auth connection

        Parameters
        ----------
        auth_connection_id : str

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.workspace.auth_connections.delete(
                auth_connection_id="auth_connection_id",
            )


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

    async def update(
        self,
        auth_connection_id: str,
        *,
        request: AuthConnectionsUpdateRequestBody,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AuthConnectionsUpdateResponse:
        """
        Update an auth connection

        Parameters
        ----------
        auth_connection_id : str

        request : AuthConnectionsUpdateRequestBody

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

        Returns
        -------
        AuthConnectionsUpdateResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs
        from elevenlabs.workspace.auth_connections import (
            AuthConnectionsUpdateRequestBody_Oauth2ClientCredentials,
        )

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.workspace.auth_connections.update(
                auth_connection_id="auth_connection_id",
                request=AuthConnectionsUpdateRequestBody_Oauth2ClientCredentials(),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(auth_connection_id, request=request, request_options=request_options)
        return _response.data
