Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal] Add example for workspace unified authentication #320

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.

<p>
For more details, please see <a href="https://docs.databricks.com/en/dev-tools/sdk-java.html#authenticate-the-databricks-sdk-for-java-with-your-databricks-account-or-workspace">Authenticate with Databricks SDK for Java</a>.
*/
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());
}
}
}
Loading