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

Added support for dbutils.secrets #132

Merged
merged 15 commits into from
Aug 16, 2023
Merged

Added support for dbutils.secrets #132

merged 15 commits into from
Aug 16, 2023

Conversation

tanmay-db
Copy link
Contributor

@tanmay-db tanmay-db commented Aug 8, 2023

Changes

Add support for dbutils.secrets. New open api spec has been created to support secrets/get

TODO:

  1. Update https://github.com/databricks/databricks-sdk-java/blob/main/.codegen/_openapi_sha once the PR with spec changes is merged and we have the sha
  2. Uncomment secrets/get section in integration test once it is enabled for test infra

Tests

Unit and Integration tests

@tanmay-db tanmay-db changed the title [WIP] Add support for dbutils.secrets [WIP] Added support for dbutils.secrets Aug 8, 2023
@tanmay-db tanmay-db changed the title [WIP] Added support for dbutils.secrets Added support for dbutils.secrets Aug 14, 2023
@tanmay-db tanmay-db requested a review from mgyucht August 14, 2023 09:39
// < "error_code" : "BAD_REQUEST",
// < "message" : "This operation is not allowed outside databricks notebooks."
// < }
// ================= Uncomment once enabled ==================
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc: @mgyucht on this for visibility

Copy link
Contributor

@mgyucht mgyucht left a comment

Choose a reason for hiding this comment

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

Couple comments, otherwise looking great!

