# 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.provider import Provider
from ..types.provider_type import ProviderType
from .raw_client import AsyncRawProvidersClient, RawProvidersClient

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


class ProvidersClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawProvidersClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawProvidersClient
        """
        return self._raw_client

    def list(
        self,
        *,
        name: typing.Optional[str] = None,
        provider_type: typing.Optional[ProviderType] = None,
        after: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Provider]:
        """
        Get a list of all custom providers in the database

        Parameters
        ----------
        name : typing.Optional[str]

        provider_type : typing.Optional[ProviderType]

        after : typing.Optional[str]

        limit : typing.Optional[int]

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

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

        Examples
        --------
        from letta_client import Letta

        client = Letta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )
        client.providers.list()
        """
        _response = self._raw_client.list(
            name=name, provider_type=provider_type, after=after, limit=limit, request_options=request_options
        )
        return _response.data

    def create(
        self,
        *,
        name: str,
        provider_type: ProviderType,
        api_key: str,
        access_key: typing.Optional[str] = OMIT,
        region: typing.Optional[str] = OMIT,
        base_url: typing.Optional[str] = OMIT,
        api_version: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Provider:
        """
        Create a new custom provider

        Parameters
        ----------
        name : str
            The name of the provider.

        provider_type : ProviderType
            The type of the provider.

        api_key : str
            API key or secret key used for requests to the provider.

        access_key : typing.Optional[str]
            Access key used for requests to the provider.

        region : typing.Optional[str]
            Region used for requests to the provider.

        base_url : typing.Optional[str]
            Base URL used for requests to the provider.

        api_version : typing.Optional[str]
            API version used for requests to the provider.

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

        Returns
        -------
        Provider
            Successful Response

        Examples
        --------
        from letta_client import Letta

        client = Letta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )
        client.providers.create(
            name="name",
            provider_type="anthropic",
            api_key="api_key",
        )
        """
        _response = self._raw_client.create(
            name=name,
            provider_type=provider_type,
            api_key=api_key,
            access_key=access_key,
            region=region,
            base_url=base_url,
            api_version=api_version,
            request_options=request_options,
        )
        return _response.data

    def delete(
        self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Delete an existing custom provider

        Parameters
        ----------
        provider_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from letta_client import Letta

        client = Letta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )
        client.providers.delete(
            provider_id="provider_id",
        )
        """
        _response = self._raw_client.delete(provider_id, request_options=request_options)
        return _response.data

    def modify(
        self,
        provider_id: str,
        *,
        api_key: str,
        access_key: typing.Optional[str] = OMIT,
        region: typing.Optional[str] = OMIT,
        base_url: typing.Optional[str] = OMIT,
        api_version: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Provider:
        """
        Update an existing custom provider

        Parameters
        ----------
        provider_id : str

        api_key : str
            API key or secret key used for requests to the provider.

        access_key : typing.Optional[str]
            Access key used for requests to the provider.

        region : typing.Optional[str]
            Region used for requests to the provider.

        base_url : typing.Optional[str]
            Base URL used for requests to the provider.

        api_version : typing.Optional[str]
            API version used for requests to the provider.

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

        Returns
        -------
        Provider
            Successful Response

        Examples
        --------
        from letta_client import Letta

        client = Letta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )
        client.providers.modify(
            provider_id="provider_id",
            api_key="api_key",
        )
        """
        _response = self._raw_client.modify(
            provider_id,
            api_key=api_key,
            access_key=access_key,
            region=region,
            base_url=base_url,
            api_version=api_version,
            request_options=request_options,
        )
        return _response.data

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

        Returns
        -------
        None

        Examples
        --------
        from letta_client import Letta

        client = Letta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )
        client.providers.check()
        """
        _response = self._raw_client.check(request_options=request_options)
        return _response.data

    def check_provider(
        self,
        *,
        provider_type: ProviderType,
        api_key: str,
        access_key: typing.Optional[str] = OMIT,
        region: typing.Optional[str] = OMIT,
        base_url: typing.Optional[str] = OMIT,
        api_version: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        provider_type : ProviderType
            The type of the provider.

        api_key : str
            API key or secret key used for requests to the provider.

        access_key : typing.Optional[str]
            Access key used for requests to the provider.

        region : typing.Optional[str]
            Region used for requests to the provider.

        base_url : typing.Optional[str]
            Base URL used for requests to the provider.

        api_version : typing.Optional[str]
            API version used for requests to the provider.

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        from letta_client import Letta

        client = Letta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )
        client.providers.check_provider(
            provider_type="anthropic",
            api_key="api_key",
        )
        """
        _response = self._raw_client.check_provider(
            provider_type=provider_type,
            api_key=api_key,
            access_key=access_key,
            region=region,
            base_url=base_url,
            api_version=api_version,
            request_options=request_options,
        )
        return _response.data


class AsyncProvidersClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawProvidersClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawProvidersClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        name: typing.Optional[str] = None,
        provider_type: typing.Optional[ProviderType] = None,
        after: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[Provider]:
        """
        Get a list of all custom providers in the database

        Parameters
        ----------
        name : typing.Optional[str]

        provider_type : typing.Optional[ProviderType]

        after : typing.Optional[str]

        limit : typing.Optional[int]

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

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

        Examples
        --------
        import asyncio

        from letta_client import AsyncLetta

        client = AsyncLetta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            name=name, provider_type=provider_type, after=after, limit=limit, request_options=request_options
        )
        return _response.data

    async def create(
        self,
        *,
        name: str,
        provider_type: ProviderType,
        api_key: str,
        access_key: typing.Optional[str] = OMIT,
        region: typing.Optional[str] = OMIT,
        base_url: typing.Optional[str] = OMIT,
        api_version: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Provider:
        """
        Create a new custom provider

        Parameters
        ----------
        name : str
            The name of the provider.

        provider_type : ProviderType
            The type of the provider.

        api_key : str
            API key or secret key used for requests to the provider.

        access_key : typing.Optional[str]
            Access key used for requests to the provider.

        region : typing.Optional[str]
            Region used for requests to the provider.

        base_url : typing.Optional[str]
            Base URL used for requests to the provider.

        api_version : typing.Optional[str]
            API version used for requests to the provider.

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

        Returns
        -------
        Provider
            Successful Response

        Examples
        --------
        import asyncio

        from letta_client import AsyncLetta

        client = AsyncLetta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.providers.create(
                name="name",
                provider_type="anthropic",
                api_key="api_key",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            name=name,
            provider_type=provider_type,
            api_key=api_key,
            access_key=access_key,
            region=region,
            base_url=base_url,
            api_version=api_version,
            request_options=request_options,
        )
        return _response.data

    async def delete(
        self, provider_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Optional[typing.Any]:
        """
        Delete an existing custom provider

        Parameters
        ----------
        provider_id : str

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from letta_client import AsyncLetta

        client = AsyncLetta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.providers.delete(
                provider_id="provider_id",
            )


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

    async def modify(
        self,
        provider_id: str,
        *,
        api_key: str,
        access_key: typing.Optional[str] = OMIT,
        region: typing.Optional[str] = OMIT,
        base_url: typing.Optional[str] = OMIT,
        api_version: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Provider:
        """
        Update an existing custom provider

        Parameters
        ----------
        provider_id : str

        api_key : str
            API key or secret key used for requests to the provider.

        access_key : typing.Optional[str]
            Access key used for requests to the provider.

        region : typing.Optional[str]
            Region used for requests to the provider.

        base_url : typing.Optional[str]
            Base URL used for requests to the provider.

        api_version : typing.Optional[str]
            API version used for requests to the provider.

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

        Returns
        -------
        Provider
            Successful Response

        Examples
        --------
        import asyncio

        from letta_client import AsyncLetta

        client = AsyncLetta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.providers.modify(
                provider_id="provider_id",
                api_key="api_key",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.modify(
            provider_id,
            api_key=api_key,
            access_key=access_key,
            region=region,
            base_url=base_url,
            api_version=api_version,
            request_options=request_options,
        )
        return _response.data

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from letta_client import AsyncLetta

        client = AsyncLetta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.providers.check()


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

    async def check_provider(
        self,
        *,
        provider_type: ProviderType,
        api_key: str,
        access_key: typing.Optional[str] = OMIT,
        region: typing.Optional[str] = OMIT,
        base_url: typing.Optional[str] = OMIT,
        api_version: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Optional[typing.Any]:
        """
        Parameters
        ----------
        provider_type : ProviderType
            The type of the provider.

        api_key : str
            API key or secret key used for requests to the provider.

        access_key : typing.Optional[str]
            Access key used for requests to the provider.

        region : typing.Optional[str]
            Region used for requests to the provider.

        base_url : typing.Optional[str]
            Base URL used for requests to the provider.

        api_version : typing.Optional[str]
            API version used for requests to the provider.

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

        Returns
        -------
        typing.Optional[typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from letta_client import AsyncLetta

        client = AsyncLetta(
            project="YOUR_PROJECT",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.providers.check_provider(
                provider_type="anthropic",
                api_key="api_key",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.check_provider(
            provider_type=provider_type,
            api_key=api_key,
            access_key=access_key,
            region=region,
            base_url=base_url,
            api_version=api_version,
            request_options=request_options,
        )
        return _response.data
