# 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_variable_v1 import AgentVariableV1
from ...types.delete_agent_variable_v1response import DeleteAgentVariableV1Response
from ...types.list_agent_variables_v1response import ListAgentVariablesV1Response
from .raw_client import AsyncRawVariablesClient, RawVariablesClient

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


class VariablesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawVariablesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawVariablesClient
        """
        return self._raw_client

    def list(
        self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ListAgentVariablesV1Response:
        """
        Returns all template variables for the specified project

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

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

        Returns
        -------
        ListAgentVariablesV1Response
            A list of agent variables

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

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.voice_agent.variables.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,
        *,
        key: str,
        value: typing.Any,
        api_version: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AgentVariableV1:
        """
        Creates a new template variable. Variables follow the `DG_<VARIABLE_NAME>` naming format and can substitute any JSON value in an agent configuration.

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

        key : str
            The variable name, following the DG_<VARIABLE_NAME> format

        value : typing.Any

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

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

        Returns
        -------
        AgentVariableV1
            Agent variable created successfully

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

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.voice_agent.variables.create(
            project_id="project_id",
            key="key",
            value={"key": "value"},
        )
        """
        _response = self._raw_client.create(
            project_id, key=key, value=value, api_version=api_version, request_options=request_options
        )
        return _response.data

    def get(
        self, project_id: str, variable_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AgentVariableV1:
        """
        Returns the specified template variable

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

        variable_id : str
            The unique identifier of the agent variable

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

        Returns
        -------
        AgentVariableV1
            An agent variable

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

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.voice_agent.variables.get(
            project_id="123456-7890-1234-5678-901234",
            variable_id="v1a2b3c4-d5e6-7890-abcd-ef1234567890",
        )
        """
        _response = self._raw_client.get(project_id, variable_id, request_options=request_options)
        return _response.data

    def delete(
        self, project_id: str, variable_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteAgentVariableV1Response:
        """
        Deletes the specified template variable

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

        variable_id : str
            The unique identifier of the agent variable

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

        Returns
        -------
        DeleteAgentVariableV1Response
            Agent variable deleted

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

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.voice_agent.variables.delete(
            project_id="123456-7890-1234-5678-901234",
            variable_id="v1a2b3c4-d5e6-7890-abcd-ef1234567890",
        )
        """
        _response = self._raw_client.delete(project_id, variable_id, request_options=request_options)
        return _response.data

    def update(
        self,
        project_id: str,
        variable_id: str,
        *,
        value: typing.Any,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AgentVariableV1:
        """
        Updates the value of an existing template variable

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

        variable_id : str
            The unique identifier of the agent variable

        value : typing.Any

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

        Returns
        -------
        AgentVariableV1
            Agent variable updated

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

        client = DeepgramClient(
            api_key="YOUR_API_KEY",
        )
        client.voice_agent.variables.update(
            project_id="project_id",
            variable_id="variable_id",
            value={"key": "value"},
        )
        """
        _response = self._raw_client.update(project_id, variable_id, value=value, request_options=request_options)
        return _response.data


class AsyncVariablesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawVariablesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawVariablesClient
        """
        return self._raw_client

    async def list(
        self, project_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ListAgentVariablesV1Response:
        """
        Returns all template variables for the specified project

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

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

        Returns
        -------
        ListAgentVariablesV1Response
            A list of agent variables

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_agent.variables.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,
        *,
        key: str,
        value: typing.Any,
        api_version: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AgentVariableV1:
        """
        Creates a new template variable. Variables follow the `DG_<VARIABLE_NAME>` naming format and can substitute any JSON value in an agent configuration.

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

        key : str
            The variable name, following the DG_<VARIABLE_NAME> format

        value : typing.Any

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

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

        Returns
        -------
        AgentVariableV1
            Agent variable created successfully

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_agent.variables.create(
                project_id="project_id",
                key="key",
                value={"key": "value"},
            )


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

    async def get(
        self, project_id: str, variable_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> AgentVariableV1:
        """
        Returns the specified template variable

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

        variable_id : str
            The unique identifier of the agent variable

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

        Returns
        -------
        AgentVariableV1
            An agent variable

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_agent.variables.get(
                project_id="123456-7890-1234-5678-901234",
                variable_id="v1a2b3c4-d5e6-7890-abcd-ef1234567890",
            )


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

    async def delete(
        self, project_id: str, variable_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteAgentVariableV1Response:
        """
        Deletes the specified template variable

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

        variable_id : str
            The unique identifier of the agent variable

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

        Returns
        -------
        DeleteAgentVariableV1Response
            Agent variable deleted

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_agent.variables.delete(
                project_id="123456-7890-1234-5678-901234",
                variable_id="v1a2b3c4-d5e6-7890-abcd-ef1234567890",
            )


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

    async def update(
        self,
        project_id: str,
        variable_id: str,
        *,
        value: typing.Any,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AgentVariableV1:
        """
        Updates the value of an existing template variable

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

        variable_id : str
            The unique identifier of the agent variable

        value : typing.Any

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

        Returns
        -------
        AgentVariableV1
            Agent variable updated

        Examples
        --------
        import asyncio

        from deepgram import AsyncDeepgramClient

        client = AsyncDeepgramClient(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.voice_agent.variables.update(
                project_id="project_id",
                variable_id="variable_id",
                value={"key": "value"},
            )


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