managed/api-examples/python-client/list-universes.ipynb
First, import the required packages.
Next, specify some important variables:
platform_address: The address of the Yugabyte Platform APIplatform_api_key: The API key used to authenticate with the Platform APIFinally, create the Yugabyte Platform API client object.
import os
import yb_platform_client
from yb_platform_client.api import universe_api, session_api
platform_address = 'http://localhost:9000'
platform_api_key = os.getenv('YB_API_KEY')
api_client = yb_platform_client.ApiClient(yb_platform_client.Configuration(
host = platform_address,
api_key = {
'apiKeyAuth': platform_api_key,
}
))
Make an API call to session endpoint to determine customer UUID.
session_api = session_api.SessionApi(api_client)
try:
session_info = session_api.get_session_info()
except yb_platform_client.ApiException as e:
print("Error get_session_info: %s" % e)
raise
customer_uuid = session_info.get('customer_uuid')
print('Customer UUID:\n%s' % customer_uuid)
Make API call to provider endpoint to list universes.
universe_api = universe_api.UniverseApi(api_client)
try:
universe_list = universe_api.get_list_of_universes(customer_uuid)
except yb_platform_client.ApiException as e:
print('Error get_list_of_universes: %s' % e)
raise
print('Universes:\n%s' % universe_list)