# 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 .raw_client import AsyncRawOllieStateClient, RawOllieStateClient

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


class OllieStateClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawOllieStateClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawOllieStateClient
        """
        return self._raw_client

    def download_ollie_state(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Iterator[bytes]:
        """
        Download stored ollie state file

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.Iterator[bytes]
            Ollie state file

        Examples
        --------
        from Opik import OpikApi
        client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
        client.ollie_state.download_ollie_state()
        """
        with self._raw_client.download_ollie_state(request_options=request_options) as r:
            yield from r.data

    def replace_ollie_state(
        self,
        *,
        request: typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Upload gzip-compressed SQLite DB file, replacing any existing state

        Parameters
        ----------
        request : typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]

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

        Returns
        -------
        None
        """
        _response = self._raw_client.replace_ollie_state(request=request, request_options=request_options)
        return _response.data

    def delete_ollie_state(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Clear stored ollie state

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

        Returns
        -------
        None

        Examples
        --------
        from Opik import OpikApi
        client = OpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
        client.ollie_state.delete_ollie_state()
        """
        _response = self._raw_client.delete_ollie_state(request_options=request_options)
        return _response.data


class AsyncOllieStateClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawOllieStateClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawOllieStateClient
        """
        return self._raw_client

    async def download_ollie_state(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.AsyncIterator[bytes]:
        """
        Download stored ollie state file

        Parameters
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration. You can pass in configuration such as `chunk_size`, and more to customize the request and response.

        Returns
        -------
        typing.AsyncIterator[bytes]
            Ollie state file

        Examples
        --------
        from Opik import AsyncOpikApi
        import asyncio
        client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
        async def main() -> None:
            await client.ollie_state.download_ollie_state()
        asyncio.run(main())
        """
        async with self._raw_client.download_ollie_state(request_options=request_options) as r:
            async for data in r.data:
                yield data

    async def replace_ollie_state(
        self,
        *,
        request: typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Upload gzip-compressed SQLite DB file, replacing any existing state

        Parameters
        ----------
        request : typing.Union[bytes, typing.Iterator[bytes], typing.AsyncIterator[bytes]]

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

        Returns
        -------
        None
        """
        _response = await self._raw_client.replace_ollie_state(request=request, request_options=request_options)
        return _response.data

    async def delete_ollie_state(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Clear stored ollie state

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

        Returns
        -------
        None

        Examples
        --------
        from Opik import AsyncOpikApi
        import asyncio
        client = AsyncOpikApi(api_key="YOUR_API_KEY", workspace_name="YOUR_WORKSPACE_NAME", )
        async def main() -> None:
            await client.ollie_state.delete_ollie_state()
        asyncio.run(main())
        """
        _response = await self._raw_client.delete_ollie_state(request_options=request_options)
        return _response.data
