diff --git a/docs/API.md b/docs/API.md index d069e392e..03c5f0d4f 100644 --- a/docs/API.md +++ b/docs/API.md @@ -183,7 +183,7 @@ client.remove_bucket("my-bucket") -### list_objects(bucket_name, prefix=None, recursive=False, start_after=None, include_user_meta=False, include_version=False, use_api_v1=False, use_url_encoding_type=True) +### list_objects(bucket_name, prefix=None, recursive=False, start_after=None, include_user_meta=False, include_version=False, use_api_v1=False, use_url_encoding_type=True, extra_headers=None, extra_query_params=None) Lists object information of a bucket. @@ -199,6 +199,8 @@ __Parameters__ | `include_version` | _bool_ | Flag to control whether include object versions. | | `use_api_v1` | _bool_ | Flag to control to use ListObjectV1 S3 API or not. | | `use_url_encoding_type` | _bool_ | Flag to control whether URL encoding type to be used or not. | +| `extra_headers` | _dict_ | Extra HTTP headers for advanced usage. | +| `extra_query_params` | _dict_ | Extra query parameters for advanced usage. | __Return Value__ @@ -1374,7 +1376,7 @@ print( -### stat_object(bucket_name, object_name, ssec=None, version_id=None, extra_query_params=None) +### stat_object(bucket_name, object_name, ssec=None, version_id=None, extra_headers=None, extra_query_params=None) Get object information and metadata of an object. diff --git a/minio/api.py b/minio/api.py index 47b24d300..c0f60d688 100644 --- a/minio/api.py +++ b/minio/api.py @@ -2006,6 +2006,8 @@ def list_objects( use_api_v1: bool = False, use_url_encoding_type: bool = True, fetch_owner: bool = False, + extra_headers: DictType | None = None, + extra_query_params: DictType | None = None, ): """ Lists object information of a bucket. @@ -2021,6 +2023,8 @@ def list_objects( :param use_api_v1: Flag to control to use ListObjectV1 S3 API or not. :param use_url_encoding_type: Flag to control whether URL encoding type to be used or not. + :param extra_headers: Extra HTTP headers for advanced usage. + :param extra_query_params: Extra query parameters for advanced usage. :return: Iterator of :class:`Object `. Example:: @@ -2065,6 +2069,8 @@ def list_objects( include_version=include_version, encoding_type="url" if use_url_encoding_type else None, fetch_owner=fetch_owner, + extra_headers=extra_headers, + extra_query_params=extra_query_params, ) def stat_object( @@ -3136,6 +3142,8 @@ def _list_objects( version_id_marker: str | None = None, # versioned use_api_v1: bool = False, include_version: bool = False, + extra_headers: DictType | None = None, + extra_query_params: DictType | None = None, ) -> Iterator[Object]: """ List objects optionally including versions. @@ -3152,7 +3160,7 @@ def _list_objects( is_truncated = True while is_truncated: - query = {} + query = extra_query_params or {} if include_version: query["versions"] = "" elif not use_api_v1: @@ -3184,6 +3192,7 @@ def _list_objects( "GET", bucket_name, query_params=cast(DictType, query), + headers=extra_headers, ) objects, is_truncated, start_after, version_id_marker = (