# 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 AsyncRawDataexportsClient, RawDataexportsClient
from .types.create_data_export_response import CreateDataExportResponse

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


class DataexportsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawDataexportsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawDataexportsClient
        """
        return self._raw_client

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

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

        Returns
        -------
        CreateDataExportResponse
            Created

        Examples
        --------
        from schematic import Schematic

        client = Schematic(
            api_key="YOUR_API_KEY",
        )
        client.dataexports.create_data_export(
            metadata="metadata",
        )
        """
        _response = self._raw_client.create_data_export(metadata=metadata, request_options=request_options)
        return _response.data

    def get_data_export_artifact(
        self, data_export_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Iterator[bytes]:
        """
        Parameters
        ----------
        data_export_id : str
            data_export_id

        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]
            OK
        """
        with self._raw_client.get_data_export_artifact(data_export_id, request_options=request_options) as r:
            yield from r.data


class AsyncDataexportsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawDataexportsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawDataexportsClient
        """
        return self._raw_client

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

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

        Returns
        -------
        CreateDataExportResponse
            Created

        Examples
        --------
        import asyncio

        from schematic import AsyncSchematic

        client = AsyncSchematic(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dataexports.create_data_export(
                metadata="metadata",
            )


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

    async def get_data_export_artifact(
        self, data_export_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.AsyncIterator[bytes]:
        """
        Parameters
        ----------
        data_export_id : str
            data_export_id

        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]
            OK
        """
        async with self._raw_client.get_data_export_artifact(data_export_id, request_options=request_options) as r:
            async for _chunk in r.data:
                yield _chunk
