From d72b4f38a3ffa7acb52aeb04ab83803ab412e645 Mon Sep 17 00:00:00 2001 From: Renaud Hartert Date: Wed, 24 Jul 2024 14:44:16 +0200 Subject: [PATCH] Create UnifiedAuthWorkspace.java --- .../example/UnifiedAuthWorkspace.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/docs/src/main/java/com/databricks/example/UnifiedAuthWorkspace.java diff --git a/examples/docs/src/main/java/com/databricks/example/UnifiedAuthWorkspace.java b/examples/docs/src/main/java/com/databricks/example/UnifiedAuthWorkspace.java new file mode 100644 index 000000000..5b372b827 --- /dev/null +++ b/examples/docs/src/main/java/com/databricks/example/UnifiedAuthWorkspace.java @@ -0,0 +1,27 @@ +package com.databricks.example; + +import com.databricks.sdk.WorkspaceClient; +import com.databricks.sdk.core.DatabricksConfig; +import com.databricks.sdk.service.compute.ClusterDetails; +import com.databricks.sdk.service.compute.ListClustersRequest; + +/** + Example for authenticating with Databricks Workspace through Databricks' Unified Authentication. Unified + Authentication takes care of inspecting your environment to determine the best way to authenticate. + +

+ For more details, please see Authenticate with Databricks SDK for Java. + */ +public class UnifiedAuthWorkspace { + /** + Authenticate and retrieve the list of clusters from the workspace + */ + public static void main(String[] args) { + DatabricksConfig config = new DatabricksConfig(); + + WorkspaceClient workspace = new WorkspaceClient(config); + for (ClusterDetails c : workspace.clusters().list(new ListClustersRequest())) { + System.out.println(c.getClusterName()); + } + } +}