Skip to content

Commit

Permalink
list_objects: add extra headers and extra query parameters (#1458)
Browse files Browse the repository at this point in the history
Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana authored Nov 26, 2024
1 parent caf9ab0 commit 7ec72b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 4 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ client.remove_bucket("my-bucket")

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

### 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.

Expand All @@ -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__

Expand Down Expand Up @@ -1374,7 +1376,7 @@ print(

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

### 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.

Expand Down
11 changes: 10 additions & 1 deletion minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 <Object>`.
Example::
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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 = (
Expand Down

0 comments on commit 7ec72b8

Please sign in to comment.