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

import typing
from json.decoder import JSONDecodeError

from ...core.api_error import ApiError
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.http_response import AsyncHttpResponse, HttpResponse
from ...core.jsonable_encoder import jsonable_encoder
from ...core.request_options import RequestOptions
from ...core.unchecked_base_model import construct_type
from ...types.gcs_import_storage import GcsImportStorage

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


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

    def list(
        self,
        *,
        project: int,
        ordering: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[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
        -------
        HttpResponse[typing.List[GcsImportStorage]]

        """
        _response = self._client_wrapper.httpx_client.request(
            "api/storages/gcs/",
            method="GET",
            params={
                "ordering": ordering,
                "project": project,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[GcsImportStorage],
                    construct_type(
                        type_=typing.List[GcsImportStorage],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> HttpResponse[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
        -------
        HttpResponse[GcsImportStorage]

        """
        _response = self._client_wrapper.httpx_client.request(
            "api/storages/gcs/",
            method="POST",
            json={
                "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,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GcsImportStorage,
                    construct_type(
                        type_=GcsImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> HttpResponse[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
        -------
        HttpResponse[None]
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/storages/gcs/validate",
            method="POST",
            json={
                "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,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return HttpResponse(response=_response, data=None)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

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

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

        Returns
        -------
        HttpResponse[GcsImportStorage]

        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/storages/gcs/{jsonable_encoder(id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GcsImportStorage,
                    construct_type(
                        type_=GcsImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

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

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

        Returns
        -------
        HttpResponse[None]
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/storages/gcs/{jsonable_encoder(id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return HttpResponse(response=_response, data=None)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> HttpResponse[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
        -------
        HttpResponse[GcsImportStorage]

        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/storages/gcs/{jsonable_encoder(id)}",
            method="PATCH",
            json={
                "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,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GcsImportStorage,
                    construct_type(
                        type_=GcsImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

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

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

        Returns
        -------
        HttpResponse[GcsImportStorage]

        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/storages/gcs/{jsonable_encoder(id)}/sync",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GcsImportStorage,
                    construct_type(
                        type_=GcsImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


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

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

        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/storages/gcs/",
            method="GET",
            params={
                "ordering": ordering,
                "project": project,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    typing.List[GcsImportStorage],
                    construct_type(
                        type_=typing.List[GcsImportStorage],  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[GcsImportStorage]

        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/storages/gcs/",
            method="POST",
            json={
                "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,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GcsImportStorage,
                    construct_type(
                        type_=GcsImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[None]
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/storages/gcs/validate",
            method="POST",
            json={
                "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,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return AsyncHttpResponse(response=_response, data=None)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

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

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

        Returns
        -------
        AsyncHttpResponse[GcsImportStorage]

        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/storages/gcs/{jsonable_encoder(id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GcsImportStorage,
                    construct_type(
                        type_=GcsImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

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

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

        Returns
        -------
        AsyncHttpResponse[None]
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/storages/gcs/{jsonable_encoder(id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return AsyncHttpResponse(response=_response, data=None)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    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,
    ) -> AsyncHttpResponse[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
        -------
        AsyncHttpResponse[GcsImportStorage]

        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/storages/gcs/{jsonable_encoder(id)}",
            method="PATCH",
            json={
                "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,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GcsImportStorage,
                    construct_type(
                        type_=GcsImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

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

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

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

        Returns
        -------
        AsyncHttpResponse[GcsImportStorage]

        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/storages/gcs/{jsonable_encoder(id)}/sync",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GcsImportStorage,
                    construct_type(
                        type_=GcsImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
