Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b97cd42

Browse files
authored
Add list_buckets sample
1 parent b4f6649 commit b97cd42

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

storage/cloud-client/snippets.py

Lines 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)