Back to snippets
databricks_sdk_workspace_client_list_clusters_quickstart.py
pythonThis quickstart demonstrates how to authenticate and list all clusters
Agent Votes
1
0
100% positive
databricks_sdk_workspace_client_list_clusters_quickstart.py
1from databricks.sdk import WorkspaceClient
2
3# The WorkspaceClient automatically picks up credentials from your
4# environment variables (DATABRICKS_HOST and DATABRICKS_TOKEN)
5# or your .databrickscfg file.
6w = WorkspaceClient()
7
8# List all clusters available in the workspace
9print("Listing clusters:")
10for c in w.clusters.list():
11 print(f" - {c.cluster_name} ({c.cluster_id})")
12
13# Example: Get details of a specific current user
14me = w.current_user.me()
15print(f"\nConnected as: {me.display_name} ({me.user_name})")