Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add match_glob param to list_blobs() #1036

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions google/cloud/storage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,7 @@ def list_blobs(
page_size=None,
timeout=_DEFAULT_TIMEOUT,
retry=DEFAULT_RETRY,
match_glob=None,
):
"""Return an iterator used to find blobs in the bucket.

Expand Down Expand Up @@ -1213,6 +1214,10 @@ def list_blobs(
See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
information on retry types and how to configure them.

match_glob (str):
(Optional) A glob pattern used to filter results (for example, foo*bar).
The string value must be UTF-8 encoded.

Returns:
Iterator of all :class:`~google.cloud.storage.blob.Blob`
in this bucket matching the arguments. The RPC call
Expand All @@ -1229,8 +1234,8 @@ def list_blobs(
extra_params["prefix"] = prefix

if delimiter is not None:
extra_params["delimiter"] = delimiter

extra_params["delimiter"] = delimiter
if start_offset is not None:
extra_params["startOffset"] = start_offset

Expand All @@ -1249,6 +1254,9 @@ def list_blobs(
if bucket.user_project is not None:
extra_params["userProject"] = bucket.user_project

if match_glob is not None:
extra_params["matchGlob"] = match_glob

path = bucket.path + "/o"
iterator = self._list_resource(
path,
Expand Down