@EnvContext("workspace")
@ExtendWith(EnvTest.class)
public class SecretsIT {
// Most likely secrets/get isn't enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave the rest of the test uncommented. For example, we should be able to list the scope and see the newly created secret. We can simply comment out the parts from getSecret() onwards.

// String responseValue = secretsExt.get(scope, key);
// assertEquals(value, responseValue);
// } finally {
// secretsExt.deleteSecret(scope, key);
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: technically you need two nested try-finally blocks, as you can only delete the secret after it is created.

It is totally fine for this test to nest these. However, if you want to simplify this a bit, you can define new classes that extend Autocloseable that call secretsExt.deleteSecret or secretsExt.deleteScope, respectively, in their close methods.

@tanmay-db tanmay-db requested a review from mgyucht August 16, 2023 11:02
@mgyucht mgyucht enabled auto-merge August 16, 2023 15:39
Copy link
Contributor

@mgyucht mgyucht 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 Aug 16, 2023
Merged via the queue into main with commit a2479d7 Aug 16, 2023
9 checks passed
@mgyucht mgyucht deleted the secrets branch August 16, 2023 15:45
mgyucht added a commit that referenced this pull request Aug 18, 2023
* Added support for `dbutils.secrets` ([#132](#132)).
* Added retry in `w.clusters().ensureClusterIsRunning(id)` when cluster is simultaneously started by two different processes ([#134](#134)).
* Set necessary headers when authenticating via Azure CLI ([#136](#136)).

New Services:

 * Added `workspaceClient.artifactAllowlists()` service.
 * Added `workspaceClient.securableTags()` service.
 * Added `workspaceClient.subentityTags()` service.
 * Added `com.databricks.sdk.service.catalog.ArtifactAllowlistInfo` class.
 * Added `com.databricks.sdk.service.catalog.ArtifactMatcher` class.
 * Added `com.databricks.sdk.service.catalog.ArtifactType` class.
 * Added `com.databricks.sdk.service.catalog.GetArtifactAllowlistRequest` class.
 * Added `com.databricks.sdk.service.catalog.ListSecurableTagsRequest` class.
 * Added `com.databricks.sdk.service.catalog.ListSecurableType` class.
 * Added `com.databricks.sdk.service.catalog.ListSubentityTagsRequest` class.
 * Added `com.databricks.sdk.service.catalog.MatchType` class.
 * Added `com.databricks.sdk.service.catalog.SetArtifactAllowlist` class.
 * Added `com.databricks.sdk.service.catalog.TagChanges` class.
 * Added `com.databricks.sdk.service.catalog.TagKeyValuePair` class.
 * Added `com.databricks.sdk.service.catalog.TagSecurable` class.
 * Added `com.databricks.sdk.service.catalog.TagSecurableAssignment` class.
 * Added `com.databricks.sdk.service.catalog.TagSecurableAssignmentsList` class.
 * Added `com.databricks.sdk.service.catalog.TagSubentity` class.
 * Added `com.databricks.sdk.service.catalog.TagSubentityAssignmentsList` class.
 * Added `com.databricks.sdk.service.catalog.TagsSubentityAssignment` class.
 * Added `com.databricks.sdk.service.catalog.UpdateSecurableType` class.
 * Added `com.databricks.sdk.service.catalog.UpdateTags` class.

New APIs:

 * Added `deleteRuns()` method for `workspaceClient.experiments()` service.
 * Added `restoreRuns()` method for `workspaceClient.experiments()` service.
 * Added `com.databricks.sdk.service.ml.DeleteRuns` class.
 * Added `com.databricks.sdk.service.ml.DeleteRunsResponse` class.
 * Added `com.databricks.sdk.service.ml.RestoreRuns` class.
 * Added `com.databricks.sdk.service.ml.RestoreRunsResponse` class.
 * Added `getSecret()` method for `workspaceClient.secrets()` service.
 * Added `com.databricks.sdk.service.workspace.GetSecretRequest` class.
 * Added `com.databricks.sdk.service.workspace.GetSecretResponse` class.

API Renames:

 * Renamed `effectiveAutoMaintenanceFlag` field to `effectivePredictiveOptimizationFlag` field for `com.databricks.sdk.service.catalog.CatalogInfo`.
 * Renamed `enableAutoMaintenance` field to `enablePredictiveOptimization` field for `com.databricks.sdk.service.catalog.CatalogInfo`.
 * Renamed `com.databricks.sdk.service.catalog.EffectiveAutoMaintenanceFlag` class to `com.databricks.sdk.service.catalog.EffectivePredictiveOptimizationFlag` class.
 * Renamed `com.databricks.sdk.service.catalog.EffectiveAutoMaintenanceFlagInheritedFromType` class to `com.databricks.sdk.service.catalog.EffectivePredictiveOptimizationFlagInheritedFromType`.
 * Renamed `com.databricks.sdk.service.catalog.EnableAutoMaintenance` class to `com.databricks.sdk.service.catalog.EnablePredictiveOptimization`.
 * Renamed `effectiveAutoMaintenanceFlag` field to `effectivePredictiveOptimizationFlag` field for `com.databricks.sdk.service.catalog.SchemaInfo`.
 * Renamed `enableAutoMaintenance` field to `enablePredictiveOptimization` field for `com.databricks.sdk.service.catalog.SchemaInfo`.
 * Renamed `effectiveAutoMaintenanceFlag` field to `effectivePredictiveOptimizationFlag` field for `com.databricks.sdk.service.catalog.TableInfo`.
 * Renamed `enableAutoMaintenance` field to `enablePredictiveOptimization` field for `com.databricks.sdk.service.catalog.TableInfo`.

OpenAPI SHA: beff621d7b3e1d59244e2e34fc53a496f310e130, Date: 2023-08-17
@mgyucht mgyucht mentioned this pull request Aug 18, 2023
github-merge-queue bot pushed a commit that referenced this pull request Aug 18, 2023
* Added support for `dbutils.secrets`
([#132](#132)).
* Added retry in `w.clusters().ensureClusterIsRunning(id)` when cluster
is simultaneously started by two different processes
([#134](#134)).
* Set necessary headers when authenticating via Azure CLI
([#136](#136)).

New Services:

 * Added `workspaceClient.artifactAllowlists()` service.
 * Added `workspaceClient.securableTags()` service.
 * Added `workspaceClient.subentityTags()` service.
* Added `com.databricks.sdk.service.catalog.ArtifactAllowlistInfo`
class.
 * Added `com.databricks.sdk.service.catalog.ArtifactMatcher` class.
 * Added `com.databricks.sdk.service.catalog.ArtifactType` class.
* Added `com.databricks.sdk.service.catalog.GetArtifactAllowlistRequest`
class.
* Added `com.databricks.sdk.service.catalog.ListSecurableTagsRequest`
class.
 * Added `com.databricks.sdk.service.catalog.ListSecurableType` class.
* Added `com.databricks.sdk.service.catalog.ListSubentityTagsRequest`
class.
 * Added `com.databricks.sdk.service.catalog.MatchType` class.
* Added `com.databricks.sdk.service.catalog.SetArtifactAllowlist` class.
 * Added `com.databricks.sdk.service.catalog.TagChanges` class.
 * Added `com.databricks.sdk.service.catalog.TagKeyValuePair` class.
 * Added `com.databricks.sdk.service.catalog.TagSecurable` class.
* Added `com.databricks.sdk.service.catalog.TagSecurableAssignment`
class.
* Added `com.databricks.sdk.service.catalog.TagSecurableAssignmentsList`
class.
 * Added `com.databricks.sdk.service.catalog.TagSubentity` class.
* Added `com.databricks.sdk.service.catalog.TagSubentityAssignmentsList`
class.
* Added `com.databricks.sdk.service.catalog.TagsSubentityAssignment`
class.
 * Added `com.databricks.sdk.service.catalog.UpdateSecurableType` class.
 * Added `com.databricks.sdk.service.catalog.UpdateTags` class.

New APIs:

* Added `deleteRuns()` method for `workspaceClient.experiments()`
service.
* Added `restoreRuns()` method for `workspaceClient.experiments()`
service.
 * Added `com.databricks.sdk.service.ml.DeleteRuns` class.
 * Added `com.databricks.sdk.service.ml.DeleteRunsResponse` class.
 * Added `com.databricks.sdk.service.ml.RestoreRuns` class.
 * Added `com.databricks.sdk.service.ml.RestoreRunsResponse` class.
 * Added `getSecret()` method for `workspaceClient.secrets()` service.
 * Added `com.databricks.sdk.service.workspace.GetSecretRequest` class.
 * Added `com.databricks.sdk.service.workspace.GetSecretResponse` class.

API Renames:

* Renamed `effectiveAutoMaintenanceFlag` field to
`effectivePredictiveOptimizationFlag` field for
`com.databricks.sdk.service.catalog.CatalogInfo`.
* Renamed `enableAutoMaintenance` field to
`enablePredictiveOptimization` field for
`com.databricks.sdk.service.catalog.CatalogInfo`.
* Renamed
`com.databricks.sdk.service.catalog.EffectiveAutoMaintenanceFlag` class
to
`com.databricks.sdk.service.catalog.EffectivePredictiveOptimizationFlag`
class.
* Renamed
`com.databricks.sdk.service.catalog.EffectiveAutoMaintenanceFlagInheritedFromType`
class to
`com.databricks.sdk.service.catalog.EffectivePredictiveOptimizationFlagInheritedFromType`.
* Renamed `com.databricks.sdk.service.catalog.EnableAutoMaintenance`
class to
`com.databricks.sdk.service.catalog.EnablePredictiveOptimization`.
* Renamed `effectiveAutoMaintenanceFlag` field to
`effectivePredictiveOptimizationFlag` field for
`com.databricks.sdk.service.catalog.SchemaInfo`.
* Renamed `enableAutoMaintenance` field to
`enablePredictiveOptimization` field for
`com.databricks.sdk.service.catalog.SchemaInfo`.
* Renamed `effectiveAutoMaintenanceFlag` field to
`effectivePredictiveOptimizationFlag` field for
`com.databricks.sdk.service.catalog.TableInfo`.
* Renamed `enableAutoMaintenance` field to
`enablePredictiveOptimization` field for
`com.databricks.sdk.service.catalog.TableInfo`.

OpenAPI SHA: beff621d7b3e1d59244e2e34fc53a496f310e130, Date: 2023-08-17
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