# This file was auto-generated by Fern from our API Definition.

import typing

from .. import core
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.data_pool_dto import DataPoolDto
from ..types.data_pool_file_dto import DataPoolFileDto
from .raw_client import AsyncRawDataPoolsClient, RawDataPoolsClient

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


class DataPoolsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawDataPoolsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawDataPoolsClient
        """
        return self._raw_client

    def get_data_pool(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DataPoolDto:
        """
        Get a specific data pool (identified by its ID).

        Parameters
        ----------
        id : str

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

        Returns
        -------
        DataPoolDto
            A data pool

        Examples
        --------
        from planqk import PlanqkApi

        client = PlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )
        client.data_pools.get_data_pool(
            id="id",
        )
        """
        _response = self._raw_client.get_data_pool(id, request_options=request_options)
        return _response.data

    def update_data_pool(
        self,
        id: str,
        *,
        name: typing.Optional[str] = OMIT,
        short_description: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DataPoolDto:
        """
        Update an existing data pool (identified by its ID).

        Parameters
        ----------
        id : str

        name : typing.Optional[str]

        short_description : typing.Optional[str]

        description : typing.Optional[str]

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

        Returns
        -------
        DataPoolDto
            Data pool is saved

        Examples
        --------
        from planqk import PlanqkApi

        client = PlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )
        client.data_pools.update_data_pool(
            id="id",
        )
        """
        _response = self._raw_client.update_data_pool(
            id, name=name, short_description=short_description, description=description, request_options=request_options
        )
        return _response.data

    def delete_data_pool(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a specific data pool (identified by its ID).

        Parameters
        ----------
        id : str

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

        Returns
        -------
        None

        Examples
        --------
        from planqk import PlanqkApi

        client = PlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )
        client.data_pools.delete_data_pool(
            id="id",
        )
        """
        _response = self._raw_client.delete_data_pool(id, request_options=request_options)
        return _response.data

    def get_data_pools(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[DataPoolDto]:
        """
        Get a list of all data pools for the current user.

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

        Returns
        -------
        typing.List[DataPoolDto]
            List of data pools

        Examples
        --------
        from planqk import PlanqkApi

        client = PlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )
        client.data_pools.get_data_pools()
        """
        _response = self._raw_client.get_data_pools(request_options=request_options)
        return _response.data

    def create_data_pool(
        self, *, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None
    ) -> DataPoolDto:
        """
        Create a new data pool.

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

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

        Returns
        -------
        DataPoolDto
            Data pool is created

        Examples
        --------
        from planqk import PlanqkApi

        client = PlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )
        client.data_pools.create_data_pool()
        """
        _response = self._raw_client.create_data_pool(name=name, request_options=request_options)
        return _response.data

    def get_data_pool_files(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[DataPoolFileDto]:
        """
        Get all files associated with a specific data pool (identified by its ID).

        Parameters
        ----------
        id : str

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

        Returns
        -------
        typing.List[DataPoolFileDto]
            List of files in the data pool

        Examples
        --------
        from planqk import PlanqkApi

        client = PlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )
        client.data_pools.get_data_pool_files(
            id="id",
        )
        """
        _response = self._raw_client.get_data_pool_files(id, request_options=request_options)
        return _response.data

    def add_data_pool_file(
        self,
        id: str,
        *,
        file: core.File,
        filename: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DataPoolFileDto:
        """
        Add a new file to a specific data pool (identified by its ID).

        Parameters
        ----------
        id : str

        file : core.File
            See core.File for more documentation

        filename : typing.Optional[str]

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

        Returns
        -------
        DataPoolFileDto
            File is added to the data pool

        Examples
        --------
        from planqk import PlanqkApi

        client = PlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )
        client.data_pools.add_data_pool_file(
            id="id",
        )
        """
        _response = self._raw_client.add_data_pool_file(
            id, file=file, filename=filename, request_options=request_options
        )
        return _response.data

    def get_data_pool_file(
        self, id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Iterator[bytes]:
        """
        Get the content of a specific file from a data pool (both file and data pool identified by their ID).

        Parameters
        ----------
        id : str

        file_id : str

        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]
            The file content
        """
        with self._raw_client.get_data_pool_file(id, file_id, request_options=request_options) as r:
            yield from r.data

    def delete_data_pool_file(
        self, id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a specific file from a data pool (both file and data pool identified by their IDs).

        Parameters
        ----------
        id : str

        file_id : str

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

        Returns
        -------
        None

        Examples
        --------
        from planqk import PlanqkApi

        client = PlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )
        client.data_pools.delete_data_pool_file(
            id="id",
            file_id="fileId",
        )
        """
        _response = self._raw_client.delete_data_pool_file(id, file_id, request_options=request_options)
        return _response.data


class AsyncDataPoolsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawDataPoolsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawDataPoolsClient
        """
        return self._raw_client

    async def get_data_pool(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DataPoolDto:
        """
        Get a specific data pool (identified by its ID).

        Parameters
        ----------
        id : str

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

        Returns
        -------
        DataPoolDto
            A data pool

        Examples
        --------
        import asyncio

        from planqk import AsyncPlanqkApi

        client = AsyncPlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.data_pools.get_data_pool(
                id="id",
            )


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

    async def update_data_pool(
        self,
        id: str,
        *,
        name: typing.Optional[str] = OMIT,
        short_description: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DataPoolDto:
        """
        Update an existing data pool (identified by its ID).

        Parameters
        ----------
        id : str

        name : typing.Optional[str]

        short_description : typing.Optional[str]

        description : typing.Optional[str]

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

        Returns
        -------
        DataPoolDto
            Data pool is saved

        Examples
        --------
        import asyncio

        from planqk import AsyncPlanqkApi

        client = AsyncPlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.data_pools.update_data_pool(
                id="id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_data_pool(
            id, name=name, short_description=short_description, description=description, request_options=request_options
        )
        return _response.data

    async def delete_data_pool(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a specific data pool (identified by its ID).

        Parameters
        ----------
        id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from planqk import AsyncPlanqkApi

        client = AsyncPlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.data_pools.delete_data_pool(
                id="id",
            )


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

    async def get_data_pools(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[DataPoolDto]:
        """
        Get a list of all data pools for the current user.

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

        Returns
        -------
        typing.List[DataPoolDto]
            List of data pools

        Examples
        --------
        import asyncio

        from planqk import AsyncPlanqkApi

        client = AsyncPlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.data_pools.get_data_pools()


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

    async def create_data_pool(
        self, *, name: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None
    ) -> DataPoolDto:
        """
        Create a new data pool.

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

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

        Returns
        -------
        DataPoolDto
            Data pool is created

        Examples
        --------
        import asyncio

        from planqk import AsyncPlanqkApi

        client = AsyncPlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.data_pools.create_data_pool()


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

    async def get_data_pool_files(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[DataPoolFileDto]:
        """
        Get all files associated with a specific data pool (identified by its ID).

        Parameters
        ----------
        id : str

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

        Returns
        -------
        typing.List[DataPoolFileDto]
            List of files in the data pool

        Examples
        --------
        import asyncio

        from planqk import AsyncPlanqkApi

        client = AsyncPlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.data_pools.get_data_pool_files(
                id="id",
            )


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

    async def add_data_pool_file(
        self,
        id: str,
        *,
        file: core.File,
        filename: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DataPoolFileDto:
        """
        Add a new file to a specific data pool (identified by its ID).

        Parameters
        ----------
        id : str

        file : core.File
            See core.File for more documentation

        filename : typing.Optional[str]

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

        Returns
        -------
        DataPoolFileDto
            File is added to the data pool

        Examples
        --------
        import asyncio

        from planqk import AsyncPlanqkApi

        client = AsyncPlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.data_pools.add_data_pool_file(
                id="id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.add_data_pool_file(
            id, file=file, filename=filename, request_options=request_options
        )
        return _response.data

    async def get_data_pool_file(
        self, id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.AsyncIterator[bytes]:
        """
        Get the content of a specific file from a data pool (both file and data pool identified by their ID).

        Parameters
        ----------
        id : str

        file_id : str

        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]
            The file content
        """
        async with self._raw_client.get_data_pool_file(id, file_id, request_options=request_options) as r:
            async for _chunk in r.data:
                yield _chunk

    async def delete_data_pool_file(
        self, id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete a specific file from a data pool (both file and data pool identified by their IDs).

        Parameters
        ----------
        id : str

        file_id : str

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from planqk import AsyncPlanqkApi

        client = AsyncPlanqkApi(
            organization_id="YOUR_ORGANIZATION_ID",
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.data_pools.delete_data_pool_file(
                id="id",
                file_id="fileId",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_data_pool_file(id, file_id, request_options=request_options)
        return _response.data
