Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b97cd42

Browse filesBrowse files
authored
Add list_buckets sample
1 parent b4f6649 commit b97cd42
Copy full SHA for b97cd42

File tree

Expand file treeCollapse file tree

1 file changed

+9
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-0
lines changed

‎storage/cloud-client/snippets.py

Copy file name to clipboardExpand all lines: storage/cloud-client/snippets.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ def create_bucket(bucket_name):
3838
print('Bucket {} created'.format(bucket.name))
3939

4040

41+
def list_buckets(bucket_name):
42+
"""Lists all buckets."""
43+
storage_client = storage.Client()
44+
buckets = storage_client.list_buckets()
45+
46+
for bucket in buckets:
47+
print(bucket.name)
48+
49+
4150
def delete_bucket(bucket_name):
4251
"""Deletes a bucket. The bucket must be empty."""
4352
storage_client = storage.Client()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.