# 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.redis_export_storage import RedisExportStorage
from .raw_client import AsyncRawRedisClient, RawRedisClient

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


class RedisClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawRedisClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawRedisClient
        """
        return self._raw_client

    def list(
        self,
        *,
        project: int,
        ordering: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[RedisExportStorage]:
        """
        Get a list of all Redis export storage connections.

        Parameters
        ----------
        project : int
            Project ID

        ordering : typing.Optional[str]
            Which field to use when ordering the results.

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

        Returns
        -------
        typing.List[RedisExportStorage]


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.export_storage.redis.list(
            project=1,
        )
        """
        _response = self._raw_client.list(project=project, ordering=ordering, request_options=request_options)
        return _response.data

    def create(
        self,
        *,
        can_delete_objects: typing.Optional[bool] = OMIT,
        db: typing.Optional[int] = OMIT,
        description: typing.Optional[str] = OMIT,
        host: typing.Optional[str] = OMIT,
        password: typing.Optional[str] = OMIT,
        path: typing.Optional[str] = OMIT,
        port: typing.Optional[str] = OMIT,
        project: typing.Optional[int] = OMIT,
        title: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RedisExportStorage:
        """
        Create a new Redis export storage connection to store annotations.

        Parameters
        ----------
        can_delete_objects : typing.Optional[bool]
            Deletion from storage enabled.

        db : typing.Optional[int]
            Database ID of database to use

        description : typing.Optional[str]
            Storage description

        host : typing.Optional[str]
            Server Host IP (optional)

        password : typing.Optional[str]
            Server Password (optional)

        path : typing.Optional[str]
            Storage prefix (optional)

        port : typing.Optional[str]
            Server Port (optional)

        project : typing.Optional[int]
            Project ID

        title : typing.Optional[str]
            Storage title

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

        Returns
        -------
        RedisExportStorage


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.export_storage.redis.create()
        """
        _response = self._raw_client.create(
            can_delete_objects=can_delete_objects,
            db=db,
            description=description,
            host=host,
            password=password,
            path=path,
            port=port,
            project=project,
            title=title,
            request_options=request_options,
        )
        return _response.data

    def validate(
        self,
        *,
        can_delete_objects: typing.Optional[bool] = OMIT,
        db: typing.Optional[int] = OMIT,
        description: typing.Optional[str] = OMIT,
        host: typing.Optional[str] = OMIT,
        id: typing.Optional[int] = OMIT,
        password: typing.Optional[str] = OMIT,
        path: typing.Optional[str] = OMIT,
        port: typing.Optional[str] = OMIT,
        project: typing.Optional[int] = OMIT,
        title: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Validate a specific Redis export storage connection.

        Parameters
        ----------
        can_delete_objects : typing.Optional[bool]
            Deletion from storage enabled.

        db : typing.Optional[int]
            Database ID of database to use

        description : typing.Optional[str]
            Storage description

        host : typing.Optional[str]
            Server Host IP (optional)

        id : typing.Optional[int]
            Storage ID. If set, storage with specified ID will be updated

        password : typing.Optional[str]
            Server Password (optional)

        path : typing.Optional[str]
            Storage prefix (optional)

        port : typing.Optional[str]
            Server Port (optional)

        project : typing.Optional[int]
            Project ID

        title : typing.Optional[str]
            Storage title

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

        Returns
        -------
        None

        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.export_storage.redis.validate()
        """
        _response = self._raw_client.validate(
            can_delete_objects=can_delete_objects,
            db=db,
            description=description,
            host=host,
            id=id,
            password=password,
            path=path,
            port=port,
            project=project,
            title=title,
            request_options=request_options,
        )
        return _response.data

    def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
        """
        Get a specific Redis export storage connection.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        RedisExportStorage


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.export_storage.redis.get(
            id=1,
        )
        """
        _response = self._raw_client.get(id, request_options=request_options)
        return _response.data

    def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a specific Redis export storage connection.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        None

        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.export_storage.redis.delete(
            id=1,
        )
        """
        _response = self._raw_client.delete(id, request_options=request_options)
        return _response.data

    def update(
        self,
        id: int,
        *,
        can_delete_objects: typing.Optional[bool] = OMIT,
        db: typing.Optional[int] = OMIT,
        description: typing.Optional[str] = OMIT,
        host: typing.Optional[str] = OMIT,
        password: typing.Optional[str] = OMIT,
        path: typing.Optional[str] = OMIT,
        port: typing.Optional[str] = OMIT,
        project: typing.Optional[int] = OMIT,
        title: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RedisExportStorage:
        """
        Update a specific Redis export storage connection.

        Parameters
        ----------
        id : int

        can_delete_objects : typing.Optional[bool]
            Deletion from storage enabled.

        db : typing.Optional[int]
            Database ID of database to use

        description : typing.Optional[str]
            Storage description

        host : typing.Optional[str]
            Server Host IP (optional)

        password : typing.Optional[str]
            Server Password (optional)

        path : typing.Optional[str]
            Storage prefix (optional)

        port : typing.Optional[str]
            Server Port (optional)

        project : typing.Optional[int]
            Project ID

        title : typing.Optional[str]
            Storage title

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

        Returns
        -------
        RedisExportStorage


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.export_storage.redis.update(
            id=1,
        )
        """
        _response = self._raw_client.update(
            id,
            can_delete_objects=can_delete_objects,
            db=db,
            description=description,
            host=host,
            password=password,
            path=path,
            port=port,
            project=project,
            title=title,
            request_options=request_options,
        )
        return _response.data

    def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
        """
        Sync tasks from a Redis export storage connection.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        RedisExportStorage


        Examples
        --------
        from label_studio_sdk import LabelStudio

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.export_storage.redis.sync(
            id=1,
        )
        """
        _response = self._raw_client.sync(id, request_options=request_options)
        return _response.data


class AsyncRedisClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawRedisClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawRedisClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        project: int,
        ordering: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[RedisExportStorage]:
        """
        Get a list of all Redis export storage connections.

        Parameters
        ----------
        project : int
            Project ID

        ordering : typing.Optional[str]
            Which field to use when ordering the results.

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

        Returns
        -------
        typing.List[RedisExportStorage]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.export_storage.redis.list(
                project=1,
            )


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

    async def create(
        self,
        *,
        can_delete_objects: typing.Optional[bool] = OMIT,
        db: typing.Optional[int] = OMIT,
        description: typing.Optional[str] = OMIT,
        host: typing.Optional[str] = OMIT,
        password: typing.Optional[str] = OMIT,
        path: typing.Optional[str] = OMIT,
        port: typing.Optional[str] = OMIT,
        project: typing.Optional[int] = OMIT,
        title: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RedisExportStorage:
        """
        Create a new Redis export storage connection to store annotations.

        Parameters
        ----------
        can_delete_objects : typing.Optional[bool]
            Deletion from storage enabled.

        db : typing.Optional[int]
            Database ID of database to use

        description : typing.Optional[str]
            Storage description

        host : typing.Optional[str]
            Server Host IP (optional)

        password : typing.Optional[str]
            Server Password (optional)

        path : typing.Optional[str]
            Storage prefix (optional)

        port : typing.Optional[str]
            Server Port (optional)

        project : typing.Optional[int]
            Project ID

        title : typing.Optional[str]
            Storage title

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

        Returns
        -------
        RedisExportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.export_storage.redis.create()


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            can_delete_objects=can_delete_objects,
            db=db,
            description=description,
            host=host,
            password=password,
            path=path,
            port=port,
            project=project,
            title=title,
            request_options=request_options,
        )
        return _response.data

    async def validate(
        self,
        *,
        can_delete_objects: typing.Optional[bool] = OMIT,
        db: typing.Optional[int] = OMIT,
        description: typing.Optional[str] = OMIT,
        host: typing.Optional[str] = OMIT,
        id: typing.Optional[int] = OMIT,
        password: typing.Optional[str] = OMIT,
        path: typing.Optional[str] = OMIT,
        port: typing.Optional[str] = OMIT,
        project: typing.Optional[int] = OMIT,
        title: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Validate a specific Redis export storage connection.

        Parameters
        ----------
        can_delete_objects : typing.Optional[bool]
            Deletion from storage enabled.

        db : typing.Optional[int]
            Database ID of database to use

        description : typing.Optional[str]
            Storage description

        host : typing.Optional[str]
            Server Host IP (optional)

        id : typing.Optional[int]
            Storage ID. If set, storage with specified ID will be updated

        password : typing.Optional[str]
            Server Password (optional)

        path : typing.Optional[str]
            Storage prefix (optional)

        port : typing.Optional[str]
            Server Port (optional)

        project : typing.Optional[int]
            Project ID

        title : typing.Optional[str]
            Storage title

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.export_storage.redis.validate()


        asyncio.run(main())
        """
        _response = await self._raw_client.validate(
            can_delete_objects=can_delete_objects,
            db=db,
            description=description,
            host=host,
            id=id,
            password=password,
            path=path,
            port=port,
            project=project,
            title=title,
            request_options=request_options,
        )
        return _response.data

    async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
        """
        Get a specific Redis export storage connection.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        RedisExportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.export_storage.redis.get(
                id=1,
            )


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

    async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a specific Redis export storage connection.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.export_storage.redis.delete(
                id=1,
            )


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

    async def update(
        self,
        id: int,
        *,
        can_delete_objects: typing.Optional[bool] = OMIT,
        db: typing.Optional[int] = OMIT,
        description: typing.Optional[str] = OMIT,
        host: typing.Optional[str] = OMIT,
        password: typing.Optional[str] = OMIT,
        path: typing.Optional[str] = OMIT,
        port: typing.Optional[str] = OMIT,
        project: typing.Optional[int] = OMIT,
        title: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RedisExportStorage:
        """
        Update a specific Redis export storage connection.

        Parameters
        ----------
        id : int

        can_delete_objects : typing.Optional[bool]
            Deletion from storage enabled.

        db : typing.Optional[int]
            Database ID of database to use

        description : typing.Optional[str]
            Storage description

        host : typing.Optional[str]
            Server Host IP (optional)

        password : typing.Optional[str]
            Server Password (optional)

        path : typing.Optional[str]
            Storage prefix (optional)

        port : typing.Optional[str]
            Server Port (optional)

        project : typing.Optional[int]
            Project ID

        title : typing.Optional[str]
            Storage title

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

        Returns
        -------
        RedisExportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.export_storage.redis.update(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            id,
            can_delete_objects=can_delete_objects,
            db=db,
            description=description,
            host=host,
            password=password,
            path=path,
            port=port,
            project=project,
            title=title,
            request_options=request_options,
        )
        return _response.data

    async def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
        """
        Sync tasks from a Redis export storage connection.

        Parameters
        ----------
        id : int

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

        Returns
        -------
        RedisExportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.export_storage.redis.sync(
                id=1,
            )


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