Skip to content

Commit 7ec72b8

Browse files
authored
list_objects: add extra headers and extra query parameters (#1458)
Signed-off-by: Bala.FA <[email protected]>
1 parent caf9ab0 commit 7ec72b8

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

docs/API.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ client.remove_bucket("my-bucket")
183183

184184
<a name="list_objects"></a>
185185

186-
### 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)
186+
### 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)
187187

188188
Lists object information of a bucket.
189189

@@ -199,6 +199,8 @@ __Parameters__
199199
| `include_version` | _bool_ | Flag to control whether include object versions. |
200200
| `use_api_v1` | _bool_ | Flag to control to use ListObjectV1 S3 API or not. |
201201
| `use_url_encoding_type` | _bool_ | Flag to control whether URL encoding type to be used or not. |
202+
| `extra_headers` | _dict_ | Extra HTTP headers for advanced usage. |
203+
| `extra_query_params` | _dict_ | Extra query parameters for advanced usage. |
202204

203205
__Return Value__
204206

@@ -1374,7 +1376,7 @@ print(
13741376

13751377
<a name="stat_object"></a>
13761378

1377-
### stat_object(bucket_name, object_name, ssec=None, version_id=None, extra_query_params=None)
1379+
### stat_object(bucket_name, object_name, ssec=None, version_id=None, extra_headers=None, extra_query_params=None)
13781380

13791381
Get object information and metadata of an object.
13801382

minio/api.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,8 @@ def list_objects(
20062006
use_api_v1: bool = False,
20072007
use_url_encoding_type: bool = True,
20082008
fetch_owner: bool = False,
2009+
extra_headers: DictType | None = None,
2010+
extra_query_params: DictType | None = None,
20092011
):
20102012
"""
20112013
Lists object information of a bucket.
@@ -2021,6 +2023,8 @@ def list_objects(
20212023
:param use_api_v1: Flag to control to use ListObjectV1 S3 API or not.
20222024
:param use_url_encoding_type: Flag to control whether URL encoding type
20232025
to be used or not.
2026+
:param extra_headers: Extra HTTP headers for advanced usage.
2027+
:param extra_query_params: Extra query parameters for advanced usage.
20242028
:return: Iterator of :class:`Object <Object>`.
20252029
20262030
Example::
@@ -2065,6 +2069,8 @@ def list_objects(
20652069
include_version=include_version,
20662070
encoding_type="url" if use_url_encoding_type else None,
20672071
fetch_owner=fetch_owner,
2072+
extra_headers=extra_headers,
2073+
extra_query_params=extra_query_params,
20682074
)
20692075

20702076
def stat_object(
@@ -3136,6 +3142,8 @@ def _list_objects(
31363142
version_id_marker: str | None = None, # versioned
31373143
use_api_v1: bool = False,
31383144
include_version: bool = False,
3145+
extra_headers: DictType | None = None,
3146+
extra_query_params: DictType | None = None,
31393147
) -> Iterator[Object]:
31403148
"""
31413149
List objects optionally including versions.
@@ -3152,7 +3160,7 @@ def _list_objects(
31523160

31533161
is_truncated = True
31543162
while is_truncated:
3155-
query = {}
3163+
query = extra_query_params or {}
31563164
if include_version:
31573165
query["versions"] = ""
31583166
elif not use_api_v1:
@@ -3184,6 +3192,7 @@ def _list_objects(
31843192
"GET",
31853193
bucket_name,
31863194
query_params=cast(DictType, query),
3195+
headers=extra_headers,
31873196
)
31883197

31893198
objects, is_truncated, start_after, version_id_marker = (

0 commit comments

Comments
 (0)