# 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.agent_configuration_v1 import AgentConfigurationV1
from ...types.create_agent_configuration_v1response import CreateAgentConfigurationV1Response
from ...types.delete_agent_configuration_v1response import DeleteAgentConfigurationV1Response
from ...types.list_agent_configurations_v1response import ListAgentConfigurationsV1Response
from .raw_client import AsyncRawConfigurationsClient, RawConfigurationsClient

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


class ConfigurationsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawConfigurationsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawConfigurationsClient
        """
        return self._raw_client

    def list(
        self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ListAgentConfigurationsV1Response:
        """
        Returns all agent configurations for the specified project. Configurations are returned in their uninterpolated form—template variable placeholders appear as-is rather than with their substituted values.

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

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

        Returns
        -------
        ListAgentConfigurationsV1Response
            A list of agent configurations

        Examples
        --------
        from deepgram import DeepgramClient

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.voice_agent.configurations.list(
            project_id="123456-7890-1234-5678-901234",
        )
        """
        _response = self._raw_client.list(project_id, request_options=request_options)
        return _response.data

    def create(
        self,
        project_id: str,
        *,
        config: str,
        metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
        api_version: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateAgentConfigurationV1Response:
        """
        Creates a new reusable agent configuration. The `config` field must be a valid JSON string representing the `agent` block of a Settings message. The returned `agent_id` can be passed in place of the full `agent` object in future Settings messages.

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        config : str
            A valid JSON string representing the agent block of a Settings message

        metadata : typing.Optional[typing.Dict[str, str]]
            A map of arbitrary key-value pairs for labeling or organizing the agent configuration

        api_version : typing.Optional[int]
            API version. Defaults to 1

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

        Returns
        -------
        CreateAgentConfigurationV1Response
            Agent configuration created successfully

        Examples
        --------
        from deepgram import DeepgramClient

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.voice_agent.configurations.create(
            project_id="123456-7890-1234-5678-901234",
            config="config",
        )
        """
        _response = self._raw_client.create(
            project_id, config=config, metadata=metadata, api_version=api_version, request_options=request_options
        )
        return _response.data

    def get(
        self, project_id: str, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AgentConfigurationV1:
        """
        Returns the specified agent configuration in its uninterpolated form

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        agent_id : str
            The unique identifier of the agent configuration

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

        Returns
        -------
        AgentConfigurationV1
            An agent configuration

        Examples
        --------
        from deepgram import DeepgramClient

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.voice_agent.configurations.get(
            project_id="123456-7890-1234-5678-901234",
            agent_id="a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        )
        """
        _response = self._raw_client.get(project_id, agent_id, request_options=request_options)
        return _response.data

    def update(
        self,
        project_id: str,
        agent_id: str,
        *,
        metadata: typing.Dict[str, str],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AgentConfigurationV1:
        """
        Updates the metadata associated with an agent configuration. The config itself is immutable—to change the configuration, delete the existing agent and create a new one.

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        agent_id : str
            The unique identifier of the agent configuration

        metadata : typing.Dict[str, str]
            A map of string key-value pairs to associate with this agent configuration

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

        Returns
        -------
        AgentConfigurationV1
            Agent configuration updated

        Examples
        --------
        from deepgram import DeepgramClient

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.voice_agent.configurations.update(
            project_id="123456-7890-1234-5678-901234",
            agent_id="a1b2c3d4-e5f6-7890-abcd-ef1234567890",
            metadata={"key": "value"},
        )
        """
        _response = self._raw_client.update(project_id, agent_id, metadata=metadata, request_options=request_options)
        return _response.data

    def delete(
        self, project_id: str, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteAgentConfigurationV1Response:
        """
        Deletes the specified agent configuration. Deleting an agent configuration can cause a production outage if your service references this agent UUID. Migrate all active sessions to a new configuration before deleting.

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        agent_id : str
            The unique identifier of the agent configuration

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

        Returns
        -------
        DeleteAgentConfigurationV1Response
            Agent configuration deleted

        Examples
        --------
        from deepgram import DeepgramClient

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.voice_agent.configurations.delete(
            project_id="123456-7890-1234-5678-901234",
            agent_id="a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        )
        """
        _response = self._raw_client.delete(project_id, agent_id, request_options=request_options)
        return _response.data


class AsyncConfigurationsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawConfigurationsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawConfigurationsClient
        """
        return self._raw_client

    async def list(
        self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ListAgentConfigurationsV1Response:
        """
        Returns all agent configurations for the specified project. Configurations are returned in their uninterpolated form—template variable placeholders appear as-is rather than with their substituted values.

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

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

        Returns
        -------
        ListAgentConfigurationsV1Response
            A list of agent configurations

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_agent.configurations.list(
                project_id="123456-7890-1234-5678-901234",
            )


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

    async def create(
        self,
        project_id: str,
        *,
        config: str,
        metadata: typing.Optional[typing.Dict[str, str]] = OMIT,
        api_version: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateAgentConfigurationV1Response:
        """
        Creates a new reusable agent configuration. The `config` field must be a valid JSON string representing the `agent` block of a Settings message. The returned `agent_id` can be passed in place of the full `agent` object in future Settings messages.

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        config : str
            A valid JSON string representing the agent block of a Settings message

        metadata : typing.Optional[typing.Dict[str, str]]
            A map of arbitrary key-value pairs for labeling or organizing the agent configuration

        api_version : typing.Optional[int]
            API version. Defaults to 1

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

        Returns
        -------
        CreateAgentConfigurationV1Response
            Agent configuration created successfully

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_agent.configurations.create(
                project_id="123456-7890-1234-5678-901234",
                config="config",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            project_id, config=config, metadata=metadata, api_version=api_version, request_options=request_options
        )
        return _response.data

    async def get(
        self, project_id: str, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AgentConfigurationV1:
        """
        Returns the specified agent configuration in its uninterpolated form

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        agent_id : str
            The unique identifier of the agent configuration

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

        Returns
        -------
        AgentConfigurationV1
            An agent configuration

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_agent.configurations.get(
                project_id="123456-7890-1234-5678-901234",
                agent_id="a1b2c3d4-e5f6-7890-abcd-ef1234567890",
            )


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

    async def update(
        self,
        project_id: str,
        agent_id: str,
        *,
        metadata: typing.Dict[str, str],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AgentConfigurationV1:
        """
        Updates the metadata associated with an agent configuration. The config itself is immutable—to change the configuration, delete the existing agent and create a new one.

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        agent_id : str
            The unique identifier of the agent configuration

        metadata : typing.Dict[str, str]
            A map of string key-value pairs to associate with this agent configuration

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

        Returns
        -------
        AgentConfigurationV1
            Agent configuration updated

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_agent.configurations.update(
                project_id="123456-7890-1234-5678-901234",
                agent_id="a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                metadata={"key": "value"},
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            project_id, agent_id, metadata=metadata, request_options=request_options
        )
        return _response.data

    async def delete(
        self, project_id: str, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteAgentConfigurationV1Response:
        """
        Deletes the specified agent configuration. Deleting an agent configuration can cause a production outage if your service references this agent UUID. Migrate all active sessions to a new configuration before deleting.

        Parameters
        ----------
        project_id : str
            The unique identifier of the project

        agent_id : str
            The unique identifier of the agent configuration

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

        Returns
        -------
        DeleteAgentConfigurationV1Response
            Agent configuration deleted

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_agent.configurations.delete(
                project_id="123456-7890-1234-5678-901234",
                agent_id="a1b2c3d4-e5f6-7890-abcd-ef1234567890",
            )


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