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

Implement notebook-native auth for the Java SDK #171

Merged
merged 13 commits into from
Oct 26, 2023
Merged

Conversation

mgyucht
Copy link
Contributor

@mgyucht mgyucht commented Oct 23, 2023

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.

@mgyucht mgyucht requested a review from tanmay-db October 24, 2023 11:00
headers.put("Authorization", String.format("Bearer %s", tokenAndUrl.token));
return headers;
};
} catch (Exception e) {
Copy link
Contributor

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.

@mgyucht
Copy link
Contributor Author

mgyucht commented Oct 25, 2023

Need to check DBR version range supported (including serverless)

Copy link
Contributor

@tanmay-db tanmay-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mgyucht mgyucht added this pull request to the merge queue Oct 26, 2023
Merged via the queue into main with commit 79f4ed7 Oct 26, 2023
9 checks passed
@mgyucht mgyucht deleted the notebook-native-auth branch October 26, 2023 13:28
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
@tanmay-db tanmay-db mentioned this pull request Nov 9, 2023
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants