# 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.schema_response import SchemaResponse
from ..types.src_app_http_routes_collection_create_table_response import SrcAppHttpRoutesCollectionCreateTableResponse
from ..types.src_app_http_routes_collection_delete_table_response import SrcAppHttpRoutesCollectionDeleteTableResponse
from ..types.src_app_http_routes_collection_get_table_response import SrcAppHttpRoutesCollectionGetTableResponse
from ..types.src_app_http_routes_collection_get_tables_response import SrcAppHttpRoutesCollectionGetTablesResponse
from ..types.src_app_http_routes_collection_sync_table_response import SrcAppHttpRoutesCollectionSyncTableResponse
from ..types.src_app_http_routes_collection_update_table_response import SrcAppHttpRoutesCollectionUpdateTableResponse
from .raw_client import AsyncRawTablesClient, RawTablesClient
from .types.table_config_input_schema_item import TableConfigInputSchemaItem
from .types.table_data_schema_item import TableDataSchemaItem

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


class TablesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTablesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawTablesClient
        """
        return self._raw_client

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

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

        Returns
        -------
        SrcAppHttpRoutesCollectionGetTablesResponse
            Successful Response

        Examples
        --------
        from scoutos import Scout

        client = Scout(
            api_key="YOUR_API_KEY",
        )
        client.tables.list(
            collection_id="collection_id",
        )
        """
        _response = self._raw_client.list(collection_id, request_options=request_options)
        return _response.data

    def create(
        self,
        collection_id: str,
        *,
        table_display_name: typing.Optional[str] = OMIT,
        table_img_url: typing.Optional[str] = OMIT,
        table_description: typing.Optional[str] = OMIT,
        schema: typing.Optional[typing.Sequence[TableConfigInputSchemaItem]] = OMIT,
        icon_emoji: typing.Optional[str] = OMIT,
        icon_asset_url: typing.Optional[str] = OMIT,
        icon_fill: typing.Optional[str] = OMIT,
        singular_name: typing.Optional[str] = OMIT,
        plural_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SrcAppHttpRoutesCollectionCreateTableResponse:
        """
        Parameters
        ----------
        collection_id : str

        table_display_name : typing.Optional[str]

        table_img_url : typing.Optional[str]

        table_description : typing.Optional[str]

        schema : typing.Optional[typing.Sequence[TableConfigInputSchemaItem]]

        icon_emoji : typing.Optional[str]

        icon_asset_url : typing.Optional[str]

        icon_fill : typing.Optional[str]

        singular_name : typing.Optional[str]

        plural_name : typing.Optional[str]

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

        Returns
        -------
        SrcAppHttpRoutesCollectionCreateTableResponse
            Successful Response

        Examples
        --------
        from scoutos import Scout

        client = Scout(
            api_key="YOUR_API_KEY",
        )
        client.tables.create(
            collection_id="collection_id",
        )
        """
        _response = self._raw_client.create(
            collection_id,
            table_display_name=table_display_name,
            table_img_url=table_img_url,
            table_description=table_description,
            schema=schema,
            icon_emoji=icon_emoji,
            icon_asset_url=icon_asset_url,
            icon_fill=icon_fill,
            singular_name=singular_name,
            plural_name=plural_name,
            request_options=request_options,
        )
        return _response.data

    def get(
        self, collection_id: str, table_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SrcAppHttpRoutesCollectionGetTableResponse:
        """
        Parameters
        ----------
        collection_id : str

        table_id : str

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

        Returns
        -------
        SrcAppHttpRoutesCollectionGetTableResponse
            Successful Response

        Examples
        --------
        from scoutos import Scout

        client = Scout(
            api_key="YOUR_API_KEY",
        )
        client.tables.get(
            collection_id="collection_id",
            table_id="table_id",
        )
        """
        _response = self._raw_client.get(collection_id, table_id, request_options=request_options)
        return _response.data

    def update(
        self,
        collection_id: str,
        table_id: str,
        *,
        table_display_name: typing.Optional[str] = OMIT,
        table_img_url: typing.Optional[str] = OMIT,
        table_description: typing.Optional[str] = OMIT,
        schema: typing.Optional[typing.Sequence[TableDataSchemaItem]] = OMIT,
        icon_emoji: typing.Optional[str] = OMIT,
        icon_asset_url: typing.Optional[str] = OMIT,
        icon_fill: typing.Optional[str] = OMIT,
        singular_name: typing.Optional[str] = OMIT,
        plural_name: typing.Optional[str] = OMIT,
        index_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SrcAppHttpRoutesCollectionUpdateTableResponse:
        """
        Parameters
        ----------
        collection_id : str

        table_id : str

        table_display_name : typing.Optional[str]

        table_img_url : typing.Optional[str]

        table_description : typing.Optional[str]

        schema : typing.Optional[typing.Sequence[TableDataSchemaItem]]

        icon_emoji : typing.Optional[str]

        icon_asset_url : typing.Optional[str]

        icon_fill : typing.Optional[str]

        singular_name : typing.Optional[str]

        plural_name : typing.Optional[str]

        index_id : typing.Optional[str]

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

        Returns
        -------
        SrcAppHttpRoutesCollectionUpdateTableResponse
            Successful Response

        Examples
        --------
        from scoutos import Scout

        client = Scout(
            api_key="YOUR_API_KEY",
        )
        client.tables.update(
            collection_id="collection_id",
            table_id="table_id",
        )
        """
        _response = self._raw_client.update(
            collection_id,
            table_id,
            table_display_name=table_display_name,
            table_img_url=table_img_url,
            table_description=table_description,
            schema=schema,
            icon_emoji=icon_emoji,
            icon_asset_url=icon_asset_url,
            icon_fill=icon_fill,
            singular_name=singular_name,
            plural_name=plural_name,
            index_id=index_id,
            request_options=request_options,
        )
        return _response.data

    def delete(
        self, collection_id: str, table_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SrcAppHttpRoutesCollectionDeleteTableResponse:
        """
        Delete a table given a collection_id and table_id.

        Parameters
        ----------
        collection_id : str

        table_id : str

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

        Returns
        -------
        SrcAppHttpRoutesCollectionDeleteTableResponse
            Successful Response

        Examples
        --------
        from scoutos import Scout

        client = Scout(
            api_key="YOUR_API_KEY",
        )
        client.tables.delete(
            collection_id="collection_id",
            table_id="table_id",
        )
        """
        _response = self._raw_client.delete(collection_id, table_id, request_options=request_options)
        return _response.data

    def get_schema(
        self, collection_id: str, table_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SchemaResponse:
        """
        Parameters
        ----------
        collection_id : str

        table_id : str

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

        Returns
        -------
        SchemaResponse
            Successful Response

        Examples
        --------
        from scoutos import Scout

        client = Scout(
            api_key="YOUR_API_KEY",
        )
        client.tables.get_schema(
            collection_id="collection_id",
            table_id="table_id",
        )
        """
        _response = self._raw_client.get_schema(collection_id, table_id, request_options=request_options)
        return _response.data

    def sync(
        self,
        collection_id: str,
        table_id: str,
        *,
        request: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SrcAppHttpRoutesCollectionSyncTableResponse:
        """
        Sync a table with a list of documents.

        Parameters
        ----------
        collection_id : str

        table_id : str

        request : typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]

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

        Returns
        -------
        SrcAppHttpRoutesCollectionSyncTableResponse
            Successful Response

        Examples
        --------
        from scoutos import Scout

        client = Scout(
            api_key="YOUR_API_KEY",
        )
        client.tables.sync(
            collection_id="collection_id",
            table_id="table_id",
            request=[{"key": "value"}],
        )
        """
        _response = self._raw_client.sync(collection_id, table_id, request=request, request_options=request_options)
        return _response.data


class AsyncTablesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTablesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawTablesClient
        """
        return self._raw_client

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

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

        Returns
        -------
        SrcAppHttpRoutesCollectionGetTablesResponse
            Successful Response

        Examples
        --------
        import asyncio

        from scoutos import AsyncScout

        client = AsyncScout(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tables.list(
                collection_id="collection_id",
            )


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

    async def create(
        self,
        collection_id: str,
        *,
        table_display_name: typing.Optional[str] = OMIT,
        table_img_url: typing.Optional[str] = OMIT,
        table_description: typing.Optional[str] = OMIT,
        schema: typing.Optional[typing.Sequence[TableConfigInputSchemaItem]] = OMIT,
        icon_emoji: typing.Optional[str] = OMIT,
        icon_asset_url: typing.Optional[str] = OMIT,
        icon_fill: typing.Optional[str] = OMIT,
        singular_name: typing.Optional[str] = OMIT,
        plural_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SrcAppHttpRoutesCollectionCreateTableResponse:
        """
        Parameters
        ----------
        collection_id : str

        table_display_name : typing.Optional[str]

        table_img_url : typing.Optional[str]

        table_description : typing.Optional[str]

        schema : typing.Optional[typing.Sequence[TableConfigInputSchemaItem]]

        icon_emoji : typing.Optional[str]

        icon_asset_url : typing.Optional[str]

        icon_fill : typing.Optional[str]

        singular_name : typing.Optional[str]

        plural_name : typing.Optional[str]

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

        Returns
        -------
        SrcAppHttpRoutesCollectionCreateTableResponse
            Successful Response

        Examples
        --------
        import asyncio

        from scoutos import AsyncScout

        client = AsyncScout(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tables.create(
                collection_id="collection_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            collection_id,
            table_display_name=table_display_name,
            table_img_url=table_img_url,
            table_description=table_description,
            schema=schema,
            icon_emoji=icon_emoji,
            icon_asset_url=icon_asset_url,
            icon_fill=icon_fill,
            singular_name=singular_name,
            plural_name=plural_name,
            request_options=request_options,
        )
        return _response.data

    async def get(
        self, collection_id: str, table_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SrcAppHttpRoutesCollectionGetTableResponse:
        """
        Parameters
        ----------
        collection_id : str

        table_id : str

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

        Returns
        -------
        SrcAppHttpRoutesCollectionGetTableResponse
            Successful Response

        Examples
        --------
        import asyncio

        from scoutos import AsyncScout

        client = AsyncScout(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tables.get(
                collection_id="collection_id",
                table_id="table_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get(collection_id, table_id, request_options=request_options)
        return _response.data

    async def update(
        self,
        collection_id: str,
        table_id: str,
        *,
        table_display_name: typing.Optional[str] = OMIT,
        table_img_url: typing.Optional[str] = OMIT,
        table_description: typing.Optional[str] = OMIT,
        schema: typing.Optional[typing.Sequence[TableDataSchemaItem]] = OMIT,
        icon_emoji: typing.Optional[str] = OMIT,
        icon_asset_url: typing.Optional[str] = OMIT,
        icon_fill: typing.Optional[str] = OMIT,
        singular_name: typing.Optional[str] = OMIT,
        plural_name: typing.Optional[str] = OMIT,
        index_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SrcAppHttpRoutesCollectionUpdateTableResponse:
        """
        Parameters
        ----------
        collection_id : str

        table_id : str

        table_display_name : typing.Optional[str]

        table_img_url : typing.Optional[str]

        table_description : typing.Optional[str]

        schema : typing.Optional[typing.Sequence[TableDataSchemaItem]]

        icon_emoji : typing.Optional[str]

        icon_asset_url : typing.Optional[str]

        icon_fill : typing.Optional[str]

        singular_name : typing.Optional[str]

        plural_name : typing.Optional[str]

        index_id : typing.Optional[str]

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

        Returns
        -------
        SrcAppHttpRoutesCollectionUpdateTableResponse
            Successful Response

        Examples
        --------
        import asyncio

        from scoutos import AsyncScout

        client = AsyncScout(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tables.update(
                collection_id="collection_id",
                table_id="table_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            collection_id,
            table_id,
            table_display_name=table_display_name,
            table_img_url=table_img_url,
            table_description=table_description,
            schema=schema,
            icon_emoji=icon_emoji,
            icon_asset_url=icon_asset_url,
            icon_fill=icon_fill,
            singular_name=singular_name,
            plural_name=plural_name,
            index_id=index_id,
            request_options=request_options,
        )
        return _response.data

    async def delete(
        self, collection_id: str, table_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SrcAppHttpRoutesCollectionDeleteTableResponse:
        """
        Delete a table given a collection_id and table_id.

        Parameters
        ----------
        collection_id : str

        table_id : str

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

        Returns
        -------
        SrcAppHttpRoutesCollectionDeleteTableResponse
            Successful Response

        Examples
        --------
        import asyncio

        from scoutos import AsyncScout

        client = AsyncScout(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tables.delete(
                collection_id="collection_id",
                table_id="table_id",
            )


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

    async def get_schema(
        self, collection_id: str, table_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SchemaResponse:
        """
        Parameters
        ----------
        collection_id : str

        table_id : str

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

        Returns
        -------
        SchemaResponse
            Successful Response

        Examples
        --------
        import asyncio

        from scoutos import AsyncScout

        client = AsyncScout(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tables.get_schema(
                collection_id="collection_id",
                table_id="table_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_schema(collection_id, table_id, request_options=request_options)
        return _response.data

    async def sync(
        self,
        collection_id: str,
        table_id: str,
        *,
        request: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SrcAppHttpRoutesCollectionSyncTableResponse:
        """
        Sync a table with a list of documents.

        Parameters
        ----------
        collection_id : str

        table_id : str

        request : typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]

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

        Returns
        -------
        SrcAppHttpRoutesCollectionSyncTableResponse
            Successful Response

        Examples
        --------
        import asyncio

        from scoutos import AsyncScout

        client = AsyncScout(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tables.sync(
                collection_id="collection_id",
                table_id="table_id",
                request=[{"key": "value"}],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.sync(
            collection_id, table_id, request=request, request_options=request_options
        )
        return _response.data
