2022-10-24 17:29:03 -07:00
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# snippet-start:[python.example_code.keyspaces.Hello]
import boto3
2023-10-18 10:35:05 -07:00
2022-10-24 17:29:03 -07:00
def hello_keyspaces ( keyspaces_client ) :
"""
Use the AWS SDK for Python (Boto3) to create an Amazon Keyspaces (for Apache Cassandra)
client and list the keyspaces in your account.
This example uses the default settings specified in your shared credentials
and config files.
:param keyspaces_client: A Boto3 Amazon Keyspaces Client object. This object wraps
the low-level Amazon Keyspaces service API.
"""
2022-10-28 16:25:02 -07:00
print ( " Hello, Amazon Keyspaces! Let ' s list some of your keyspaces: \n " )
2023-10-18 10:35:05 -07:00
for ks in keyspaces_client . list_keyspaces ( maxResults = 5 ) . get ( " keyspaces " , [ ] ) :
print ( ks [ " keyspaceName " ] )
2022-10-24 17:29:03 -07:00
print ( f " \t { ks [ ' resourceArn ' ] } " )
2023-10-18 10:35:05 -07:00
if __name__ == " __main__ " :
hello_keyspaces ( boto3 . client ( " keyspaces " ) )
2022-10-24 17:29:03 -07:00
# snippet-end:[python.example_code.keyspaces.Hello]