From 9b104993e56bbb7dad9b9a08f0ea0b02ba992581 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 12:00:14 +0000 Subject: [PATCH 1/4] Bump github.com/databricks/databricks-sdk-go from 0.27.0 to 0.28.0 Bumps [github.com/databricks/databricks-sdk-go](https://github.com/databricks/databricks-sdk-go) from 0.27.0 to 0.28.0. - [Release notes](https://github.com/databricks/databricks-sdk-go/releases) - [Changelog](https://github.com/databricks/databricks-sdk-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/databricks/databricks-sdk-go/compare/v0.27.0...v0.28.0) --- updated-dependencies: - dependency-name: github.com/databricks/databricks-sdk-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0f859790465..fba04f3e386 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( github.com/briandowns/spinner v1.23.0 // Apache 2.0 - github.com/databricks/databricks-sdk-go v0.27.0 // Apache 2.0 + github.com/databricks/databricks-sdk-go v0.28.0 // Apache 2.0 github.com/fatih/color v1.16.0 // MIT github.com/ghodss/yaml v1.0.0 // MIT + NOTICE github.com/google/uuid v1.5.0 // BSD-3-Clause diff --git a/go.sum b/go.sum index 2112cacb81e..22128dd79e9 100644 --- a/go.sum +++ b/go.sum @@ -29,8 +29,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= -github.com/databricks/databricks-sdk-go v0.27.0 h1:JJ9CxVE7Js08Ug/gafM1gGYx+u/je2g2I4bSYeMPPaY= -github.com/databricks/databricks-sdk-go v0.27.0/go.mod h1:AGzQDmVUcf/J9ARx2FgObcRI5RO2VZ1jehhxFM6tA60= +github.com/databricks/databricks-sdk-go v0.28.0 h1:4Dp/Mm85FJs+Whd/vj5DfsHoKwxTXCZ+7EQEGypDL4w= +github.com/databricks/databricks-sdk-go v0.28.0/go.mod h1:AGzQDmVUcf/J9ARx2FgObcRI5RO2VZ1jehhxFM6tA60= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 3713aa72ba77c74438b927fe36c8625e765f9a21 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Mon, 18 Dec 2023 16:13:21 +0100 Subject: [PATCH 2/4] regenerated cli --- .codegen/_openapi_sha | 2 +- bundle/schema/docs/bundle_descriptions.json | 20 +-- .../ip-access-lists/ip-access-lists.go | 130 ++++++++++++++---- .../ip-access-lists/ip-access-lists.go | 130 ++++++++++++++---- cmd/workspace/permissions/permissions.go | 21 ++- cmd/workspace/queries/queries.go | 2 +- .../serving-endpoints/serving-endpoints.go | 16 ++- 7 files changed, 249 insertions(+), 72 deletions(-) diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index 0d79c490d4e..2c3fb6e1314 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -63caa3cb0c05045e81d3dcf2451fa990d8670f36 \ No newline at end of file +d3853c8dee5806d04da2ae8910f273ffb35719a5 \ No newline at end of file diff --git a/bundle/schema/docs/bundle_descriptions.json b/bundle/schema/docs/bundle_descriptions.json index a53a5274cb6..7da1bacb4ef 100644 --- a/bundle/schema/docs/bundle_descriptions.json +++ b/bundle/schema/docs/bundle_descriptions.json @@ -182,7 +182,7 @@ "description": "An optional continuous property for this job. The continuous property will ensure that there is always one run executing. Only one of `schedule` and `continuous` can be used.", "properties": { "pause_status": { - "description": "Indicate whether this schedule is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." } } }, @@ -692,7 +692,7 @@ "description": "An optional periodic schedule for this job. The default behavior is that the job only runs when triggered by clicking “Run Now” in the Jobs UI or sending an API request to `runNow`.", "properties": { "pause_status": { - "description": "Indicate whether this schedule is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." }, "quartz_cron_expression": { "description": "A Cron expression using Quartz syntax that describes the schedule for a job.\nSee [Cron Trigger](http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html)\nfor details. This field is required.\"\n" @@ -1417,7 +1417,7 @@ "description": "An optional timeout applied to each run of this job task. A value of `0` means no timeout." }, "webhook_notifications": { - "description": "A collection of system notification IDs to notify when runs of this task begin or complete. The default behavior is to not send any system notifications.", + "description": "A collection of system notification IDs to notify when runs of this job begin or complete.", "properties": { "on_duration_warning_threshold_exceeded": { "description": "An optional list of system notification IDs to call when the duration of a run exceeds the threshold specified for the `RUN_DURATION_SECONDS` metric in the `health` field. A maximum of 3 destinations can be specified for the `on_duration_warning_threshold_exceeded` property.", @@ -1489,12 +1489,12 @@ } }, "pause_status": { - "description": "Indicate whether this schedule is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." } } }, "webhook_notifications": { - "description": "A collection of system notification IDs to notify when runs of this task begin or complete. The default behavior is to not send any system notifications.", + "description": "A collection of system notification IDs to notify when runs of this job begin or complete.", "properties": { "on_duration_warning_threshold_exceeded": { "description": "An optional list of system notification IDs to call when the duration of a run exceeds the threshold specified for the `RUN_DURATION_SECONDS` metric in the `health` field. A maximum of 3 destinations can be specified for the `on_duration_warning_threshold_exceeded` property.", @@ -2541,7 +2541,7 @@ "description": "An optional continuous property for this job. The continuous property will ensure that there is always one run executing. Only one of `schedule` and `continuous` can be used.", "properties": { "pause_status": { - "description": "Indicate whether this schedule is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." } } }, @@ -3051,7 +3051,7 @@ "description": "An optional periodic schedule for this job. The default behavior is that the job only runs when triggered by clicking “Run Now” in the Jobs UI or sending an API request to `runNow`.", "properties": { "pause_status": { - "description": "Indicate whether this schedule is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." }, "quartz_cron_expression": { "description": "A Cron expression using Quartz syntax that describes the schedule for a job.\nSee [Cron Trigger](http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html)\nfor details. This field is required.\"\n" @@ -3776,7 +3776,7 @@ "description": "An optional timeout applied to each run of this job task. A value of `0` means no timeout." }, "webhook_notifications": { - "description": "A collection of system notification IDs to notify when runs of this task begin or complete. The default behavior is to not send any system notifications.", + "description": "A collection of system notification IDs to notify when runs of this job begin or complete.", "properties": { "on_duration_warning_threshold_exceeded": { "description": "An optional list of system notification IDs to call when the duration of a run exceeds the threshold specified for the `RUN_DURATION_SECONDS` metric in the `health` field. A maximum of 3 destinations can be specified for the `on_duration_warning_threshold_exceeded` property.", @@ -3848,12 +3848,12 @@ } }, "pause_status": { - "description": "Indicate whether this schedule is paused or not." + "description": "Indicate whether the continuous execution of the job is paused or not. Defaults to UNPAUSED." } } }, "webhook_notifications": { - "description": "A collection of system notification IDs to notify when runs of this task begin or complete. The default behavior is to not send any system notifications.", + "description": "A collection of system notification IDs to notify when runs of this job begin or complete.", "properties": { "on_duration_warning_threshold_exceeded": { "description": "An optional list of system notification IDs to call when the duration of a run exceeds the threshold specified for the `RUN_DURATION_SECONDS` metric in the `health` field. A maximum of 3 destinations can be specified for the `on_duration_warning_threshold_exceeded` property.", diff --git a/cmd/account/ip-access-lists/ip-access-lists.go b/cmd/account/ip-access-lists/ip-access-lists.go index 5d95614a426..f455a73b077 100755 --- a/cmd/account/ip-access-lists/ip-access-lists.go +++ b/cmd/account/ip-access-lists/ip-access-lists.go @@ -74,7 +74,9 @@ func newCreate() *cobra.Command { // TODO: short flags cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Use = "create" + // TODO: array: ip_addresses + + cmd.Use = "create LABEL LIST_TYPE" cmd.Short = `Create access list.` cmd.Long = `Create access list. @@ -91,10 +93,31 @@ func newCreate() *cobra.Command { * If the new list would block the calling user's current IP, error 400 is returned with error_code value INVALID_STATE. - It can take a few minutes for the changes to take effect.` + It can take a few minutes for the changes to take effect. + + Arguments: + LABEL: Label for the IP access list. This **cannot** be empty. + LIST_TYPE: Type of IP access list. Valid values are as follows and are + case-sensitive: + + * ALLOW: An allow list. Include this IP or range. * BLOCK: A block + list. Exclude this IP or range. IP addresses in the block list are + excluded even if they are included in an allow list.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := cobra.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'label', 'list_type' in your JSON input") + } + return nil + } + check := cobra.ExactArgs(2) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() @@ -105,8 +128,15 @@ func newCreate() *cobra.Command { if err != nil { return err } - } else { - return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + if !cmd.Flags().Changed("json") { + createReq.Label = args[0] + } + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[1], &createReq.ListType) + if err != nil { + return fmt.Errorf("invalid LIST_TYPE: %s", args[1]) + } } response, err := a.IpAccessLists.Create(ctx, createReq) @@ -154,10 +184,7 @@ func newDelete() *cobra.Command { cmd.Short = `Delete access list.` cmd.Long = `Delete access list. - Deletes an IP access list, specified by its list ID. - - Arguments: - IP_ACCESS_LIST_ID: The ID for the corresponding IP access list.` + Deletes an IP access list, specified by its list ID.` cmd.Annotations = make(map[string]string) @@ -174,14 +201,14 @@ func newDelete() *cobra.Command { if err != nil { return fmt.Errorf("failed to load names for Account Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list") + id, err := cmdio.Select(ctx, names, "") if err != nil { return err } args = append(args, id) } if len(args) != 1 { - return fmt.Errorf("expected to have the id for the corresponding ip access list") + return fmt.Errorf("expected to have ") } deleteReq.IpAccessListId = args[0] @@ -230,10 +257,7 @@ func newGet() *cobra.Command { cmd.Short = `Get IP access list.` cmd.Long = `Get IP access list. - Gets an IP access list, specified by its list ID. - - Arguments: - IP_ACCESS_LIST_ID: The ID for the corresponding IP access list.` + Gets an IP access list, specified by its list ID.` cmd.Annotations = make(map[string]string) @@ -250,14 +274,14 @@ func newGet() *cobra.Command { if err != nil { return fmt.Errorf("failed to load names for Account Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list") + id, err := cmdio.Select(ctx, names, "") if err != nil { return err } args = append(args, id) } if len(args) != 1 { - return fmt.Errorf("expected to have the id for the corresponding ip access list") + return fmt.Errorf("expected to have ") } getReq.IpAccessListId = args[0] @@ -352,9 +376,9 @@ func newReplace() *cobra.Command { // TODO: short flags cmd.Flags().Var(&replaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&replaceReq.ListId, "list-id", replaceReq.ListId, `Universally unique identifier (UUID) of the IP access list.`) + // TODO: array: ip_addresses - cmd.Use = "replace" + cmd.Use = "replace IP_ACCESS_LIST_ID LABEL LIST_TYPE ENABLED" cmd.Short = `Replace access list.` cmd.Long = `Replace access list. @@ -367,10 +391,33 @@ func newReplace() *cobra.Command { counts as a single value. Attempts to exceed that number return error 400 with error_code value QUOTA_EXCEEDED. * If the resulting list would block the calling user's current IP, error 400 is returned with error_code value - INVALID_STATE. It can take a few minutes for the changes to take effect.` + INVALID_STATE. It can take a few minutes for the changes to take effect. + + Arguments: + IP_ACCESS_LIST_ID: + LABEL: Label for the IP access list. This **cannot** be empty. + LIST_TYPE: Type of IP access list. Valid values are as follows and are + case-sensitive: + + * ALLOW: An allow list. Include this IP or range. * BLOCK: A block + list. Exclude this IP or range. IP addresses in the block list are + excluded even if they are included in an allow list. + ENABLED: Specifies whether this IP access list is enabled.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := cobra.ExactArgs(1)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only IP_ACCESS_LIST_ID as positional arguments. Provide 'label', 'list_type', 'enabled' in your JSON input") + } + return nil + } + check := cobra.ExactArgs(4) + return check(cmd, args) + } + cmd.PreRunE = root.MustAccountClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() @@ -381,8 +428,22 @@ func newReplace() *cobra.Command { if err != nil { return err } - } else { - return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + replaceReq.IpAccessListId = args[0] + if !cmd.Flags().Changed("json") { + replaceReq.Label = args[1] + } + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[2], &replaceReq.ListType) + if err != nil { + return fmt.Errorf("invalid LIST_TYPE: %s", args[2]) + } + } + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[3], &replaceReq.Enabled) + if err != nil { + return fmt.Errorf("invalid ENABLED: %s", args[3]) + } } err = a.IpAccessLists.Replace(ctx, replaceReq) @@ -428,9 +489,12 @@ func newUpdate() *cobra.Command { // TODO: short flags cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateReq.ListId, "list-id", updateReq.ListId, `Universally unique identifier (UUID) of the IP access list.`) + cmd.Flags().BoolVar(&updateReq.Enabled, "enabled", updateReq.Enabled, `Specifies whether this IP access list is enabled.`) + // TODO: array: ip_addresses + cmd.Flags().StringVar(&updateReq.Label, "label", updateReq.Label, `Label for the IP access list.`) + cmd.Flags().Var(&updateReq.ListType, "list-type", `Type of IP access list. Supported values: [ALLOW, BLOCK]`) - cmd.Use = "update" + cmd.Use = "update IP_ACCESS_LIST_ID" cmd.Short = `Update access list.` cmd.Long = `Update access list. @@ -461,9 +525,25 @@ func newUpdate() *cobra.Command { if err != nil { return err } - } else { - return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") } + if len(args) == 0 { + promptSpinner := cmdio.Spinner(ctx) + promptSpinner <- "No IP_ACCESS_LIST_ID argument specified. Loading names for Account Ip Access Lists drop-down." + names, err := a.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Account Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + updateReq.IpAccessListId = args[0] err = a.IpAccessLists.Update(ctx, updateReq) if err != nil { diff --git a/cmd/workspace/ip-access-lists/ip-access-lists.go b/cmd/workspace/ip-access-lists/ip-access-lists.go index 7f66f417248..c5bf165e5af 100755 --- a/cmd/workspace/ip-access-lists/ip-access-lists.go +++ b/cmd/workspace/ip-access-lists/ip-access-lists.go @@ -73,7 +73,9 @@ func newCreate() *cobra.Command { // TODO: short flags cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Use = "create" + // TODO: array: ip_addresses + + cmd.Use = "create LABEL LIST_TYPE" cmd.Short = `Create access list.` cmd.Long = `Create access list. @@ -92,10 +94,31 @@ func newCreate() *cobra.Command { It can take a few minutes for the changes to take effect. **Note**: Your new IP access list has no effect until you enable the feature. See - :method:workspaceconf/setStatus` + :method:workspaceconf/setStatus + + Arguments: + LABEL: Label for the IP access list. This **cannot** be empty. + LIST_TYPE: Type of IP access list. Valid values are as follows and are + case-sensitive: + + * ALLOW: An allow list. Include this IP or range. * BLOCK: A block + list. Exclude this IP or range. IP addresses in the block list are + excluded even if they are included in an allow list.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := cobra.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'label', 'list_type' in your JSON input") + } + return nil + } + check := cobra.ExactArgs(2) + return check(cmd, args) + } + cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() @@ -106,8 +129,15 @@ func newCreate() *cobra.Command { if err != nil { return err } - } else { - return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + if !cmd.Flags().Changed("json") { + createReq.Label = args[0] + } + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[1], &createReq.ListType) + if err != nil { + return fmt.Errorf("invalid LIST_TYPE: %s", args[1]) + } } response, err := w.IpAccessLists.Create(ctx, createReq) @@ -155,10 +185,7 @@ func newDelete() *cobra.Command { cmd.Short = `Delete access list.` cmd.Long = `Delete access list. - Deletes an IP access list, specified by its list ID. - - Arguments: - IP_ACCESS_LIST_ID: The ID for the corresponding IP access list to modify.` + Deletes an IP access list, specified by its list ID.` cmd.Annotations = make(map[string]string) @@ -175,14 +202,14 @@ func newDelete() *cobra.Command { if err != nil { return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list to modify") + id, err := cmdio.Select(ctx, names, "") if err != nil { return err } args = append(args, id) } if len(args) != 1 { - return fmt.Errorf("expected to have the id for the corresponding ip access list to modify") + return fmt.Errorf("expected to have ") } deleteReq.IpAccessListId = args[0] @@ -231,10 +258,7 @@ func newGet() *cobra.Command { cmd.Short = `Get access list.` cmd.Long = `Get access list. - Gets an IP access list, specified by its list ID. - - Arguments: - IP_ACCESS_LIST_ID: The ID for the corresponding IP access list to modify.` + Gets an IP access list, specified by its list ID.` cmd.Annotations = make(map[string]string) @@ -251,14 +275,14 @@ func newGet() *cobra.Command { if err != nil { return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } - id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list to modify") + id, err := cmdio.Select(ctx, names, "") if err != nil { return err } args = append(args, id) } if len(args) != 1 { - return fmt.Errorf("expected to have the id for the corresponding ip access list to modify") + return fmt.Errorf("expected to have ") } getReq.IpAccessListId = args[0] @@ -353,9 +377,9 @@ func newReplace() *cobra.Command { // TODO: short flags cmd.Flags().Var(&replaceJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&replaceReq.ListId, "list-id", replaceReq.ListId, `Universally unique identifier (UUID) of the IP access list.`) + // TODO: array: ip_addresses - cmd.Use = "replace" + cmd.Use = "replace IP_ACCESS_LIST_ID LABEL LIST_TYPE ENABLED" cmd.Short = `Replace access list.` cmd.Long = `Replace access list. @@ -370,10 +394,33 @@ func newReplace() *cobra.Command { calling user's current IP, error 400 is returned with error_code value INVALID_STATE. It can take a few minutes for the changes to take effect. Note that your resulting IP access list has no effect until you enable the - feature. See :method:workspaceconf/setStatus.` + feature. See :method:workspaceconf/setStatus. + + Arguments: + IP_ACCESS_LIST_ID: + LABEL: Label for the IP access list. This **cannot** be empty. + LIST_TYPE: Type of IP access list. Valid values are as follows and are + case-sensitive: + + * ALLOW: An allow list. Include this IP or range. * BLOCK: A block + list. Exclude this IP or range. IP addresses in the block list are + excluded even if they are included in an allow list. + ENABLED: Specifies whether this IP access list is enabled.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := cobra.ExactArgs(1)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only IP_ACCESS_LIST_ID as positional arguments. Provide 'label', 'list_type', 'enabled' in your JSON input") + } + return nil + } + check := cobra.ExactArgs(4) + return check(cmd, args) + } + cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() @@ -384,8 +431,22 @@ func newReplace() *cobra.Command { if err != nil { return err } - } else { - return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") + } + replaceReq.IpAccessListId = args[0] + if !cmd.Flags().Changed("json") { + replaceReq.Label = args[1] + } + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[2], &replaceReq.ListType) + if err != nil { + return fmt.Errorf("invalid LIST_TYPE: %s", args[2]) + } + } + if !cmd.Flags().Changed("json") { + _, err = fmt.Sscan(args[3], &replaceReq.Enabled) + if err != nil { + return fmt.Errorf("invalid ENABLED: %s", args[3]) + } } err = w.IpAccessLists.Replace(ctx, replaceReq) @@ -431,9 +492,12 @@ func newUpdate() *cobra.Command { // TODO: short flags cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateReq.ListId, "list-id", updateReq.ListId, `Universally unique identifier (UUID) of the IP access list.`) + cmd.Flags().BoolVar(&updateReq.Enabled, "enabled", updateReq.Enabled, `Specifies whether this IP access list is enabled.`) + // TODO: array: ip_addresses + cmd.Flags().StringVar(&updateReq.Label, "label", updateReq.Label, `Label for the IP access list.`) + cmd.Flags().Var(&updateReq.ListType, "list-type", `Type of IP access list. Supported values: [ALLOW, BLOCK]`) - cmd.Use = "update" + cmd.Use = "update IP_ACCESS_LIST_ID" cmd.Short = `Update access list.` cmd.Long = `Update access list. @@ -466,9 +530,25 @@ func newUpdate() *cobra.Command { if err != nil { return err } - } else { - return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") } + if len(args) == 0 { + promptSpinner := cmdio.Spinner(ctx) + promptSpinner <- "No IP_ACCESS_LIST_ID argument specified. Loading names for Ip Access Lists drop-down." + names, err := w.IpAccessLists.IpAccessListInfoLabelToListIdMap(ctx) + close(promptSpinner) + if err != nil { + return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) + } + id, err := cmdio.Select(ctx, names, "") + if err != nil { + return err + } + args = append(args, id) + } + if len(args) != 1 { + return fmt.Errorf("expected to have ") + } + updateReq.IpAccessListId = args[0] err = w.IpAccessLists.Update(ctx, updateReq) if err != nil { diff --git a/cmd/workspace/permissions/permissions.go b/cmd/workspace/permissions/permissions.go index 61edb0096b7..8aeb3fc734d 100755 --- a/cmd/workspace/permissions/permissions.go +++ b/cmd/workspace/permissions/permissions.go @@ -103,8 +103,11 @@ func newGet() *cobra.Command { parent objects or root object. Arguments: - REQUEST_OBJECT_TYPE: - REQUEST_OBJECT_ID: ` + REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: + authorization, clusters, cluster-policies, directories, experiments, + files, instance-pools, jobs, notebooks, pipelines, registered-models, + repos, serving-endpoints, or sql-warehouses. + REQUEST_OBJECT_ID: The id of the request object.` cmd.Annotations = make(map[string]string) @@ -240,8 +243,11 @@ func newSet() *cobra.Command { parent objects or root object. Arguments: - REQUEST_OBJECT_TYPE: - REQUEST_OBJECT_ID: ` + REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: + authorization, clusters, cluster-policies, directories, experiments, + files, instance-pools, jobs, notebooks, pipelines, registered-models, + repos, serving-endpoints, or sql-warehouses. + REQUEST_OBJECT_ID: The id of the request object.` cmd.Annotations = make(map[string]string) @@ -317,8 +323,11 @@ func newUpdate() *cobra.Command { their parent objects or root object. Arguments: - REQUEST_OBJECT_TYPE: - REQUEST_OBJECT_ID: ` + REQUEST_OBJECT_TYPE: The type of the request object. Can be one of the following: + authorization, clusters, cluster-policies, directories, experiments, + files, instance-pools, jobs, notebooks, pipelines, registered-models, + repos, serving-endpoints, or sql-warehouses. + REQUEST_OBJECT_ID: The id of the request object.` cmd.Annotations = make(map[string]string) diff --git a/cmd/workspace/queries/queries.go b/cmd/workspace/queries/queries.go index 6ac80000fc0..38fa9c0c510 100755 --- a/cmd/workspace/queries/queries.go +++ b/cmd/workspace/queries/queries.go @@ -417,7 +417,7 @@ func newUpdate() *cobra.Command { // TODO: short flags cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) - cmd.Flags().StringVar(&updateReq.DataSourceId, "data-source-id", updateReq.DataSourceId, `Data source ID.`) + cmd.Flags().StringVar(&updateReq.DataSourceId, "data-source-id", updateReq.DataSourceId, `Data source ID maps to the ID of the data source used by the resource and is distinct from the warehouse ID.`) cmd.Flags().StringVar(&updateReq.Description, "description", updateReq.Description, `General description that conveys additional information about this query such as usage notes.`) cmd.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 diff --git a/cmd/workspace/serving-endpoints/serving-endpoints.go b/cmd/workspace/serving-endpoints/serving-endpoints.go index a174bc457ca..8c488d093e6 100755 --- a/cmd/workspace/serving-endpoints/serving-endpoints.go +++ b/cmd/workspace/serving-endpoints/serving-endpoints.go @@ -973,20 +973,29 @@ func newUpdateConfig() *cobra.Command { cmd.Flags().Var(&updateConfigJson, "json", `either inline JSON string or @path/to/file.json with request body`) // TODO: complex arg: auto_capture_config + // TODO: array: served_entities // TODO: array: served_models // TODO: complex arg: traffic_config - cmd.Use = "update-config" + cmd.Use = "update-config NAME" cmd.Short = `Update a serving endpoint with a new config.` cmd.Long = `Update a serving endpoint with a new config. Updates any combination of the serving endpoint's served entities, the compute configuration of those served entities, and the endpoint's traffic config. An endpoint that already has an update in progress can not be updated until the - current update completes or fails.` + current update completes or fails. + + Arguments: + NAME: The name of the serving endpoint to update. This field is required.` cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := cobra.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() @@ -997,9 +1006,8 @@ func newUpdateConfig() *cobra.Command { if err != nil { return err } - } else { - return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") } + updateConfigReq.Name = args[0] wait, err := w.ServingEndpoints.UpdateConfig(ctx, updateConfigReq) if err != nil { From 436f2fa4645fe746293573e73aa11042c3ff696e Mon Sep 17 00:00:00 2001 From: monalisa Date: Tue, 19 Dec 2023 22:08:26 +0530 Subject: [PATCH 3/4] regenerate CLI with the latest deco tool --- bundle/schema/docs/bundle_descriptions.json | 8 ++--- .../dashboard-widgets/dashboard-widgets.go | 5 +++- .../ip-access-lists/ip-access-lists.go | 29 ++++++++++++------- .../query-visualizations.go | 5 +++- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/bundle/schema/docs/bundle_descriptions.json b/bundle/schema/docs/bundle_descriptions.json index 7da1bacb4ef..789d879fb6b 100644 --- a/bundle/schema/docs/bundle_descriptions.json +++ b/bundle/schema/docs/bundle_descriptions.json @@ -1210,7 +1210,7 @@ "description": "The path of the notebook to be run in the Databricks workspace or remote repository.\nFor notebooks stored in the Databricks workspace, the path must be absolute and begin with a slash.\nFor notebooks stored in a remote repository, the path must be relative. This field is required.\n" }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved\nfrom the local \u003cDatabricks\u003e workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a \u003cDatabricks\u003e workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository.\n" + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved\nfrom the local \u003cDatabricks\u003e workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n\n* `WORKSPACE`: Notebook is located in \u003cDatabricks\u003e workspace.\n* `GIT`: Notebook is located in cloud Git provider.\n" } } }, @@ -1312,7 +1312,7 @@ "description": "The Python file to be executed. Cloud file URIs (such as dbfs:/, s3:/, adls:/, gcs:/) and workspace paths are supported. For python files stored in the Databricks workspace, the path must be absolute and begin with `/`. For files stored in a remote repository, the path must be relative. This field is required." }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved\nfrom the local \u003cDatabricks\u003e workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a \u003cDatabricks\u003e workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository.\n" + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved\nfrom the local \u003cDatabricks\u003e workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n\n* `WORKSPACE`: Notebook is located in \u003cDatabricks\u003e workspace.\n* `GIT`: Notebook is located in cloud Git provider.\n" } } }, @@ -3569,7 +3569,7 @@ "description": "The path of the notebook to be run in the Databricks workspace or remote repository.\nFor notebooks stored in the Databricks workspace, the path must be absolute and begin with a slash.\nFor notebooks stored in a remote repository, the path must be relative. This field is required.\n" }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved\nfrom the local \u003cDatabricks\u003e workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a \u003cDatabricks\u003e workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository.\n" + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved\nfrom the local \u003cDatabricks\u003e workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n\n* `WORKSPACE`: Notebook is located in \u003cDatabricks\u003e workspace.\n* `GIT`: Notebook is located in cloud Git provider.\n" } } }, @@ -3671,7 +3671,7 @@ "description": "The Python file to be executed. Cloud file URIs (such as dbfs:/, s3:/, adls:/, gcs:/) and workspace paths are supported. For python files stored in the Databricks workspace, the path must be absolute and begin with `/`. For files stored in a remote repository, the path must be relative. This field is required." }, "source": { - "description": "Optional location type of the Python file. When set to `WORKSPACE` or not specified, the file will be retrieved\nfrom the local \u003cDatabricks\u003e workspace or cloud location (if the `python_file` has a URI format). When set to `GIT`,\nthe Python file will be retrieved from a Git repository defined in `git_source`.\n\n* `WORKSPACE`: The Python file is located in a \u003cDatabricks\u003e workspace or at a cloud filesystem URI.\n* `GIT`: The Python file is located in a remote Git repository.\n" + "description": "Optional location type of the notebook. When set to `WORKSPACE`, the notebook will be retrieved\nfrom the local \u003cDatabricks\u003e workspace. When set to `GIT`, the notebook will be retrieved from a Git repository\ndefined in `git_source`. If the value is empty, the task will use `GIT` if `git_source` is defined and `WORKSPACE` otherwise.\n\n* `WORKSPACE`: Notebook is located in \u003cDatabricks\u003e workspace.\n* `GIT`: Notebook is located in cloud Git provider.\n" } } }, diff --git a/cmd/workspace/dashboard-widgets/dashboard-widgets.go b/cmd/workspace/dashboard-widgets/dashboard-widgets.go index 63e8d120ca7..c3b3ae03616 100755 --- a/cmd/workspace/dashboard-widgets/dashboard-widgets.go +++ b/cmd/workspace/dashboard-widgets/dashboard-widgets.go @@ -121,7 +121,10 @@ func newDelete() *cobra.Command { cmd.Use = "delete ID" cmd.Short = `Remove widget.` - cmd.Long = `Remove widget.` + cmd.Long = `Remove widget. + + Arguments: + ID: Widget ID returned by :method:dashboardwidgets/create` cmd.Annotations = make(map[string]string) diff --git a/cmd/workspace/ip-access-lists/ip-access-lists.go b/cmd/workspace/ip-access-lists/ip-access-lists.go index c5bf165e5af..f55d4fdca88 100755 --- a/cmd/workspace/ip-access-lists/ip-access-lists.go +++ b/cmd/workspace/ip-access-lists/ip-access-lists.go @@ -185,7 +185,10 @@ func newDelete() *cobra.Command { cmd.Short = `Delete access list.` cmd.Long = `Delete access list. - Deletes an IP access list, specified by its list ID.` + Deletes an IP access list, specified by its list ID. + + Arguments: + IP_ACCESS_LIST_ID: The ID for the corresponding IP access list to modify` cmd.Annotations = make(map[string]string) @@ -202,14 +205,14 @@ func newDelete() *cobra.Command { if err != nil { return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } - id, err := cmdio.Select(ctx, names, "") + id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list to modify") if err != nil { return err } args = append(args, id) } if len(args) != 1 { - return fmt.Errorf("expected to have ") + return fmt.Errorf("expected to have the id for the corresponding ip access list to modify") } deleteReq.IpAccessListId = args[0] @@ -258,7 +261,10 @@ func newGet() *cobra.Command { cmd.Short = `Get access list.` cmd.Long = `Get access list. - Gets an IP access list, specified by its list ID.` + Gets an IP access list, specified by its list ID. + + Arguments: + IP_ACCESS_LIST_ID: The ID for the corresponding IP access list to modify` cmd.Annotations = make(map[string]string) @@ -275,14 +281,14 @@ func newGet() *cobra.Command { if err != nil { return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } - id, err := cmdio.Select(ctx, names, "") + id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list to modify") if err != nil { return err } args = append(args, id) } if len(args) != 1 { - return fmt.Errorf("expected to have ") + return fmt.Errorf("expected to have the id for the corresponding ip access list to modify") } getReq.IpAccessListId = args[0] @@ -397,7 +403,7 @@ func newReplace() *cobra.Command { feature. See :method:workspaceconf/setStatus. Arguments: - IP_ACCESS_LIST_ID: + IP_ACCESS_LIST_ID: The ID for the corresponding IP access list to modify LABEL: Label for the IP access list. This **cannot** be empty. LIST_TYPE: Type of IP access list. Valid values are as follows and are case-sensitive: @@ -516,7 +522,10 @@ func newUpdate() *cobra.Command { It can take a few minutes for the changes to take effect. Note that your resulting IP access list has no effect until you enable the feature. See - :method:workspaceconf/setStatus.` + :method:workspaceconf/setStatus. + + Arguments: + IP_ACCESS_LIST_ID: The ID for the corresponding IP access list to modify` cmd.Annotations = make(map[string]string) @@ -539,14 +548,14 @@ func newUpdate() *cobra.Command { if err != nil { return fmt.Errorf("failed to load names for Ip Access Lists drop-down. Please manually specify required arguments. Original error: %w", err) } - id, err := cmdio.Select(ctx, names, "") + id, err := cmdio.Select(ctx, names, "The ID for the corresponding IP access list to modify") if err != nil { return err } args = append(args, id) } if len(args) != 1 { - return fmt.Errorf("expected to have ") + return fmt.Errorf("expected to have the id for the corresponding ip access list to modify") } updateReq.IpAccessListId = args[0] diff --git a/cmd/workspace/query-visualizations/query-visualizations.go b/cmd/workspace/query-visualizations/query-visualizations.go index 11630084076..042faa5b7b5 100755 --- a/cmd/workspace/query-visualizations/query-visualizations.go +++ b/cmd/workspace/query-visualizations/query-visualizations.go @@ -121,7 +121,10 @@ func newDelete() *cobra.Command { cmd.Use = "delete ID" cmd.Short = `Remove visualization.` - cmd.Long = `Remove visualization.` + cmd.Long = `Remove visualization. + + Arguments: + ID: Widget ID returned by :method:queryvizualisations/create` cmd.Annotations = make(map[string]string) From 29f8ef2f42745f1358467ad8d87653bfe1d37a8d Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Thu, 4 Jan 2024 12:32:56 +0100 Subject: [PATCH 4/4] upgrade to 0.28.1 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b869901aa16..cc34d2d90c8 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21 require ( github.com/briandowns/spinner v1.23.0 // Apache 2.0 - github.com/databricks/databricks-sdk-go v0.28.0 // Apache 2.0 + github.com/databricks/databricks-sdk-go v0.28.1 // Apache 2.0 github.com/fatih/color v1.16.0 // MIT github.com/ghodss/yaml v1.0.0 // MIT + NOTICE github.com/google/uuid v1.5.0 // BSD-3-Clause diff --git a/go.sum b/go.sum index 827e28aca99..2ea6aa846e0 100644 --- a/go.sum +++ b/go.sum @@ -29,8 +29,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= -github.com/databricks/databricks-sdk-go v0.28.0 h1:4Dp/Mm85FJs+Whd/vj5DfsHoKwxTXCZ+7EQEGypDL4w= -github.com/databricks/databricks-sdk-go v0.28.0/go.mod h1:AGzQDmVUcf/J9ARx2FgObcRI5RO2VZ1jehhxFM6tA60= +github.com/databricks/databricks-sdk-go v0.28.1 h1:RH5sPSnzQjZ0x3yWP8+omuBXKLMI2P1lJO8B7BJVhQs= +github.com/databricks/databricks-sdk-go v0.28.1/go.mod h1:AGzQDmVUcf/J9ARx2FgObcRI5RO2VZ1jehhxFM6tA60= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=