# 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.gcs_import_storage import GcsImportStorage
from .raw_client import AsyncRawGcsClient, RawGcsClient

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


class GcsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawGcsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawGcsClient
        """
        return self._raw_client

    def list(
        self,
        *,
        project: int,
        ordering: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[GcsImportStorage]:
        """
        Get a list of all GCS import 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[GcsImportStorage]


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

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

    def create(
        self,
        *,
        bucket: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        prefix: typing.Optional[str] = OMIT,
        presign: typing.Optional[bool] = OMIT,
        presign_ttl: typing.Optional[int] = OMIT,
        project: typing.Optional[int] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        use_blob_urls: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GcsImportStorage:
        """
        Create a new GCS import storage connection.

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

        description : typing.Optional[str]
            Storage description

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.

        google_project_id : typing.Optional[str]
            Google project ID

        prefix : typing.Optional[str]
            GCS bucket prefix

        presign : typing.Optional[bool]
            Presign URLs for direct download

        presign_ttl : typing.Optional[int]
            Presign TTL in minutes

        project : typing.Optional[int]
            Project ID

        regex_filter : typing.Optional[str]
            Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.

        title : typing.Optional[str]
            Storage title

        use_blob_urls : typing.Optional[bool]
            Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.

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

        Returns
        -------
        GcsImportStorage


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.import_storage.gcs.create()
        """
        _response = self._raw_client.create(
            bucket=bucket,
            description=description,
            google_application_credentials=google_application_credentials,
            google_project_id=google_project_id,
            prefix=prefix,
            presign=presign,
            presign_ttl=presign_ttl,
            project=project,
            regex_filter=regex_filter,
            title=title,
            use_blob_urls=use_blob_urls,
            request_options=request_options,
        )
        return _response.data

    def validate(
        self,
        *,
        bucket: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        id: typing.Optional[int] = OMIT,
        prefix: typing.Optional[str] = OMIT,
        presign: typing.Optional[bool] = OMIT,
        presign_ttl: typing.Optional[int] = OMIT,
        project: typing.Optional[int] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        use_blob_urls: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Validate a specific GCS import storage connection.

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

        description : typing.Optional[str]
            Storage description

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.

        google_project_id : typing.Optional[str]
            Google project ID

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

        prefix : typing.Optional[str]
            GCS bucket prefix

        presign : typing.Optional[bool]
            Presign URLs for direct download

        presign_ttl : typing.Optional[int]
            Presign TTL in minutes

        project : typing.Optional[int]
            Project ID

        regex_filter : typing.Optional[str]
            Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.

        title : typing.Optional[str]
            Storage title

        use_blob_urls : typing.Optional[bool]
            Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.

        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.import_storage.gcs.validate()
        """
        _response = self._raw_client.validate(
            bucket=bucket,
            description=description,
            google_application_credentials=google_application_credentials,
            google_project_id=google_project_id,
            id=id,
            prefix=prefix,
            presign=presign,
            presign_ttl=presign_ttl,
            project=project,
            regex_filter=regex_filter,
            title=title,
            use_blob_urls=use_blob_urls,
            request_options=request_options,
        )
        return _response.data

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

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

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

        Returns
        -------
        GcsImportStorage


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.import_storage.gcs.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 GCS import 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.import_storage.gcs.delete(
            id=1,
        )
        """
        _response = self._raw_client.delete(id, request_options=request_options)
        return _response.data

    def update(
        self,
        id: int,
        *,
        bucket: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        prefix: typing.Optional[str] = OMIT,
        presign: typing.Optional[bool] = OMIT,
        presign_ttl: typing.Optional[int] = OMIT,
        project: typing.Optional[int] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        use_blob_urls: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GcsImportStorage:
        """
        Update a specific GCS import storage connection.

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

        bucket : typing.Optional[str]
            GCS bucket name

        description : typing.Optional[str]
            Storage description

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.

        google_project_id : typing.Optional[str]
            Google project ID

        prefix : typing.Optional[str]
            GCS bucket prefix

        presign : typing.Optional[bool]
            Presign URLs for direct download

        presign_ttl : typing.Optional[int]
            Presign TTL in minutes

        project : typing.Optional[int]
            Project ID

        regex_filter : typing.Optional[str]
            Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.

        title : typing.Optional[str]
            Storage title

        use_blob_urls : typing.Optional[bool]
            Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.

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

        Returns
        -------
        GcsImportStorage


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.import_storage.gcs.update(
            id=1,
        )
        """
        _response = self._raw_client.update(
            id,
            bucket=bucket,
            description=description,
            google_application_credentials=google_application_credentials,
            google_project_id=google_project_id,
            prefix=prefix,
            presign=presign,
            presign_ttl=presign_ttl,
            project=project,
            regex_filter=regex_filter,
            title=title,
            use_blob_urls=use_blob_urls,
            request_options=request_options,
        )
        return _response.data

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

        Parameters
        ----------
        id : int
            Storage ID

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

        Returns
        -------
        GcsImportStorage


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

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


class AsyncGcsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawGcsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawGcsClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        project: int,
        ordering: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[GcsImportStorage]:
        """
        Get a list of all GCS import 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[GcsImportStorage]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.import_storage.gcs.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,
        *,
        bucket: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        prefix: typing.Optional[str] = OMIT,
        presign: typing.Optional[bool] = OMIT,
        presign_ttl: typing.Optional[int] = OMIT,
        project: typing.Optional[int] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        use_blob_urls: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GcsImportStorage:
        """
        Create a new GCS import storage connection.

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

        description : typing.Optional[str]
            Storage description

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.

        google_project_id : typing.Optional[str]
            Google project ID

        prefix : typing.Optional[str]
            GCS bucket prefix

        presign : typing.Optional[bool]
            Presign URLs for direct download

        presign_ttl : typing.Optional[int]
            Presign TTL in minutes

        project : typing.Optional[int]
            Project ID

        regex_filter : typing.Optional[str]
            Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.

        title : typing.Optional[str]
            Storage title

        use_blob_urls : typing.Optional[bool]
            Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.

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

        Returns
        -------
        GcsImportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.import_storage.gcs.create()


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            bucket=bucket,
            description=description,
            google_application_credentials=google_application_credentials,
            google_project_id=google_project_id,
            prefix=prefix,
            presign=presign,
            presign_ttl=presign_ttl,
            project=project,
            regex_filter=regex_filter,
            title=title,
            use_blob_urls=use_blob_urls,
            request_options=request_options,
        )
        return _response.data

    async def validate(
        self,
        *,
        bucket: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        id: typing.Optional[int] = OMIT,
        prefix: typing.Optional[str] = OMIT,
        presign: typing.Optional[bool] = OMIT,
        presign_ttl: typing.Optional[int] = OMIT,
        project: typing.Optional[int] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        use_blob_urls: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> None:
        """
        Validate a specific GCS import storage connection.

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

        description : typing.Optional[str]
            Storage description

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.

        google_project_id : typing.Optional[str]
            Google project ID

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

        prefix : typing.Optional[str]
            GCS bucket prefix

        presign : typing.Optional[bool]
            Presign URLs for direct download

        presign_ttl : typing.Optional[int]
            Presign TTL in minutes

        project : typing.Optional[int]
            Project ID

        regex_filter : typing.Optional[str]
            Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.

        title : typing.Optional[str]
            Storage title

        use_blob_urls : typing.Optional[bool]
            Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.

        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.import_storage.gcs.validate()


        asyncio.run(main())
        """
        _response = await self._raw_client.validate(
            bucket=bucket,
            description=description,
            google_application_credentials=google_application_credentials,
            google_project_id=google_project_id,
            id=id,
            prefix=prefix,
            presign=presign,
            presign_ttl=presign_ttl,
            project=project,
            regex_filter=regex_filter,
            title=title,
            use_blob_urls=use_blob_urls,
            request_options=request_options,
        )
        return _response.data

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

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

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

        Returns
        -------
        GcsImportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.import_storage.gcs.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 GCS import 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.import_storage.gcs.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,
        *,
        bucket: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        google_application_credentials: typing.Optional[str] = OMIT,
        google_project_id: typing.Optional[str] = OMIT,
        prefix: typing.Optional[str] = OMIT,
        presign: typing.Optional[bool] = OMIT,
        presign_ttl: typing.Optional[int] = OMIT,
        project: typing.Optional[int] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        use_blob_urls: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> GcsImportStorage:
        """
        Update a specific GCS import storage connection.

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

        bucket : typing.Optional[str]
            GCS bucket name

        description : typing.Optional[str]
            Storage description

        google_application_credentials : typing.Optional[str]
            The content of GOOGLE_APPLICATION_CREDENTIALS json file. Check official Google Cloud Authentication documentation for more details.

        google_project_id : typing.Optional[str]
            Google project ID

        prefix : typing.Optional[str]
            GCS bucket prefix

        presign : typing.Optional[bool]
            Presign URLs for direct download

        presign_ttl : typing.Optional[int]
            Presign TTL in minutes

        project : typing.Optional[int]
            Project ID

        regex_filter : typing.Optional[str]
            Cloud storage regex for filtering objects. You must specify it otherwise no objects will be imported.

        title : typing.Optional[str]
            Storage title

        use_blob_urls : typing.Optional[bool]
            Interpret objects as BLOBs and generate URLs. For example, if your bucket contains images, you can use this option to generate URLs for these images. If set to False, it will read the content of the file and load it into Label Studio.

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

        Returns
        -------
        GcsImportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            id,
            bucket=bucket,
            description=description,
            google_application_credentials=google_application_credentials,
            google_project_id=google_project_id,
            prefix=prefix,
            presign=presign,
            presign_ttl=presign_ttl,
            project=project,
            regex_filter=regex_filter,
            title=title,
            use_blob_urls=use_blob_urls,
            request_options=request_options,
        )
        return _response.data

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

        Parameters
        ----------
        id : int
            Storage ID

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

        Returns
        -------
        GcsImportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


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