Chapter 3. Listing available buckets in your object store
To list buckets that are available in your object store, use the list_bucket()
method.
Prerequisites
-
You have cloned the
odh-doc-examples
repository to your workbench. -
You have opened the
s3client_examples.ipynb
file in your workbench. - You have installed Boto3 and configured the S3 client.
Procedure
In the Jupyter notebook, locate the following instructions that lists available buckets and then run the code cell.
#List available buckets s3_client.list_buckets()
#List available buckets s3_client.list_buckets()
Copy to Clipboard Copied! A successful response includes an HTTP request status code of
200
and a list of buckets, similar to the following output:'HTTPStatusCode': 200, 'Buckets': [{'Name': 'aqs086-image-registry', 'CreationDate': datetime.datetime(2024, 1, 16, 20, 21, 36, 244000, tzinfo=tzlocal( ))},
'HTTPStatusCode': 200, 'Buckets': [{'Name': 'aqs086-image-registry', 'CreationDate': datetime.datetime(2024, 1, 16, 20, 21, 36, 244000, tzinfo=tzlocal( ))},
Copy to Clipboard Copied! Locate the instructions that prints only the names of available buckets and execute the code cell.
#Print only names of available buckets for bucket in s3_client.list_buckets()[‘Buckets’]: print(bucket[‘Name’])
#Print only names of available buckets for bucket in s3_client.list_buckets()[‘Buckets’]: print(bucket[‘Name’])
Copy to Clipboard Copied! The output displays the names of the buckets, similar to the following example.
aqs086-image-registry aqs087-image-registry aqs135-image-registry aqs246-image-registry
aqs086-image-registry aqs087-image-registry aqs135-image-registry aqs246-image-registry
Copy to Clipboard Copied!