From b0a3349ddae921a046ef6763b86f4e72063913b3 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Mon, 3 Nov 2025 06:37:57 +0000 Subject: [PATCH 1/3] test --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index a7db13a25..761c5f260 100644 --- a/README.rst +++ b/README.rst @@ -276,3 +276,4 @@ Next Steps .. _Google Cloud Storage Product documentation: https://cloud.google.com/storage .. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst +# test From 778e68ee4e565ec270f1972bda37700de228ccbf Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Mon, 3 Nov 2025 06:44:00 +0000 Subject: [PATCH 2/3] Revert "test" This reverts commit b0a3349ddae921a046ef6763b86f4e72063913b3. --- README.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/README.rst b/README.rst index 761c5f260..a7db13a25 100644 --- a/README.rst +++ b/README.rst @@ -276,4 +276,3 @@ Next Steps .. _Google Cloud Storage Product documentation: https://cloud.google.com/storage .. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst -# test From 64153b097636efe5d5bd46b83a5ebce473249ecb Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Thu, 6 Nov 2025 10:45:10 +0000 Subject: [PATCH 3/3] list buckets --- google/cloud/storage/client.py | 21 ++++++++++++++++++++- samples/snippets/storage_list_buckets.py | 8 ++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/google/cloud/storage/client.py b/google/cloud/storage/client.py index 74b6061c0..5b9db4348 100644 --- a/google/cloud/storage/client.py +++ b/google/cloud/storage/client.py @@ -64,6 +64,22 @@ _marker = object() +def _buckets_page_start(iterator, page, response): + """Grab prefixes after a :class:`~google.cloud.iterator.Page` started. + + :type iterator: :class:`~google.api_core.page_iterator.Iterator` + :param iterator: The iterator that is currently in use. + + :type page: :class:`~google.cloud.api.core.page_iterator.Page` + :param page: The page that was just created. + + :type response: dict + :param response: The JSON API response for a page of blobs. + """ + page.unreachable = tuple(response.get("unreachable", ())) + iterator.unreachable.update(page.unreachable) + + class Client(ClientWithProject): """Client to bundle configuration needed for API requests. @@ -1551,7 +1567,7 @@ def list_buckets( if soft_deleted is not None: extra_params["softDeleted"] = soft_deleted - return self._list_resource( + iterator = self._list_resource( "/b", _item_to_bucket, page_token=page_token, @@ -1560,7 +1576,10 @@ def list_buckets( page_size=page_size, timeout=timeout, retry=retry, + page_start=_buckets_page_start, ) + iterator.unreachable = set() + return iterator def restore_bucket( self, diff --git a/samples/snippets/storage_list_buckets.py b/samples/snippets/storage_list_buckets.py index f5897e47a..4e6922a80 100644 --- a/samples/snippets/storage_list_buckets.py +++ b/samples/snippets/storage_list_buckets.py @@ -22,9 +22,13 @@ def list_buckets(): """Lists all buckets.""" storage_client = storage.Client() - buckets = storage_client.list_buckets() + buckets_iterator = storage_client.list_buckets() + if hasattr(buckets_iterator, "unreachable"): + print("Unreachable locations:", len(buckets_iterator.unreachable)) + for location in buckets_iterator.unreachable: + print(location) - for bucket in buckets: + for bucket in buckets_iterator: print(bucket.name)