# 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.conv_ai_workspace_stored_secret_config import ConvAiWorkspaceStoredSecretConfig
from ...types.get_secret_dependencies_response_model import GetSecretDependenciesResponseModel
from ...types.get_workspace_secrets_response_model import GetWorkspaceSecretsResponseModel
from ...types.post_workspace_secret_response_model import PostWorkspaceSecretResponseModel
from ...types.secret_dependency_resource_type import SecretDependencyResourceType
from .raw_client import AsyncRawSecretsClient, RawSecretsClient

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


class SecretsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawSecretsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawSecretsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        page_size: typing.Optional[int] = None,
        dependency_limit: typing.Optional[int] = None,
        search: typing.Optional[str] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetWorkspaceSecretsResponseModel:
        """
        Get all workspace secrets for the user

        Parameters
        ----------
        page_size : typing.Optional[int]
            How many documents to return at maximum. Can not exceed 100. If not provided, returns all secrets.

        dependency_limit : typing.Optional[int]
            Maximum number of dependent resources (tools, agents, phone numbers) to return per secret. Can not exceed 100.

        search : typing.Optional[str]
            If specified, returns only secrets whose names start with this string.

        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

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

        Returns
        -------
        GetWorkspaceSecretsResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.secrets.list(
            page_size=1,
            dependency_limit=1,
            search="search",
            cursor="cursor",
        )
        """
        _response = self._raw_client.list(
            page_size=page_size,
            dependency_limit=dependency_limit,
            search=search,
            cursor=cursor,
            request_options=request_options,
        )
        return _response.data

    def create(
        self, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None
    ) -> PostWorkspaceSecretResponseModel:
        """
        Create a new secret for the workspace

        Parameters
        ----------
        name : str

        value : str

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

        Returns
        -------
        PostWorkspaceSecretResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.secrets.create(
            name="name",
            value="value",
        )
        """
        _response = self._raw_client.create(name=name, value=value, request_options=request_options)
        return _response.data

    def get(
        self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ConvAiWorkspaceStoredSecretConfig:
        """
        Get a workspace secret by ID

        Parameters
        ----------
        secret_id : str

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

        Returns
        -------
        ConvAiWorkspaceStoredSecretConfig
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.secrets.get(
            secret_id="secret_id",
        )
        """
        _response = self._raw_client.get(secret_id, request_options=request_options)
        return _response.data

    def delete(self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a workspace secret if it's not in use

        Parameters
        ----------
        secret_id : str

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

        Returns
        -------
        None

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.secrets.delete(
            secret_id="secret_id",
        )
        """
        _response = self._raw_client.delete(secret_id, request_options=request_options)
        return _response.data

    def update(
        self, secret_id: str, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None
    ) -> PostWorkspaceSecretResponseModel:
        """
        Update an existing secret for the workspace

        Parameters
        ----------
        secret_id : str

        name : str

        value : str

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

        Returns
        -------
        PostWorkspaceSecretResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.secrets.update(
            secret_id="secret_id",
            name="name",
            value="value",
        )
        """
        _response = self._raw_client.update(secret_id, name=name, value=value, request_options=request_options)
        return _response.data

    def get_dependencies(
        self,
        secret_id: str,
        resource_type: SecretDependencyResourceType,
        *,
        page_size: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetSecretDependenciesResponseModel:
        """
        Get paginated list of resources that depend on a specific secret, filtered by resource type.

        Parameters
        ----------
        secret_id : str

        resource_type : SecretDependencyResourceType

        page_size : typing.Optional[int]
            How many dependency items to return per page.

        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

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

        Returns
        -------
        GetSecretDependenciesResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.secrets.get_dependencies(
            secret_id="secret_id",
            resource_type="tools",
            page_size=1,
            cursor="cursor",
        )
        """
        _response = self._raw_client.get_dependencies(
            secret_id, resource_type, page_size=page_size, cursor=cursor, request_options=request_options
        )
        return _response.data


class AsyncSecretsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawSecretsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawSecretsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        page_size: typing.Optional[int] = None,
        dependency_limit: typing.Optional[int] = None,
        search: typing.Optional[str] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetWorkspaceSecretsResponseModel:
        """
        Get all workspace secrets for the user

        Parameters
        ----------
        page_size : typing.Optional[int]
            How many documents to return at maximum. Can not exceed 100. If not provided, returns all secrets.

        dependency_limit : typing.Optional[int]
            Maximum number of dependent resources (tools, agents, phone numbers) to return per secret. Can not exceed 100.

        search : typing.Optional[str]
            If specified, returns only secrets whose names start with this string.

        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

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

        Returns
        -------
        GetWorkspaceSecretsResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.secrets.list(
                page_size=1,
                dependency_limit=1,
                search="search",
                cursor="cursor",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            page_size=page_size,
            dependency_limit=dependency_limit,
            search=search,
            cursor=cursor,
            request_options=request_options,
        )
        return _response.data

    async def create(
        self, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None
    ) -> PostWorkspaceSecretResponseModel:
        """
        Create a new secret for the workspace

        Parameters
        ----------
        name : str

        value : str

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

        Returns
        -------
        PostWorkspaceSecretResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.secrets.create(
                name="name",
                value="value",
            )


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

    async def get(
        self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ConvAiWorkspaceStoredSecretConfig:
        """
        Get a workspace secret by ID

        Parameters
        ----------
        secret_id : str

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

        Returns
        -------
        ConvAiWorkspaceStoredSecretConfig
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.secrets.get(
                secret_id="secret_id",
            )


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

    async def delete(self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a workspace secret if it's not in use

        Parameters
        ----------
        secret_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.secrets.delete(
                secret_id="secret_id",
            )


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

    async def update(
        self, secret_id: str, *, name: str, value: str, request_options: typing.Optional[RequestOptions] = None
    ) -> PostWorkspaceSecretResponseModel:
        """
        Update an existing secret for the workspace

        Parameters
        ----------
        secret_id : str

        name : str

        value : str

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

        Returns
        -------
        PostWorkspaceSecretResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.secrets.update(
                secret_id="secret_id",
                name="name",
                value="value",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(secret_id, name=name, value=value, request_options=request_options)
        return _response.data

    async def get_dependencies(
        self,
        secret_id: str,
        resource_type: SecretDependencyResourceType,
        *,
        page_size: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GetSecretDependenciesResponseModel:
        """
        Get paginated list of resources that depend on a specific secret, filtered by resource type.

        Parameters
        ----------
        secret_id : str

        resource_type : SecretDependencyResourceType

        page_size : typing.Optional[int]
            How many dependency items to return per page.

        cursor : typing.Optional[str]
            Used for fetching next page. Cursor is returned in the response.

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

        Returns
        -------
        GetSecretDependenciesResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.secrets.get_dependencies(
                secret_id="secret_id",
                resource_type="tools",
                page_size=1,
                cursor="cursor",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_dependencies(
            secret_id, resource_type, page_size=page_size, cursor=cursor, request_options=request_options
        )
        return _response.data
