Skip to content

Commit

Permalink
list_objects: add extra headers and extra query parameters
Browse files Browse the repository at this point in the history
Fixes #1278

Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana committed Nov 20, 2024
1 parent b048920 commit 0c18732
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,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.
Expand All @@ -2020,6 +2022,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 <Object>`.
Example::
Expand Down Expand Up @@ -2064,6 +2068,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(
Expand Down Expand Up @@ -3135,6 +3141,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.
Expand All @@ -3151,7 +3159,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:
Expand Down Expand Up @@ -3183,6 +3191,7 @@ def _list_objects(
"GET",
bucket_name,
query_params=cast(DictType, query),
headers=extra_headers,
)

objects, is_truncated, start_after, version_id_marker = (
Expand Down

0 comments on commit 0c18732

Please sign in to comment.