-
Notifications
You must be signed in to change notification settings - Fork 25
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
Implement notebook-native auth for the Java SDK #171
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tanmay-db
approved these changes
Oct 24, 2023
...bricks-sdk-java/src/main/java/com/databricks/sdk/core/NotebookNativeCredentialsProvider.java
Show resolved
Hide resolved
...bricks-sdk-java/src/main/java/com/databricks/sdk/core/NotebookNativeCredentialsProvider.java
Outdated
Show resolved
Hide resolved
...bricks-sdk-java/src/main/java/com/databricks/sdk/core/NotebookNativeCredentialsProvider.java
Outdated
Show resolved
Hide resolved
...bricks-sdk-java/src/main/java/com/databricks/sdk/core/NotebookNativeCredentialsProvider.java
Outdated
Show resolved
Hide resolved
headers.put("Authorization", String.format("Bearer %s", tokenAndUrl.token)); | ||
return headers; | ||
}; | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here about catching specific exception.
...bricks-sdk-java/src/main/java/com/databricks/sdk/core/NotebookNativeCredentialsProvider.java
Show resolved
Hide resolved
...bricks-sdk-java/src/main/java/com/databricks/sdk/core/NotebookNativeCredentialsProvider.java
Show resolved
Hide resolved
...bricks-sdk-java/src/main/java/com/databricks/sdk/core/NotebookNativeCredentialsProvider.java
Show resolved
Hide resolved
Need to check DBR version range supported (including serverless) |
tanmay-db
approved these changes
Oct 26, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tanmay-db
added a commit
that referenced
this pull request
Nov 9, 2023
* Implement notebook-native auth for the Java SDK ([#171](#171)). * Added regression question to github issue template ([#176](#176)). * Mark Java SDK as Beta ([#177](#177)). * Update SDK to latest OpenAPI Spec ([#181](#181)). API Changes: * Changed `create()` method for `workspaceClient.functions()` service . New request type is `com.databricks.sdk.service.catalog.CreateFunctionRequest` class. * Changed `create()` method for `workspaceClient.metastores()` service with new required argument order. * Changed `inputParams` field for `com.databricks.sdk.service.catalog.CreateFunction` to `com.databricks.sdk.service.catalog.FunctionParameterInfos` class. * Changed `properties` field for `com.databricks.sdk.service.catalog.CreateFunction` to `String` class. * Changed `returnParams` field for `com.databricks.sdk.service.catalog.CreateFunction` to `com.databricks.sdk.service.catalog.FunctionParameterInfos` class. * Changed `storageRoot` field for `com.databricks.sdk.service.catalog.CreateMetastore` to no longer be required. * Changed `inputParams` field for `com.databricks.sdk.service.catalog.FunctionInfo` to `com.databricks.sdk.service.catalog.FunctionParameterInfos` class. * Changed `properties` field for `com.databricks.sdk.service.catalog.FunctionInfo` to `String` class. * Changed `returnParams` field for `com.databricks.sdk.service.catalog.FunctionInfo` to `com.databricks.sdk.service.catalog.FunctionParameterInfos` class. * Added `skipValidation` field for `com.databricks.sdk.service.catalog.UpdateExternalLocation`. * Added `com.databricks.sdk.service.catalog.CreateFunctionRequest` class. * Added `com.databricks.sdk.service.catalog.DependencyList` class. * Added `com.databricks.sdk.service.catalog.FunctionParameterInfos` class. * Added `libraries` field for `com.databricks.sdk.service.compute.CreatePolicy`. * Added `libraries` field for `com.databricks.sdk.service.compute.EditPolicy`. * Added `initScripts` field for `com.databricks.sdk.service.compute.EventDetails`. * Added `file` field for `com.databricks.sdk.service.compute.InitScriptInfo`. * Added `zoneId` field for `com.databricks.sdk.service.compute.InstancePoolGcpAttributes`. * Added `libraries` field for `com.databricks.sdk.service.compute.Policy`. * Added `com.databricks.sdk.service.compute.InitScriptEventDetails` class. * Added `com.databricks.sdk.service.compute.InitScriptExecutionDetails` class. * Added `com.databricks.sdk.service.compute.InitScriptExecutionDetailsStatus` class. * Added `com.databricks.sdk.service.compute.InitScriptInfoAndExecutionDetails` class. * Added `com.databricks.sdk.service.compute.LocalFileInfo` class. * Removed `uiState` field for `com.databricks.sdk.service.jobs.CreateJob`. * Added `editMode` field for `com.databricks.sdk.service.jobs.CreateJob`. * Removed `com.databricks.sdk.service.jobs.CreateJobUiState` class. * Added `includeResolvedValues` field for `com.databricks.sdk.service.jobs.GetRunRequest`. * Removed `uiState` field for `com.databricks.sdk.service.jobs.JobSettings`. * Added `editMode` field for `com.databricks.sdk.service.jobs.JobSettings`. * Removed `com.databricks.sdk.service.jobs.JobSettingsUiState` class. * Added `com.databricks.sdk.service.jobs.CreateJobEditMode` class. * Added `com.databricks.sdk.service.jobs.JobSettingsEditMode` class. * Removed `accountClient.oAuthEnrollment()` service. * Removed `com.databricks.sdk.service.oauth2.CreateOAuthEnrollment` class. * Removed `com.databricks.sdk.service.oauth2.OAuthEnrollmentStatus` class. * Added `networkConnectivityConfigId` field for `com.databricks.sdk.service.provisioning.UpdateWorkspaceRequest`. * Removed `delete()` method for `workspaceClient.apps()` service. * Removed `get()` method for `workspaceClient.apps()` service. * Added `deleteApp()` method for `workspaceClient.apps()` service. * Added `getApp()` method for `workspaceClient.apps()` service. * Added `getAppDeploymentStatus()` method for `workspaceClient.apps()` service. * Added `getApps()` method for `workspaceClient.apps()` service. * Added `getEvents()` method for `workspaceClient.apps()` service. * Added `containerLogs` field for `com.databricks.sdk.service.serving.DeploymentStatus`. * Added `extraInfo` field for `com.databricks.sdk.service.serving.DeploymentStatus`. * Added `com.databricks.sdk.service.serving.AppEvents` class. * Added `com.databricks.sdk.service.serving.AppServiceStatus` class. * Added `com.databricks.sdk.service.serving.DeleteAppResponse` class. * Added `com.databricks.sdk.service.serving.GetAppDeploymentStatusRequest` class. * Added `com.databricks.sdk.service.serving.GetAppResponse` class. * Added `com.databricks.sdk.service.serving.GetEventsRequest` class. * Added `com.databricks.sdk.service.serving.ListAppEventsResponse` class. * Added `com.databricks.sdk.service.serving.ListAppsResponse` class. * Added `accountClient.networkConnectivity()` service. * Added `com.databricks.sdk.service.settings.CreateNetworkConnectivityConfigRequest` class. * Added `com.databricks.sdk.service.settings.CreatePrivateEndpointRuleRequest` class. * Added `com.databricks.sdk.service.settings.CreatePrivateEndpointRuleRequestGroupId` class. * Added `com.databricks.sdk.service.settings.DeleteNetworkConnectivityConfigurationRequest` class. * Added `com.databricks.sdk.service.settings.DeletePrivateEndpointRuleRequest` class. * Added `com.databricks.sdk.service.settings.GetNetworkConnectivityConfigurationRequest` class. * Added `com.databricks.sdk.service.settings.GetPrivateEndpointRuleRequest` class. * Added `com.databricks.sdk.service.settings.NccAzurePrivateEndpointRule` class. * Added `com.databricks.sdk.service.settings.NccAzurePrivateEndpointRuleConnectionState` class. * Added `com.databricks.sdk.service.settings.NccAzurePrivateEndpointRuleGroupId` class. * Added `com.databricks.sdk.service.settings.NccAzureServiceEndpointRule` class. * Added `com.databricks.sdk.service.settings.NccEgressConfig` class. * Added `com.databricks.sdk.service.settings.NccEgressDefaultRules` class. * Added `com.databricks.sdk.service.settings.NccEgressTargetRules` class. * Added `com.databricks.sdk.service.settings.NetworkConnectivityConfiguration` class. OpenAPI SHA: e7b127cb07af8dd4d8c61c7cc045c8910cdbb02a, Date: 2023-11-08
Merged
github-merge-queue bot
pushed a commit
that referenced
this pull request
Nov 10, 2023
* Implemented notebook-native auth for the Java SDK ([#171](#171)). * Addeded regression question to github issue template ([#176](#176)). * Marked Java SDK as Beta ([#177](#177)). * Updated SDK to latest OpenAPI Spec ([#181](#181)). API Changes: * Changed `create()` method for `workspaceClient.functions()` and `workspaceClient.metastores()` service. * Changed the following fields: * `inputParams` field for `com.databricks.sdk.service.catalog.CreateFunction` to `com.databricks.sdk.service.catalog.FunctionParameterInfos` class. * `properties` field for `com.databricks.sdk.service.catalog.CreateFunction` to `String` class. * `returnParams` field for `com.databricks.sdk.service.catalog.CreateFunction` to `com.databricks.sdk.service.catalog.FunctionParameterInfos` class. * `storageRoot` field for `com.databricks.sdk.service.catalog.CreateMetastore` to no longer be required. * `inputParams` field for `com.databricks.sdk.service.catalog.FunctionInfo` to `com.databricks.sdk.service.catalog.FunctionParameterInfos` class. * `properties` field for `com.databricks.sdk.service.catalog.FunctionInfo` to `String` class. * `returnParams` field for `com.databricks.sdk.service.catalog.FunctionInfo` to `com.databricks.sdk.service.catalog.FunctionParameterInfos` class. * Added the following fields: * `skipValidation` field for `com.databricks.sdk.service.catalog.UpdateExternalLocation`. * `libraries` field for `com.databricks.sdk.service.compute.CreatePolicy`, `com.databricks.sdk.service.compute.EditPolicy` and `com.databricks.sdk.service.compute.Policy`. * `initScripts` field for `com.databricks.sdk.service.compute.EventDetails`. * `file` field for `com.databricks.sdk.service.compute.InitScriptInfo`. * `zoneId` field for `com.databricks.sdk.service.compute.InstancePoolGcpAttributes`. * `editMode` field for `com.databricks.sdk.service.jobs.CreateJob` and `com.databricks.sdk.service.jobs.JobSettings`. * `includeResolvedValues` field for `com.databricks.sdk.service.jobs.GetRunRequest`. * `networkConnectivityConfigId` field for `com.databricks.sdk.service.provisioning.UpdateWorkspaceRequest`. * `containerLogs` and `extraInfo` field for `com.databricks.sdk.service.serving.DeploymentStatus`. * Added `deleteApp()`, `getApp()`, `getAppDeploymentStatus()`, `getApps()` and `getEvents()` method for `workspaceClient.apps()` service. * Added `accountClient.networkConnectivity()` service. * Added the following classses: * `com.databricks.sdk.service.compute`: `LocalFileInfo`, `InitScriptInfoAndExecutionDetails`, `InitScriptEventDetails`, `InitScriptExecutionDetails` and `InitScriptExecutionDetailsStatus`. * `com.databricks.sdk.service.jobs`: `JobSettingsEditMode` and `CreateJobEditMode`. * `com.databricks.sdk.service.catalog`: `CreateFunctionRequest`, `DependencyList` and `FunctionParameterInfos`. * `com.databricks.sdk.service.serving`: `AppEvents`, `AppServiceStatus`, `DeleteAppResponse`, `GetAppDeploymentStatusRequest`, `GetAppResponse`, `GetEventsRequest`, `ListAppEventsResponse` and `ListAppsResponse`. * `com.databricks.sdk.service.settings`: `CreateNetworkConnectivityConfigRequest`, `CreatePrivateEndpointRuleRequest`, `CreatePrivateEndpointRuleRequestGroupId`, `DeleteNetworkConnectivityConfigurationRequest`, `DeletePrivateEndpointRuleRequest`, `GetNetworkConnectivityConfigurationRequest`, `GetPrivateEndpointRuleRequest`, `NccAzurePrivateEndpointRule`, `NccAzurePrivateEndpointRuleConnectionState`, `NccAzurePrivateEndpointRuleGroupId`, `NccAzureServiceEndpointRule`, `NccEgressConfig`, `NccEgressDefaultRules`, `NccEgressTargetRules` and `NetworkConnectivityConfiguration`. * Removed the following fields: * `uiState` field for `com.databricks.sdk.service.jobs.CreateJob`. * `uiState` field for `com.databricks.sdk.service.jobs.JobSettings`. * Removed `delete()` and `get()` method for `workspaceClient.apps()` service. * Removed `accountClient.oAuthEnrollment()` service. * Removed the following classes: `com.databricks.sdk.service.jobs.CreateJobUiState`, `com.databricks.sdk.service.jobs.JobSettingsUiState`, `com.databricks.sdk.service.oauth2.CreateOAuthEnrollment` and `com.databricks.sdk.service.oauth2.OAuthEnrollmentStatus`. OpenAPI SHA: e7b127cb07af8dd4d8c61c7cc045c8910cdbb02a, Date: 2023-11-08
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Notebook-native authentication has been supported in the Python SDK for the last several months, and customers using the SDKs in Databricks appreciate the easier CUJ for authentication. This PR ports the behavior to the Java SDK. The approach taken for this implementation differs somewhat from the Python SDK's implementation. In particular, in Python, DBR provides some functionality to get the command context (
from dbruntime.databricks_repl_context import get_context
,from dbruntime.sdk_credential_provider import init_runtime_native_auth
) as well as from IPython. The Java SDK uses the DBUtils object directly. However, the SDK doesn't depend on the DBUtils API (which is only in Scala), so instead we load it reflectively.Tests
Ran in a notebook in DBR, worked.