From acf292da37172986b839dd648fc756c3fb3666cb Mon Sep 17 00:00:00 2001 From: Serge Smertin <259697+nfx@users.noreply.github.com> Date: Tue, 18 Jul 2023 19:13:48 +0200 Subject: [PATCH] Release v0.201.0 (#586) * Add development runs ([#522](https://github.com/databricks/cli/pull/522)). * Support tab completion for profiles ([#572](https://github.com/databricks/cli/pull/572)). * Correctly use --profile flag passed for all bundle commands ([#571](https://github.com/databricks/cli/pull/571)). * Disallow notebooks in paths where files are expected ([#573](https://github.com/databricks/cli/pull/573)). * Improve auth login experience ([#570](https://github.com/databricks/cli/pull/570)). * Remove base path checks during sync ([#576](https://github.com/databricks/cli/pull/576)). * First look for databricks.yml before falling back to bundle.yml ([#580](https://github.com/databricks/cli/pull/580)). * Integrate with auto-release infra ([#581](https://github.com/databricks/cli/pull/581)). API Changes: * Removed `databricks metastores maintenance` command. * Added `databricks metastores enable-optimization` command. * Added `databricks tables update` command. * Changed `databricks account settings delete-personal-compute-setting` command with new required argument order. * Changed `databricks account settings read-personal-compute-setting` command with new required argument order. * Added `databricks clean-rooms` command group. OpenAPI SHA: 850a075ed9758d21a6bc4409506b48c8b9f93ab4, Date: 2023-07-18 Dependency updates: * Bump golang.org/x/term from 0.9.0 to 0.10.0 ([#567](https://github.com/databricks/cli/pull/567)). * Bump golang.org/x/oauth2 from 0.9.0 to 0.10.0 ([#566](https://github.com/databricks/cli/pull/566)). * Bump golang.org/x/mod from 0.11.0 to 0.12.0 ([#568](https://github.com/databricks/cli/pull/568)). * Bump github.com/databricks/databricks-sdk-go from 0.12.0 to 0.13.0 ([#585](https://github.com/databricks/cli/pull/585)). --- .codegen/_openapi_sha | 1 + .gitattributes | 1 + CHANGELOG.md | 28 ++ cmd/account/groups/groups.go | 3 +- cmd/account/metastores/metastores.go | 2 + .../service-principals/service-principals.go | 3 +- cmd/account/settings/settings.go | 58 ++-- .../storage-credentials.go | 2 + cmd/account/users/users.go | 3 +- cmd/workspace/alerts/alerts.go | 2 +- cmd/workspace/clean-rooms/clean-rooms.go | 258 ++++++++++++++++++ cmd/workspace/cmd.go | 3 + cmd/workspace/dashboards/dashboards.go | 6 +- cmd/workspace/experiments/experiments.go | 2 +- cmd/workspace/groups/groups.go | 3 +- .../instance-profiles/instance-profiles.go | 4 +- cmd/workspace/jobs/jobs.go | 22 +- cmd/workspace/metastores/metastores.go | 140 +++++----- cmd/workspace/pipelines/pipelines.go | 20 +- .../policy-families/policy-families.go | 12 +- cmd/workspace/queries/queries.go | 16 +- .../service-principals/service-principals.go | 3 +- cmd/workspace/tables/tables.go | 61 +++++ cmd/workspace/users/users.go | 3 +- 24 files changed, 482 insertions(+), 174 deletions(-) create mode 100644 .codegen/_openapi_sha create mode 100755 cmd/workspace/clean-rooms/clean-rooms.go diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha new file mode 100644 index 00000000..ae66d336 --- /dev/null +++ b/.codegen/_openapi_sha @@ -0,0 +1 @@ +850a075ed9758d21a6bc4409506b48c8b9f93ab4 \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 8b95da20..714d6c53 100755 --- a/.gitattributes +++ b/.gitattributes @@ -25,6 +25,7 @@ cmd/account/workspace-assignment/workspace-assignment.go linguist-generated=true cmd/account/workspaces/workspaces.go linguist-generated=true cmd/workspace/alerts/alerts.go linguist-generated=true cmd/workspace/catalogs/catalogs.go linguist-generated=true +cmd/workspace/clean-rooms/clean-rooms.go linguist-generated=true cmd/workspace/cluster-policies/cluster-policies.go linguist-generated=true cmd/workspace/clusters/clusters.go linguist-generated=true cmd/workspace/cmd.go linguist-generated=true diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a7ed72b..8c045ef0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,33 @@ # Version changelog +## 0.201.0 + +* Add development runs ([#522](https://github.com/databricks/cli/pull/522)). +* Support tab completion for profiles ([#572](https://github.com/databricks/cli/pull/572)). +* Correctly use --profile flag passed for all bundle commands ([#571](https://github.com/databricks/cli/pull/571)). +* Disallow notebooks in paths where files are expected ([#573](https://github.com/databricks/cli/pull/573)). +* Improve auth login experience ([#570](https://github.com/databricks/cli/pull/570)). +* Remove base path checks during sync ([#576](https://github.com/databricks/cli/pull/576)). +* First look for databricks.yml before falling back to bundle.yml ([#580](https://github.com/databricks/cli/pull/580)). +* Integrate with auto-release infra ([#581](https://github.com/databricks/cli/pull/581)). + +API Changes: + + * Removed `databricks metastores maintenance` command. + * Added `databricks metastores enable-optimization` command. + * Added `databricks tables update` command. + * Changed `databricks account settings delete-personal-compute-setting` command with new required argument order. + * Changed `databricks account settings read-personal-compute-setting` command with new required argument order. + * Added `databricks clean-rooms` command group. + +OpenAPI SHA: 850a075ed9758d21a6bc4409506b48c8b9f93ab4, Date: 2023-07-18 +Dependency updates: + + * Bump golang.org/x/term from 0.9.0 to 0.10.0 ([#567](https://github.com/databricks/cli/pull/567)). + * Bump golang.org/x/oauth2 from 0.9.0 to 0.10.0 ([#566](https://github.com/databricks/cli/pull/566)). + * Bump golang.org/x/mod from 0.11.0 to 0.12.0 ([#568](https://github.com/databricks/cli/pull/568)). + * Bump github.com/databricks/databricks-sdk-go from 0.12.0 to 0.13.0 ([#585](https://github.com/databricks/cli/pull/585)). + ## 0.200.2 CLI: diff --git a/cmd/account/groups/groups.go b/cmd/account/groups/groups.go index 5897ef29..55d0c781 100755 --- a/cmd/account/groups/groups.go +++ b/cmd/account/groups/groups.go @@ -258,7 +258,8 @@ func init() { // TODO: short flags patchCmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - // TODO: array: operations + // TODO: array: Operations + // TODO: array: schema } diff --git a/cmd/account/metastores/metastores.go b/cmd/account/metastores/metastores.go index decbb406..89e1c8f2 100755 --- a/cmd/account/metastores/metastores.go +++ b/cmd/account/metastores/metastores.go @@ -80,6 +80,8 @@ func init() { Cmd.AddCommand(deleteCmd) // TODO: short flags + deleteCmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `Force deletion even if the metastore is not empty.`) + } var deleteCmd = &cobra.Command{ diff --git a/cmd/account/service-principals/service-principals.go b/cmd/account/service-principals/service-principals.go index 6ed4a69a..55b7492f 100755 --- a/cmd/account/service-principals/service-principals.go +++ b/cmd/account/service-principals/service-principals.go @@ -257,7 +257,8 @@ func init() { // TODO: short flags patchCmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - // TODO: array: operations + // TODO: array: Operations + // TODO: array: schema } diff --git a/cmd/account/settings/settings.go b/cmd/account/settings/settings.go index 8c507c3f..c55c7ad6 100755 --- a/cmd/account/settings/settings.go +++ b/cmd/account/settings/settings.go @@ -12,8 +12,16 @@ import ( var Cmd = &cobra.Command{ Use: "settings", - Short: `TBD.`, - Long: `TBD`, + Short: `The Personal Compute enablement setting lets you control which users can use the Personal Compute default policy to create compute resources.`, + Long: `The Personal Compute enablement setting lets you control which users can use + the Personal Compute default policy to create compute resources. By default + all users in all workspaces have access (ON), but you can change the setting + to instead let individual workspaces configure access control (DELEGATE). + + There is only one instance of this setting per account. Since this setting has + a default value, this setting is present on all accounts even though it's + never set on a given account. Deletion reverts the value of the setting back + to the default value.`, Annotations: map[string]string{ "package": "settings", }, @@ -24,30 +32,23 @@ var Cmd = &cobra.Command{ // start delete-personal-compute-setting command var deletePersonalComputeSettingReq settings.DeletePersonalComputeSettingRequest -var deletePersonalComputeSettingJson flags.JsonFlag func init() { Cmd.AddCommand(deletePersonalComputeSettingCmd) // TODO: short flags - deletePersonalComputeSettingCmd.Flags().Var(&deletePersonalComputeSettingJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - deletePersonalComputeSettingCmd.Flags().StringVar(&deletePersonalComputeSettingReq.Etag, "etag", deletePersonalComputeSettingReq.Etag, `TBD.`) } var deletePersonalComputeSettingCmd = &cobra.Command{ - Use: "delete-personal-compute-setting", + Use: "delete-personal-compute-setting ETAG", Short: `Delete Personal Compute setting.`, Long: `Delete Personal Compute setting. - TBD`, + Reverts back the Personal Compute setting value to default (ON)`, Annotations: map[string]string{}, Args: func(cmd *cobra.Command, args []string) error { - check := cobra.ExactArgs(0) - if cmd.Flags().Changed("json") { - check = cobra.ExactArgs(0) - } + check := cobra.ExactArgs(1) return check(cmd, args) }, PreRunE: root.MustAccountClient, @@ -55,13 +56,7 @@ var deletePersonalComputeSettingCmd = &cobra.Command{ ctx := cmd.Context() a := root.AccountClient(ctx) - if cmd.Flags().Changed("json") { - err = deletePersonalComputeSettingJson.Unmarshal(&deletePersonalComputeSettingReq) - if err != nil { - return err - } - } else { - } + deletePersonalComputeSettingReq.Etag = args[0] response, err := a.Settings.DeletePersonalComputeSetting(ctx, deletePersonalComputeSettingReq) if err != nil { @@ -76,30 +71,23 @@ var deletePersonalComputeSettingCmd = &cobra.Command{ // start read-personal-compute-setting command var readPersonalComputeSettingReq settings.ReadPersonalComputeSettingRequest -var readPersonalComputeSettingJson flags.JsonFlag func init() { Cmd.AddCommand(readPersonalComputeSettingCmd) // TODO: short flags - readPersonalComputeSettingCmd.Flags().Var(&readPersonalComputeSettingJson, "json", `either inline JSON string or @path/to/file.json with request body`) - - readPersonalComputeSettingCmd.Flags().StringVar(&readPersonalComputeSettingReq.Etag, "etag", readPersonalComputeSettingReq.Etag, `TBD.`) } var readPersonalComputeSettingCmd = &cobra.Command{ - Use: "read-personal-compute-setting", + Use: "read-personal-compute-setting ETAG", Short: `Get Personal Compute setting.`, Long: `Get Personal Compute setting. - TBD`, + Gets the value of the Personal Compute setting.`, Annotations: map[string]string{}, Args: func(cmd *cobra.Command, args []string) error { - check := cobra.ExactArgs(0) - if cmd.Flags().Changed("json") { - check = cobra.ExactArgs(0) - } + check := cobra.ExactArgs(1) return check(cmd, args) }, PreRunE: root.MustAccountClient, @@ -107,13 +95,7 @@ var readPersonalComputeSettingCmd = &cobra.Command{ ctx := cmd.Context() a := root.AccountClient(ctx) - if cmd.Flags().Changed("json") { - err = readPersonalComputeSettingJson.Unmarshal(&readPersonalComputeSettingReq) - if err != nil { - return err - } - } else { - } + readPersonalComputeSettingReq.Etag = args[0] response, err := a.Settings.ReadPersonalComputeSetting(ctx, readPersonalComputeSettingReq) if err != nil { @@ -135,7 +117,7 @@ func init() { // TODO: short flags updatePersonalComputeSettingCmd.Flags().Var(&updatePersonalComputeSettingJson, "json", `either inline JSON string or @path/to/file.json with request body`) - updatePersonalComputeSettingCmd.Flags().BoolVar(&updatePersonalComputeSettingReq.AllowMissing, "allow-missing", updatePersonalComputeSettingReq.AllowMissing, `TBD.`) + updatePersonalComputeSettingCmd.Flags().BoolVar(&updatePersonalComputeSettingReq.AllowMissing, "allow-missing", updatePersonalComputeSettingReq.AllowMissing, `This should always be set to true for Settings RPCs.`) // TODO: complex arg: setting } @@ -145,7 +127,7 @@ var updatePersonalComputeSettingCmd = &cobra.Command{ Short: `Update Personal Compute setting.`, Long: `Update Personal Compute setting. - TBD`, + Updates the value of the Personal Compute setting.`, Annotations: map[string]string{}, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/account/storage-credentials/storage-credentials.go b/cmd/account/storage-credentials/storage-credentials.go index 73e328dc..f5dd5820 100755 --- a/cmd/account/storage-credentials/storage-credentials.go +++ b/cmd/account/storage-credentials/storage-credentials.go @@ -81,6 +81,8 @@ func init() { Cmd.AddCommand(deleteCmd) // TODO: short flags + deleteCmd.Flags().BoolVar(&deleteReq.Force, "force", deleteReq.Force, `Force deletion even if the Storage Credential is not empty.`) + } var deleteCmd = &cobra.Command{ diff --git a/cmd/account/users/users.go b/cmd/account/users/users.go index 8a0b40b8..3c3edd0f 100755 --- a/cmd/account/users/users.go +++ b/cmd/account/users/users.go @@ -265,7 +265,8 @@ func init() { // TODO: short flags patchCmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - // TODO: array: operations + // TODO: array: Operations + // TODO: array: schema } diff --git a/cmd/workspace/alerts/alerts.go b/cmd/workspace/alerts/alerts.go index 91417c63..e13f7284 100755 --- a/cmd/workspace/alerts/alerts.go +++ b/cmd/workspace/alerts/alerts.go @@ -34,7 +34,7 @@ func init() { // TODO: short flags createCmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - createCmd.Flags().StringVar(&createReq.Parent, "parent", createReq.Parent, `The identifier of the workspace folder containing the alert.`) + createCmd.Flags().StringVar(&createReq.Parent, "parent", createReq.Parent, `The identifier of the workspace folder containing the object.`) createCmd.Flags().IntVar(&createReq.Rearm, "rearm", createReq.Rearm, `Number of seconds after being triggered before the alert rearms itself and can be triggered again.`) } diff --git a/cmd/workspace/clean-rooms/clean-rooms.go b/cmd/workspace/clean-rooms/clean-rooms.go new file mode 100755 index 00000000..328ed3e7 --- /dev/null +++ b/cmd/workspace/clean-rooms/clean-rooms.go @@ -0,0 +1,258 @@ +// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. + +package clean_rooms + +import ( + "fmt" + + "github.com/databricks/cli/cmd/root" + "github.com/databricks/cli/libs/cmdio" + "github.com/databricks/cli/libs/flags" + "github.com/databricks/databricks-sdk-go/service/sharing" + "github.com/spf13/cobra" +) + +var Cmd = &cobra.Command{ + Use: "clean-rooms", + Short: `A clean room is a secure, privacy-protecting environment where two or more parties can share sensitive enterprise data, including customer data, for measurements, insights, activation and other use cases.`, + Long: `A clean room is a secure, privacy-protecting environment where two or more + parties can share sensitive enterprise data, including customer data, for + measurements, insights, activation and other use cases. + + To create clean rooms, you must be a metastore admin or a user with the + **CREATE_CLEAN_ROOM** privilege.`, + Annotations: map[string]string{ + "package": "sharing", + }, + + // This service is being previewed; hide from help output. + Hidden: true, +} + +// start create command +var createReq sharing.CreateCleanRoom +var createJson flags.JsonFlag + +func init() { + Cmd.AddCommand(createCmd) + // TODO: short flags + createCmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + createCmd.Flags().StringVar(&createReq.Comment, "comment", createReq.Comment, `User-provided free-form text description.`) + +} + +var createCmd = &cobra.Command{ + Use: "create", + Short: `Create a clean room.`, + Long: `Create a clean room. + + Creates a new clean room with specified colaborators. The caller must be a + metastore admin or have the **CREATE_CLEAN_ROOM** privilege on the metastore.`, + + Annotations: map[string]string{}, + PreRunE: root.MustWorkspaceClient, + RunE: func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := root.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + err = createJson.Unmarshal(&createReq) + if err != nil { + return err + } + } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + + response, err := w.CleanRooms.Create(ctx, createReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + }, + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + ValidArgsFunction: cobra.NoFileCompletions, +} + +// start delete command +var deleteReq sharing.DeleteCleanRoomRequest + +func init() { + Cmd.AddCommand(deleteCmd) + // TODO: short flags + +} + +var deleteCmd = &cobra.Command{ + Use: "delete NAME_ARG", + Short: `Delete a clean room.`, + Long: `Delete a clean room. + + Deletes a data object clean room from the metastore. The caller must be an + owner of the clean room.`, + + Annotations: map[string]string{}, + Args: func(cmd *cobra.Command, args []string) error { + check := cobra.ExactArgs(1) + return check(cmd, args) + }, + PreRunE: root.MustWorkspaceClient, + RunE: func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := root.WorkspaceClient(ctx) + + deleteReq.NameArg = args[0] + + err = w.CleanRooms.Delete(ctx, deleteReq) + if err != nil { + return err + } + return nil + }, + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + ValidArgsFunction: cobra.NoFileCompletions, +} + +// start get command +var getReq sharing.GetCleanRoomRequest + +func init() { + Cmd.AddCommand(getCmd) + // TODO: short flags + + getCmd.Flags().BoolVar(&getReq.IncludeRemoteDetails, "include-remote-details", getReq.IncludeRemoteDetails, `Whether to include remote details (central) on the clean room.`) + +} + +var getCmd = &cobra.Command{ + Use: "get NAME_ARG", + Short: `Get a clean room.`, + Long: `Get a clean room. + + Gets a data object clean room from the metastore. The caller must be a + metastore admin or the owner of the clean room.`, + + Annotations: map[string]string{}, + Args: func(cmd *cobra.Command, args []string) error { + check := cobra.ExactArgs(1) + return check(cmd, args) + }, + PreRunE: root.MustWorkspaceClient, + RunE: func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := root.WorkspaceClient(ctx) + + getReq.NameArg = args[0] + + response, err := w.CleanRooms.Get(ctx, getReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + }, + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + ValidArgsFunction: cobra.NoFileCompletions, +} + +// start list command + +func init() { + Cmd.AddCommand(listCmd) + +} + +var listCmd = &cobra.Command{ + Use: "list", + Short: `List clean rooms.`, + Long: `List clean rooms. + + Gets an array of data object clean rooms from the metastore. The caller must + be a metastore admin or the owner of the clean room. There is no guarantee of + a specific ordering of the elements in the array.`, + + Annotations: map[string]string{}, + PreRunE: root.MustWorkspaceClient, + RunE: func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := root.WorkspaceClient(ctx) + response, err := w.CleanRooms.ListAll(ctx) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + }, + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + ValidArgsFunction: cobra.NoFileCompletions, +} + +// start update command +var updateReq sharing.UpdateCleanRoom +var updateJson flags.JsonFlag + +func init() { + Cmd.AddCommand(updateCmd) + // TODO: short flags + updateCmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + // TODO: array: catalog_updates + updateCmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `User-provided free-form text description.`) + updateCmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `Name of the clean room.`) + updateCmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, `Username of current owner of clean room.`) + +} + +var updateCmd = &cobra.Command{ + Use: "update NAME_ARG", + Short: `Update a clean room.`, + Long: `Update a clean room. + + Updates the clean room with the changes and data objects in the request. The + caller must be the owner of the clean room or a metastore admin. + + When the caller is a metastore admin, only the __owner__ field can be updated. + + In the case that the clean room name is changed **updateCleanRoom** requires + that the caller is both the clean room owner and a metastore admin. + + For each table that is added through this method, the clean room owner must + also have **SELECT** privilege on the table. The privilege must be maintained + indefinitely for recipients to be able to access the table. Typically, you + should use a group as the clean room owner. + + Table removals through **update** do not require additional privileges.`, + + Annotations: map[string]string{}, + Args: func(cmd *cobra.Command, args []string) error { + check := cobra.ExactArgs(1) + return check(cmd, args) + }, + PreRunE: root.MustWorkspaceClient, + RunE: func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := root.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + err = updateJson.Unmarshal(&updateReq) + if err != nil { + return err + } + } + updateReq.NameArg = args[0] + + response, err := w.CleanRooms.Update(ctx, updateReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + }, + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + ValidArgsFunction: cobra.NoFileCompletions, +} + +// end service CleanRooms diff --git a/cmd/workspace/cmd.go b/cmd/workspace/cmd.go index 68ce3ef0..596dba82 100755 --- a/cmd/workspace/cmd.go +++ b/cmd/workspace/cmd.go @@ -7,6 +7,7 @@ import ( alerts "github.com/databricks/cli/cmd/workspace/alerts" catalogs "github.com/databricks/cli/cmd/workspace/catalogs" + clean_rooms "github.com/databricks/cli/cmd/workspace/clean-rooms" cluster_policies "github.com/databricks/cli/cmd/workspace/cluster-policies" clusters "github.com/databricks/cli/cmd/workspace/clusters" connections "github.com/databricks/cli/cmd/workspace/connections" @@ -58,6 +59,7 @@ import ( func init() { root.RootCmd.AddCommand(alerts.Cmd) root.RootCmd.AddCommand(catalogs.Cmd) + root.RootCmd.AddCommand(clean_rooms.Cmd) root.RootCmd.AddCommand(cluster_policies.Cmd) root.RootCmd.AddCommand(clusters.Cmd) root.RootCmd.AddCommand(connections.Cmd) @@ -108,6 +110,7 @@ func init() { // Register commands with groups alerts.Cmd.GroupID = "sql" catalogs.Cmd.GroupID = "catalog" + clean_rooms.Cmd.GroupID = "sharing" cluster_policies.Cmd.GroupID = "compute" clusters.Cmd.GroupID = "compute" connections.Cmd.GroupID = "catalog" diff --git a/cmd/workspace/dashboards/dashboards.go b/cmd/workspace/dashboards/dashboards.go index b18ddff8..014be02f 100755 --- a/cmd/workspace/dashboards/dashboards.go +++ b/cmd/workspace/dashboards/dashboards.go @@ -35,11 +35,6 @@ func init() { // TODO: short flags createCmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - createCmd.Flags().BoolVar(&createReq.IsFavorite, "is-favorite", createReq.IsFavorite, `Indicates whether this query object should appear in the current user's favorites list.`) - createCmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `The title of this dashboard that appears in list views and at the top of the dashboard page.`) - createCmd.Flags().StringVar(&createReq.Parent, "parent", createReq.Parent, `The identifier of the workspace folder containing the dashboard.`) - // TODO: array: tags - } var createCmd = &cobra.Command{ @@ -66,6 +61,7 @@ var createCmd = &cobra.Command{ return err } } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") } response, err := w.Dashboards.Create(ctx, createReq) diff --git a/cmd/workspace/experiments/experiments.go b/cmd/workspace/experiments/experiments.go index 738c0240..a95da2f5 100755 --- a/cmd/workspace/experiments/experiments.go +++ b/cmd/workspace/experiments/experiments.go @@ -645,7 +645,7 @@ var logBatchCmd = &cobra.Command{ The following limits also apply to metric, param, and tag keys and values: - * Metric keyes, param keys, and tag keys can be up to 250 characters in length + * Metric keys, param keys, and tag keys can be up to 250 characters in length * Parameter and tag values can be up to 250 characters in length`, Annotations: map[string]string{}, diff --git a/cmd/workspace/groups/groups.go b/cmd/workspace/groups/groups.go index bdadd112..39a95aad 100755 --- a/cmd/workspace/groups/groups.go +++ b/cmd/workspace/groups/groups.go @@ -258,7 +258,8 @@ func init() { // TODO: short flags patchCmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - // TODO: array: operations + // TODO: array: Operations + // TODO: array: schema } diff --git a/cmd/workspace/instance-profiles/instance-profiles.go b/cmd/workspace/instance-profiles/instance-profiles.go index ee2d9280..17eea267 100755 --- a/cmd/workspace/instance-profiles/instance-profiles.go +++ b/cmd/workspace/instance-profiles/instance-profiles.go @@ -34,7 +34,7 @@ func init() { addCmd.Flags().Var(&addJson, "json", `either inline JSON string or @path/to/file.json with request body`) addCmd.Flags().StringVar(&addReq.IamRoleArn, "iam-role-arn", addReq.IamRoleArn, `The AWS IAM role ARN of the role associated with the instance profile.`) - addCmd.Flags().BoolVar(&addReq.IsMetaInstanceProfile, "is-meta-instance-profile", addReq.IsMetaInstanceProfile, `By default, Databricks validates that it has sufficient permissions to launch instances with the instance profile.`) + addCmd.Flags().BoolVar(&addReq.IsMetaInstanceProfile, "is-meta-instance-profile", addReq.IsMetaInstanceProfile, `Boolean flag indicating whether the instance profile should only be used in credential passthrough scenarios.`) addCmd.Flags().BoolVar(&addReq.SkipValidation, "skip-validation", addReq.SkipValidation, `By default, Databricks validates that it has sufficient permissions to launch instances with the instance profile.`) } @@ -90,7 +90,7 @@ func init() { editCmd.Flags().Var(&editJson, "json", `either inline JSON string or @path/to/file.json with request body`) editCmd.Flags().StringVar(&editReq.IamRoleArn, "iam-role-arn", editReq.IamRoleArn, `The AWS IAM role ARN of the role associated with the instance profile.`) - editCmd.Flags().BoolVar(&editReq.IsMetaInstanceProfile, "is-meta-instance-profile", editReq.IsMetaInstanceProfile, `By default, Databricks validates that it has sufficient permissions to launch instances with the instance profile.`) + editCmd.Flags().BoolVar(&editReq.IsMetaInstanceProfile, "is-meta-instance-profile", editReq.IsMetaInstanceProfile, `Boolean flag indicating whether the instance profile should only be used in credential passthrough scenarios.`) } diff --git a/cmd/workspace/jobs/jobs.go b/cmd/workspace/jobs/jobs.go index 1dfb065b..41101bdb 100755 --- a/cmd/workspace/jobs/jobs.go +++ b/cmd/workspace/jobs/jobs.go @@ -203,25 +203,6 @@ func init() { // TODO: short flags createCmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - // TODO: array: access_control_list - // TODO: array: compute - // TODO: complex arg: continuous - // TODO: complex arg: email_notifications - createCmd.Flags().Var(&createReq.Format, "format", `Used to tell what is the format of the job.`) - // TODO: complex arg: git_source - // TODO: array: job_clusters - createCmd.Flags().IntVar(&createReq.MaxConcurrentRuns, "max-concurrent-runs", createReq.MaxConcurrentRuns, `An optional maximum allowed number of concurrent runs of the job.`) - createCmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `An optional name for the job.`) - // TODO: complex arg: notification_settings - // TODO: array: parameters - // TODO: complex arg: run_as - // TODO: complex arg: schedule - // TODO: map via StringToStringVar: tags - // TODO: array: tasks - createCmd.Flags().IntVar(&createReq.TimeoutSeconds, "timeout-seconds", createReq.TimeoutSeconds, `An optional timeout applied to each run of this job.`) - // TODO: complex arg: trigger - // TODO: complex arg: webhook_notifications - } var createCmd = &cobra.Command{ @@ -250,6 +231,7 @@ var createCmd = &cobra.Command{ return err } } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") } response, err := w.Jobs.Create(ctx, createReq) @@ -1012,7 +994,9 @@ func init() { submitCmd.Flags().Var(&submitJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: array: access_control_list + // TODO: complex arg: email_notifications // TODO: complex arg: git_source + // TODO: complex arg: health submitCmd.Flags().StringVar(&submitReq.IdempotencyToken, "idempotency-token", submitReq.IdempotencyToken, `An optional token that can be used to guarantee the idempotency of job run requests.`) // TODO: complex arg: notification_settings submitCmd.Flags().StringVar(&submitReq.RunName, "run-name", submitReq.RunName, `An optional name for the run.`) diff --git a/cmd/workspace/metastores/metastores.go b/cmd/workspace/metastores/metastores.go index 1f27e0b8..9db023a7 100755 --- a/cmd/workspace/metastores/metastores.go +++ b/cmd/workspace/metastores/metastores.go @@ -20,10 +20,10 @@ var Cmd = &cobra.Command{ Databricks account admins can create metastores and assign them to Databricks workspaces to control which workloads use each metastore. For a workspace to use Unity Catalog, it must have a Unity Catalog metastore attached. - + Each metastore is configured with a root storage location in a cloud storage account. This storage location is used for metadata and managed tables data. - + NOTE: This metastore is distinct from the metastore included in Databricks workspaces created before Unity Catalog was released. If your workspace includes a legacy Hive metastore, the data in that metastore is available in a @@ -46,7 +46,7 @@ var assignCmd = &cobra.Command{ Use: "assign METASTORE_ID DEFAULT_CATALOG_NAME WORKSPACE_ID", Short: `Create an assignment.`, Long: `Create an assignment. - + Creates a new metastore assignment. If an assignment for the same __workspace_id__ exists, it will be overwritten by the new __metastore_id__ and __default_catalog_name__. The caller must be an account admin.`, @@ -96,7 +96,7 @@ var createCmd = &cobra.Command{ Use: "create NAME STORAGE_ROOT", Short: `Create a metastore.`, Long: `Create a metastore. - + Creates a new metastore based on a provided name and storage root path.`, Annotations: map[string]string{}, @@ -144,7 +144,7 @@ var currentCmd = &cobra.Command{ Use: "current", Short: `Get metastore assignment for workspace.`, Long: `Get metastore assignment for workspace. - + Gets the metastore assignment for the workspace being accessed.`, Annotations: map[string]string{}, @@ -178,7 +178,7 @@ var deleteCmd = &cobra.Command{ Use: "delete ID", Short: `Delete a metastore.`, Long: `Delete a metastore. - + Deletes a metastore. The caller must be a metastore admin.`, Annotations: map[string]string{}, @@ -217,6 +217,64 @@ var deleteCmd = &cobra.Command{ ValidArgsFunction: cobra.NoFileCompletions, } +// start enable-optimization command +var enableOptimizationReq catalog.UpdatePredictiveOptimization +var enableOptimizationJson flags.JsonFlag + +func init() { + Cmd.AddCommand(enableOptimizationCmd) + // TODO: short flags + enableOptimizationCmd.Flags().Var(&enableOptimizationJson, "json", `either inline JSON string or @path/to/file.json with request body`) + +} + +var enableOptimizationCmd = &cobra.Command{ + Use: "enable-optimization METASTORE_ID ENABLE", + Short: `Toggle predictive optimization on the metastore.`, + Long: `Toggle predictive optimization on the metastore. + + Enables or disables predictive optimization on the metastore.`, + + // This command is being previewed; hide from help output. + Hidden: true, + + Annotations: map[string]string{}, + Args: func(cmd *cobra.Command, args []string) error { + check := cobra.ExactArgs(2) + if cmd.Flags().Changed("json") { + check = cobra.ExactArgs(0) + } + return check(cmd, args) + }, + PreRunE: root.MustWorkspaceClient, + RunE: func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := root.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + err = enableOptimizationJson.Unmarshal(&enableOptimizationReq) + if err != nil { + return err + } + } else { + enableOptimizationReq.MetastoreId = args[0] + _, err = fmt.Sscan(args[1], &enableOptimizationReq.Enable) + if err != nil { + return fmt.Errorf("invalid ENABLE: %s", args[1]) + } + } + + response, err := w.Metastores.EnableOptimization(ctx, enableOptimizationReq) + if err != nil { + return err + } + return cmdio.Render(ctx, response) + }, + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + ValidArgsFunction: cobra.NoFileCompletions, +} + // start get command var getReq catalog.GetMetastoreRequest @@ -230,7 +288,7 @@ var getCmd = &cobra.Command{ Use: "get ID", Short: `Get a metastore.`, Long: `Get a metastore. - + Gets a metastore that matches the supplied ID. The caller must be a metastore admin to retrieve this info.`, @@ -281,7 +339,7 @@ var listCmd = &cobra.Command{ Use: "list", Short: `List metastores.`, Long: `List metastores. - + Gets an array of the available metastores (as __MetastoreInfo__ objects). The caller must be an admin to retrieve this info. There is no guarantee of a specific ordering of the elements in the array.`, @@ -302,64 +360,6 @@ var listCmd = &cobra.Command{ ValidArgsFunction: cobra.NoFileCompletions, } -// start maintenance command -var maintenanceReq catalog.UpdatePredictiveOptimization -var maintenanceJson flags.JsonFlag - -func init() { - Cmd.AddCommand(maintenanceCmd) - // TODO: short flags - maintenanceCmd.Flags().Var(&maintenanceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - -} - -var maintenanceCmd = &cobra.Command{ - Use: "maintenance METASTORE_ID ENABLE", - Short: `Enables or disables auto maintenance on the metastore.`, - Long: `Enables or disables auto maintenance on the metastore. - - Enables or disables auto maintenance on the metastore.`, - - // This command is being previewed; hide from help output. - Hidden: true, - - Annotations: map[string]string{}, - Args: func(cmd *cobra.Command, args []string) error { - check := cobra.ExactArgs(2) - if cmd.Flags().Changed("json") { - check = cobra.ExactArgs(0) - } - return check(cmd, args) - }, - PreRunE: root.MustWorkspaceClient, - RunE: func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := root.WorkspaceClient(ctx) - - if cmd.Flags().Changed("json") { - err = maintenanceJson.Unmarshal(&maintenanceReq) - if err != nil { - return err - } - } else { - maintenanceReq.MetastoreId = args[0] - _, err = fmt.Sscan(args[1], &maintenanceReq.Enable) - if err != nil { - return fmt.Errorf("invalid ENABLE: %s", args[1]) - } - } - - response, err := w.Metastores.EnableOptimization(ctx, maintenanceReq) - if err != nil { - return err - } - return cmdio.Render(ctx, response) - }, - // Disable completions since they are not applicable. - // Can be overridden by manual implementation in `override.go`. - ValidArgsFunction: cobra.NoFileCompletions, -} - // start summary command func init() { @@ -371,7 +371,7 @@ var summaryCmd = &cobra.Command{ Use: "summary", Short: `Get a metastore summary.`, Long: `Get a metastore summary. - + Gets information about a metastore. This summary includes the storage credential, the cloud vendor, the cloud region, and the global metastore ID.`, @@ -404,7 +404,7 @@ var unassignCmd = &cobra.Command{ Use: "unassign WORKSPACE_ID METASTORE_ID", Short: `Delete an assignment.`, Long: `Delete an assignment. - + Deletes a metastore assignment. The caller must be an account administrator.`, Annotations: map[string]string{}, @@ -455,7 +455,7 @@ var updateCmd = &cobra.Command{ Use: "update ID", Short: `Update a metastore.`, Long: `Update a metastore. - + Updates information for a specific metastore. The caller must be a metastore admin.`, @@ -511,7 +511,7 @@ var updateAssignmentCmd = &cobra.Command{ Use: "update-assignment WORKSPACE_ID", Short: `Update an assignment.`, Long: `Update an assignment. - + Updates a metastore assignment. This operation can be used to update __metastore_id__ or __default_catalog_name__ for a specified Workspace, if the Workspace is already assigned a metastore. The caller must be an account admin diff --git a/cmd/workspace/pipelines/pipelines.go b/cmd/workspace/pipelines/pipelines.go index 8d6ffff1..10f37846 100755 --- a/cmd/workspace/pipelines/pipelines.go +++ b/cmd/workspace/pipelines/pipelines.go @@ -44,25 +44,6 @@ func init() { // TODO: short flags createCmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - createCmd.Flags().BoolVar(&createReq.AllowDuplicateNames, "allow-duplicate-names", createReq.AllowDuplicateNames, `If false, deployment will fail if name conflicts with that of another pipeline.`) - createCmd.Flags().StringVar(&createReq.Catalog, "catalog", createReq.Catalog, `A catalog in Unity Catalog to publish data from this pipeline to.`) - createCmd.Flags().StringVar(&createReq.Channel, "channel", createReq.Channel, `DLT Release Channel that specifies which version to use.`) - // TODO: array: clusters - // TODO: map via StringToStringVar: configuration - createCmd.Flags().BoolVar(&createReq.Continuous, "continuous", createReq.Continuous, `Whether the pipeline is continuous or triggered.`) - createCmd.Flags().BoolVar(&createReq.Development, "development", createReq.Development, `Whether the pipeline is in Development mode.`) - createCmd.Flags().BoolVar(&createReq.DryRun, "dry-run", createReq.DryRun, ``) - createCmd.Flags().StringVar(&createReq.Edition, "edition", createReq.Edition, `Pipeline product edition.`) - // TODO: complex arg: filters - createCmd.Flags().StringVar(&createReq.Id, "id", createReq.Id, `Unique identifier for this pipeline.`) - // TODO: array: libraries - createCmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `Friendly identifier for this pipeline.`) - createCmd.Flags().BoolVar(&createReq.Photon, "photon", createReq.Photon, `Whether Photon is enabled for this pipeline.`) - createCmd.Flags().BoolVar(&createReq.Serverless, "serverless", createReq.Serverless, `Whether serverless compute is enabled for this pipeline.`) - createCmd.Flags().StringVar(&createReq.Storage, "storage", createReq.Storage, `DBFS root directory for storing checkpoints and tables.`) - createCmd.Flags().StringVar(&createReq.Target, "target", createReq.Target, `Target schema (database) to add tables in this pipeline to.`) - // TODO: complex arg: trigger - } var createCmd = &cobra.Command{ @@ -92,6 +73,7 @@ var createCmd = &cobra.Command{ return err } } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") } response, err := w.Pipelines.Create(ctx, createReq) diff --git a/cmd/workspace/policy-families/policy-families.go b/cmd/workspace/policy-families/policy-families.go index 37b45c8e..8954afa1 100755 --- a/cmd/workspace/policy-families/policy-families.go +++ b/cmd/workspace/policy-families/policy-families.go @@ -37,7 +37,11 @@ func init() { } var getCmd = &cobra.Command{ - Use: "get POLICY_FAMILY_ID", + Use: "get POLICY_FAMILY_ID", + Short: `Get policy family information.`, + Long: `Get policy family information. + + Retrieve the information for an policy family based on its identifier.`, Annotations: map[string]string{}, Args: func(cmd *cobra.Command, args []string) error { @@ -77,7 +81,11 @@ func init() { } var listCmd = &cobra.Command{ - Use: "list", + Use: "list", + Short: `List policy families.`, + Long: `List policy families. + + Retrieve a list of policy families. This API is paginated.`, Annotations: map[string]string{}, Args: func(cmd *cobra.Command, args []string) error { diff --git a/cmd/workspace/queries/queries.go b/cmd/workspace/queries/queries.go index 3f7e8ca3..8cf35278 100755 --- a/cmd/workspace/queries/queries.go +++ b/cmd/workspace/queries/queries.go @@ -33,13 +33,6 @@ func init() { // TODO: short flags createCmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - createCmd.Flags().StringVar(&createReq.DataSourceId, "data-source-id", createReq.DataSourceId, `The ID of the data source / SQL warehouse where this query will run.`) - createCmd.Flags().StringVar(&createReq.Description, "description", createReq.Description, `General description that can convey additional information about this query such as usage notes.`) - createCmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `The name or title of this query to display in list views.`) - // TODO: any: options - createCmd.Flags().StringVar(&createReq.Parent, "parent", createReq.Parent, `The identifier of the workspace folder containing the query.`) - createCmd.Flags().StringVar(&createReq.Query, "query", createReq.Query, `The text of the query.`) - } var createCmd = &cobra.Command{ @@ -76,6 +69,7 @@ var createCmd = &cobra.Command{ return err } } else { + return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") } response, err := w.Queries.Create(ctx, createReq) @@ -314,11 +308,11 @@ func init() { // TODO: short flags updateCmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - updateCmd.Flags().StringVar(&updateReq.DataSourceId, "data-source-id", updateReq.DataSourceId, `The ID of the data source / SQL warehouse where this query will run.`) - updateCmd.Flags().StringVar(&updateReq.Description, "description", updateReq.Description, `General description that can convey additional information about this query such as usage notes.`) - updateCmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `The name or title of this query to display in list views.`) + updateCmd.Flags().StringVar(&updateReq.DataSourceId, "data-source-id", updateReq.DataSourceId, `Data source ID.`) + updateCmd.Flags().StringVar(&updateReq.Description, "description", updateReq.Description, `General description that conveys additional information about this query such as usage notes.`) + updateCmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `The title of this query that appears in list views, widget headings, and on the query page.`) // TODO: any: options - updateCmd.Flags().StringVar(&updateReq.Query, "query", updateReq.Query, `The text of the query.`) + updateCmd.Flags().StringVar(&updateReq.Query, "query", updateReq.Query, `The text of the query to be run.`) } diff --git a/cmd/workspace/service-principals/service-principals.go b/cmd/workspace/service-principals/service-principals.go index 7dfc390f..4bb75d2b 100755 --- a/cmd/workspace/service-principals/service-principals.go +++ b/cmd/workspace/service-principals/service-principals.go @@ -257,7 +257,8 @@ func init() { // TODO: short flags patchCmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - // TODO: array: operations + // TODO: array: Operations + // TODO: array: schema } diff --git a/cmd/workspace/tables/tables.go b/cmd/workspace/tables/tables.go index 9ff653b9..d57b72f1 100755 --- a/cmd/workspace/tables/tables.go +++ b/cmd/workspace/tables/tables.go @@ -258,4 +258,65 @@ var listSummariesCmd = &cobra.Command{ ValidArgsFunction: cobra.NoFileCompletions, } +// start update command +var updateReq catalog.UpdateTableRequest + +func init() { + Cmd.AddCommand(updateCmd) + // TODO: short flags + + updateCmd.Flags().StringVar(&updateReq.Owner, "owner", updateReq.Owner, ``) + +} + +var updateCmd = &cobra.Command{ + Use: "update FULL_NAME", + Short: `Update a table owner.`, + Long: `Update a table owner. + + Change the owner of the table. The caller must be the owner of the parent + catalog, have the **USE_CATALOG** privilege on the parent catalog and be the + owner of the parent schema, or be the owner of the table and have the + **USE_CATALOG** privilege on the parent catalog and the **USE_SCHEMA** + privilege on the parent schema.`, + + // This command is being previewed; hide from help output. + Hidden: true, + + Annotations: map[string]string{}, + PreRunE: root.MustWorkspaceClient, + RunE: func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := root.WorkspaceClient(ctx) + + if len(args) == 0 { + promptSpinner := cmdio.Spinner(ctx) + promptSpinner <- "No FULL_NAME argument specified. Loading names for Tables drop-down." + names, err := w.Tables.TableInfoNameToTableIdMap(ctx, catalog.ListTablesRequest{}) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Tables drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "Full name of the table") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have full name of the table") + } + updateReq.FullName = args[0] + + err = w.Tables.Update(ctx, updateReq) + if err != nil { + return err + } + return nil + }, + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + ValidArgsFunction: cobra.NoFileCompletions, +} + // end service Tables diff --git a/cmd/workspace/users/users.go b/cmd/workspace/users/users.go index 570a8f79..71fdcf9e 100755 --- a/cmd/workspace/users/users.go +++ b/cmd/workspace/users/users.go @@ -265,7 +265,8 @@ func init() { // TODO: short flags patchCmd.Flags().Var(&patchJson, "json", `either inline JSON string or @path/to/file.json with request body`) - // TODO: array: operations + // TODO: array: Operations + // TODO: array: schema }