# 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.header import Header
from ..types.secret_dto import SecretDto
from ..types.secret_response_dto import SecretResponseDto
from .raw_client import AsyncRawVaultClient, RawVaultClient

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


class VaultClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawVaultClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawVaultClient
        """
        return self._raw_client

    def list_secrets(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[SecretResponseDto]:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

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

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.vault.list_secrets()
        """
        _response = self._raw_client.list_secrets(request_options=request_options)
        return _response.data

    def create_secret(
        self,
        *,
        header: Header,
        secret: SecretDto,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SecretResponseDto:
        """
        Parameters
        ----------
        header : Header

        secret : SecretDto

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

        Returns
        -------
        SecretResponseDto
            Successful Response

        Examples
        --------
        from agenta import (
            AgentaApi,
            Header,
            SecretDto,
            StandardProviderDto,
            StandardProviderSettingsDto,
        )

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.vault.create_secret(
            header=Header(),
            secret=SecretDto(
                kind="provider_key",
                data=StandardProviderDto(
                    kind="openai",
                    provider=StandardProviderSettingsDto(
                        key="key",
                    ),
                ),
            ),
        )
        """
        _response = self._raw_client.create_secret(
            header=header, secret=secret, request_options=request_options
        )
        return _response.data

    def read_secret(
        self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SecretResponseDto:
        """
        Parameters
        ----------
        secret_id : str

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

        Returns
        -------
        SecretResponseDto
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.vault.read_secret(
            secret_id="secret_id",
        )
        """
        _response = self._raw_client.read_secret(
            secret_id, request_options=request_options
        )
        return _response.data

    def update_secret(
        self,
        secret_id: str,
        *,
        header: typing.Optional[Header] = OMIT,
        secret: typing.Optional[SecretDto] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SecretResponseDto:
        """
        Parameters
        ----------
        secret_id : str

        header : typing.Optional[Header]

        secret : typing.Optional[SecretDto]

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

        Returns
        -------
        SecretResponseDto
            Successful Response

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.vault.update_secret(
            secret_id="secret_id",
        )
        """
        _response = self._raw_client.update_secret(
            secret_id, header=header, secret=secret, request_options=request_options
        )
        return _response.data

    def delete_secret(
        self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Parameters
        ----------
        secret_id : str

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

        Returns
        -------
        None

        Examples
        --------
        from agenta import AgentaApi

        client = AgentaApi(
            api_key="YOUR_API_KEY",
        )
        client.vault.delete_secret(
            secret_id="secret_id",
        )
        """
        _response = self._raw_client.delete_secret(
            secret_id, request_options=request_options
        )
        return _response.data


class AsyncVaultClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawVaultClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawVaultClient
        """
        return self._raw_client

    async def list_secrets(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[SecretResponseDto]:
        """
        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

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

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.vault.list_secrets()


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

    async def create_secret(
        self,
        *,
        header: Header,
        secret: SecretDto,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SecretResponseDto:
        """
        Parameters
        ----------
        header : Header

        secret : SecretDto

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

        Returns
        -------
        SecretResponseDto
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import (
            AsyncAgentaApi,
            Header,
            SecretDto,
            StandardProviderDto,
            StandardProviderSettingsDto,
        )

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.vault.create_secret(
                header=Header(),
                secret=SecretDto(
                    kind="provider_key",
                    data=StandardProviderDto(
                        kind="openai",
                        provider=StandardProviderSettingsDto(
                            key="key",
                        ),
                    ),
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_secret(
            header=header, secret=secret, request_options=request_options
        )
        return _response.data

    async def read_secret(
        self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SecretResponseDto:
        """
        Parameters
        ----------
        secret_id : str

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

        Returns
        -------
        SecretResponseDto
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.vault.read_secret(
                secret_id="secret_id",
            )


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

    async def update_secret(
        self,
        secret_id: str,
        *,
        header: typing.Optional[Header] = OMIT,
        secret: typing.Optional[SecretDto] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SecretResponseDto:
        """
        Parameters
        ----------
        secret_id : str

        header : typing.Optional[Header]

        secret : typing.Optional[SecretDto]

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

        Returns
        -------
        SecretResponseDto
            Successful Response

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.vault.update_secret(
                secret_id="secret_id",
            )


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

    async def delete_secret(
        self, secret_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Parameters
        ----------
        secret_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from agenta import AsyncAgentaApi

        client = AsyncAgentaApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.vault.delete_secret(
                secret_id="secret_id",
            )


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