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

import typing
from ...core.client_wrapper import SyncClientWrapper
from ...core.request_options import RequestOptions
from ...types.s3import_storage import S3ImportStorage
from ...core.unchecked_base_model import construct_type
from json.decoder import JSONDecodeError
from ...core.api_error import ApiError
from ...core.jsonable_encoder import jsonable_encoder
from ...core.client_wrapper import AsyncClientWrapper

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


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

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

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

        project : typing.Optional[int]
            Project ID

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

        Returns
        -------
        typing.List[S3ImportStorage]


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.import_storage.s3.list()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/storages/s3/",
            method="GET",
            params={
                "ordering": ordering,
                "project": project,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[S3ImportStorage],
                    construct_type(
                        type_=typing.List[S3ImportStorage],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def create(
        self,
        *,
        aws_access_key_id: typing.Optional[str] = OMIT,
        aws_secret_access_key: typing.Optional[str] = OMIT,
        aws_session_token: typing.Optional[str] = OMIT,
        aws_sse_kms_key_id: typing.Optional[str] = OMIT,
        bucket: typing.Optional[str] = OMIT,
        description: 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,
        recursive_scan: typing.Optional[bool] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        region_name: typing.Optional[str] = OMIT,
        s3endpoint: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        use_blob_urls: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> S3ImportStorage:
        """
        Create new S3 import storage

        Parameters
        ----------
        aws_access_key_id : typing.Optional[str]
            AWS_ACCESS_KEY_ID

        aws_secret_access_key : typing.Optional[str]
            AWS_SECRET_ACCESS_KEY

        aws_session_token : typing.Optional[str]
            AWS_SESSION_TOKEN

        aws_sse_kms_key_id : typing.Optional[str]
            AWS SSE KMS Key ID

        bucket : typing.Optional[str]
            S3 bucket name

        description : typing.Optional[str]
            Storage description

        prefix : typing.Optional[str]
            S3 bucket prefix

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

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

        project : typing.Optional[int]
            Project ID

        recursive_scan : typing.Optional[bool]
            Scan recursively

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

        region_name : typing.Optional[str]
            AWS Region

        s3endpoint : typing.Optional[str]
            S3 Endpoint

        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
        -------
        S3ImportStorage


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.import_storage.s3.create()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/storages/s3/",
            method="POST",
            json={
                "aws_access_key_id": aws_access_key_id,
                "aws_secret_access_key": aws_secret_access_key,
                "aws_session_token": aws_session_token,
                "aws_sse_kms_key_id": aws_sse_kms_key_id,
                "bucket": bucket,
                "description": description,
                "prefix": prefix,
                "presign": presign,
                "presign_ttl": presign_ttl,
                "project": project,
                "recursive_scan": recursive_scan,
                "regex_filter": regex_filter,
                "region_name": region_name,
                "s3_endpoint": s3endpoint,
                "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 typing.cast(
                    S3ImportStorage,
                    construct_type(
                        type_=S3ImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def validate(
        self,
        *,
        aws_access_key_id: typing.Optional[str] = OMIT,
        aws_secret_access_key: typing.Optional[str] = OMIT,
        aws_session_token: typing.Optional[str] = OMIT,
        aws_sse_kms_key_id: typing.Optional[str] = OMIT,
        bucket: typing.Optional[str] = OMIT,
        description: 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,
        recursive_scan: typing.Optional[bool] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        region_name: typing.Optional[str] = OMIT,
        s3endpoint: 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 S3 import storage connection.

        Parameters
        ----------
        aws_access_key_id : typing.Optional[str]
            AWS_ACCESS_KEY_ID

        aws_secret_access_key : typing.Optional[str]
            AWS_SECRET_ACCESS_KEY

        aws_session_token : typing.Optional[str]
            AWS_SESSION_TOKEN

        aws_sse_kms_key_id : typing.Optional[str]
            AWS SSE KMS Key ID

        bucket : typing.Optional[str]
            S3 bucket name

        description : typing.Optional[str]
            Storage description

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

        prefix : typing.Optional[str]
            S3 bucket prefix

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

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

        project : typing.Optional[int]
            Project ID

        recursive_scan : typing.Optional[bool]
            Scan recursively

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

        region_name : typing.Optional[str]
            AWS Region

        s3endpoint : typing.Optional[str]
            S3 Endpoint

        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.s3.validate()
        """
        _response = self._client_wrapper.httpx_client.request(
            "api/storages/s3/validate",
            method="POST",
            json={
                "aws_access_key_id": aws_access_key_id,
                "aws_secret_access_key": aws_secret_access_key,
                "aws_session_token": aws_session_token,
                "aws_sse_kms_key_id": aws_sse_kms_key_id,
                "bucket": bucket,
                "description": description,
                "id": id,
                "prefix": prefix,
                "presign": presign,
                "presign_ttl": presign_ttl,
                "project": project,
                "recursive_scan": recursive_scan,
                "regex_filter": regex_filter,
                "region_name": region_name,
                "s3_endpoint": s3endpoint,
                "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
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

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

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

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

        Returns
        -------
        S3ImportStorage


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.import_storage.s3.get(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/storages/s3/{jsonable_encoder(id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    S3ImportStorage,
                    construct_type(
                        type_=S3ImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a specific S3 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.s3.delete(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/storages/s3/{jsonable_encoder(id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def update(
        self,
        id: int,
        *,
        aws_access_key_id: typing.Optional[str] = OMIT,
        aws_secret_access_key: typing.Optional[str] = OMIT,
        aws_session_token: typing.Optional[str] = OMIT,
        aws_sse_kms_key_id: typing.Optional[str] = OMIT,
        bucket: typing.Optional[str] = OMIT,
        description: 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,
        recursive_scan: typing.Optional[bool] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        region_name: typing.Optional[str] = OMIT,
        s3endpoint: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        use_blob_urls: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> S3ImportStorage:
        """
        Update a specific S3 import storage connection.

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

        aws_access_key_id : typing.Optional[str]
            AWS_ACCESS_KEY_ID

        aws_secret_access_key : typing.Optional[str]
            AWS_SECRET_ACCESS_KEY

        aws_session_token : typing.Optional[str]
            AWS_SESSION_TOKEN

        aws_sse_kms_key_id : typing.Optional[str]
            AWS SSE KMS Key ID

        bucket : typing.Optional[str]
            S3 bucket name

        description : typing.Optional[str]
            Storage description

        prefix : typing.Optional[str]
            S3 bucket prefix

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

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

        project : typing.Optional[int]
            Project ID

        recursive_scan : typing.Optional[bool]
            Scan recursively

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

        region_name : typing.Optional[str]
            AWS Region

        s3endpoint : typing.Optional[str]
            S3 Endpoint

        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
        -------
        S3ImportStorage


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.import_storage.s3.update(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/storages/s3/{jsonable_encoder(id)}",
            method="PATCH",
            json={
                "aws_access_key_id": aws_access_key_id,
                "aws_secret_access_key": aws_secret_access_key,
                "aws_session_token": aws_session_token,
                "aws_sse_kms_key_id": aws_sse_kms_key_id,
                "bucket": bucket,
                "description": description,
                "prefix": prefix,
                "presign": presign,
                "presign_ttl": presign_ttl,
                "project": project,
                "recursive_scan": recursive_scan,
                "regex_filter": regex_filter,
                "region_name": region_name,
                "s3_endpoint": s3endpoint,
                "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 typing.cast(
                    S3ImportStorage,
                    construct_type(
                        type_=S3ImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

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

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

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

        Returns
        -------
        S3ImportStorage


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

        client = LabelStudio(
            api_key="YOUR_API_KEY",
        )
        client.import_storage.s3.sync(
            id=1,
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"api/storages/s3/{jsonable_encoder(id)}/sync",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    S3ImportStorage,
                    construct_type(
                        type_=S3ImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)


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

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

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

        project : typing.Optional[int]
            Project ID

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

        Returns
        -------
        typing.List[S3ImportStorage]


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.import_storage.s3.list()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/storages/s3/",
            method="GET",
            params={
                "ordering": ordering,
                "project": project,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[S3ImportStorage],
                    construct_type(
                        type_=typing.List[S3ImportStorage],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def create(
        self,
        *,
        aws_access_key_id: typing.Optional[str] = OMIT,
        aws_secret_access_key: typing.Optional[str] = OMIT,
        aws_session_token: typing.Optional[str] = OMIT,
        aws_sse_kms_key_id: typing.Optional[str] = OMIT,
        bucket: typing.Optional[str] = OMIT,
        description: 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,
        recursive_scan: typing.Optional[bool] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        region_name: typing.Optional[str] = OMIT,
        s3endpoint: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        use_blob_urls: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> S3ImportStorage:
        """
        Create new S3 import storage

        Parameters
        ----------
        aws_access_key_id : typing.Optional[str]
            AWS_ACCESS_KEY_ID

        aws_secret_access_key : typing.Optional[str]
            AWS_SECRET_ACCESS_KEY

        aws_session_token : typing.Optional[str]
            AWS_SESSION_TOKEN

        aws_sse_kms_key_id : typing.Optional[str]
            AWS SSE KMS Key ID

        bucket : typing.Optional[str]
            S3 bucket name

        description : typing.Optional[str]
            Storage description

        prefix : typing.Optional[str]
            S3 bucket prefix

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

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

        project : typing.Optional[int]
            Project ID

        recursive_scan : typing.Optional[bool]
            Scan recursively

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

        region_name : typing.Optional[str]
            AWS Region

        s3endpoint : typing.Optional[str]
            S3 Endpoint

        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
        -------
        S3ImportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/storages/s3/",
            method="POST",
            json={
                "aws_access_key_id": aws_access_key_id,
                "aws_secret_access_key": aws_secret_access_key,
                "aws_session_token": aws_session_token,
                "aws_sse_kms_key_id": aws_sse_kms_key_id,
                "bucket": bucket,
                "description": description,
                "prefix": prefix,
                "presign": presign,
                "presign_ttl": presign_ttl,
                "project": project,
                "recursive_scan": recursive_scan,
                "regex_filter": regex_filter,
                "region_name": region_name,
                "s3_endpoint": s3endpoint,
                "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 typing.cast(
                    S3ImportStorage,
                    construct_type(
                        type_=S3ImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def validate(
        self,
        *,
        aws_access_key_id: typing.Optional[str] = OMIT,
        aws_secret_access_key: typing.Optional[str] = OMIT,
        aws_session_token: typing.Optional[str] = OMIT,
        aws_sse_kms_key_id: typing.Optional[str] = OMIT,
        bucket: typing.Optional[str] = OMIT,
        description: 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,
        recursive_scan: typing.Optional[bool] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        region_name: typing.Optional[str] = OMIT,
        s3endpoint: 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 S3 import storage connection.

        Parameters
        ----------
        aws_access_key_id : typing.Optional[str]
            AWS_ACCESS_KEY_ID

        aws_secret_access_key : typing.Optional[str]
            AWS_SECRET_ACCESS_KEY

        aws_session_token : typing.Optional[str]
            AWS_SESSION_TOKEN

        aws_sse_kms_key_id : typing.Optional[str]
            AWS SSE KMS Key ID

        bucket : typing.Optional[str]
            S3 bucket name

        description : typing.Optional[str]
            Storage description

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

        prefix : typing.Optional[str]
            S3 bucket prefix

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

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

        project : typing.Optional[int]
            Project ID

        recursive_scan : typing.Optional[bool]
            Scan recursively

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

        region_name : typing.Optional[str]
            AWS Region

        s3endpoint : typing.Optional[str]
            S3 Endpoint

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


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "api/storages/s3/validate",
            method="POST",
            json={
                "aws_access_key_id": aws_access_key_id,
                "aws_secret_access_key": aws_secret_access_key,
                "aws_session_token": aws_session_token,
                "aws_sse_kms_key_id": aws_sse_kms_key_id,
                "bucket": bucket,
                "description": description,
                "id": id,
                "prefix": prefix,
                "presign": presign,
                "presign_ttl": presign_ttl,
                "project": project,
                "recursive_scan": recursive_scan,
                "regex_filter": regex_filter,
                "region_name": region_name,
                "s3_endpoint": s3endpoint,
                "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
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

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

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

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

        Returns
        -------
        S3ImportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/storages/s3/{jsonable_encoder(id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    S3ImportStorage,
                    construct_type(
                        type_=S3ImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete a specific S3 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.s3.delete(
                id=1,
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/storages/s3/{jsonable_encoder(id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def update(
        self,
        id: int,
        *,
        aws_access_key_id: typing.Optional[str] = OMIT,
        aws_secret_access_key: typing.Optional[str] = OMIT,
        aws_session_token: typing.Optional[str] = OMIT,
        aws_sse_kms_key_id: typing.Optional[str] = OMIT,
        bucket: typing.Optional[str] = OMIT,
        description: 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,
        recursive_scan: typing.Optional[bool] = OMIT,
        regex_filter: typing.Optional[str] = OMIT,
        region_name: typing.Optional[str] = OMIT,
        s3endpoint: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        use_blob_urls: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> S3ImportStorage:
        """
        Update a specific S3 import storage connection.

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

        aws_access_key_id : typing.Optional[str]
            AWS_ACCESS_KEY_ID

        aws_secret_access_key : typing.Optional[str]
            AWS_SECRET_ACCESS_KEY

        aws_session_token : typing.Optional[str]
            AWS_SESSION_TOKEN

        aws_sse_kms_key_id : typing.Optional[str]
            AWS SSE KMS Key ID

        bucket : typing.Optional[str]
            S3 bucket name

        description : typing.Optional[str]
            Storage description

        prefix : typing.Optional[str]
            S3 bucket prefix

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

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

        project : typing.Optional[int]
            Project ID

        recursive_scan : typing.Optional[bool]
            Scan recursively

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

        region_name : typing.Optional[str]
            AWS Region

        s3endpoint : typing.Optional[str]
            S3 Endpoint

        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
        -------
        S3ImportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/storages/s3/{jsonable_encoder(id)}",
            method="PATCH",
            json={
                "aws_access_key_id": aws_access_key_id,
                "aws_secret_access_key": aws_secret_access_key,
                "aws_session_token": aws_session_token,
                "aws_sse_kms_key_id": aws_sse_kms_key_id,
                "bucket": bucket,
                "description": description,
                "prefix": prefix,
                "presign": presign,
                "presign_ttl": presign_ttl,
                "project": project,
                "recursive_scan": recursive_scan,
                "regex_filter": regex_filter,
                "region_name": region_name,
                "s3_endpoint": s3endpoint,
                "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 typing.cast(
                    S3ImportStorage,
                    construct_type(
                        type_=S3ImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

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

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

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

        Returns
        -------
        S3ImportStorage


        Examples
        --------
        import asyncio

        from label_studio_sdk import AsyncLabelStudio

        client = AsyncLabelStudio(
            api_key="YOUR_API_KEY",
        )


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


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"api/storages/s3/{jsonable_encoder(id)}/sync",
            method="POST",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    S3ImportStorage,
                    construct_type(
                        type_=S3ImportStorage,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)
