diff --git a/.codegen/_openapi_sha b/.codegen/_openapi_sha index 1f11c17b..f07cf44e 100644 --- a/.codegen/_openapi_sha +++ b/.codegen/_openapi_sha @@ -1 +1 @@ -21f9f1482f9d0d15228da59f2cd9f0863d2a6d55 \ No newline at end of file +9bb7950fa3390afb97abaa552934bc0a2e069de5 \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index f9aa02d1..fb42588a 100755 --- a/.gitattributes +++ b/.gitattributes @@ -37,6 +37,7 @@ 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 +cmd/workspace/compliance-security-profile/compliance-security-profile.go linguist-generated=true cmd/workspace/connections/connections.go linguist-generated=true cmd/workspace/consumer-fulfillments/consumer-fulfillments.go linguist-generated=true cmd/workspace/consumer-installations/consumer-installations.go linguist-generated=true @@ -44,13 +45,12 @@ cmd/workspace/consumer-listings/consumer-listings.go linguist-generated=true cmd/workspace/consumer-personalization-requests/consumer-personalization-requests.go linguist-generated=true cmd/workspace/consumer-providers/consumer-providers.go linguist-generated=true cmd/workspace/credentials-manager/credentials-manager.go linguist-generated=true -cmd/workspace/csp-enablement/csp-enablement.go linguist-generated=true cmd/workspace/current-user/current-user.go linguist-generated=true cmd/workspace/dashboard-widgets/dashboard-widgets.go linguist-generated=true cmd/workspace/dashboards/dashboards.go linguist-generated=true cmd/workspace/data-sources/data-sources.go linguist-generated=true cmd/workspace/default-namespace/default-namespace.go linguist-generated=true -cmd/workspace/esm-enablement/esm-enablement.go linguist-generated=true +cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go linguist-generated=true cmd/workspace/experiments/experiments.go linguist-generated=true cmd/workspace/external-locations/external-locations.go linguist-generated=true cmd/workspace/functions/functions.go linguist-generated=true diff --git a/bundle/schema/docs/bundle_descriptions.json b/bundle/schema/docs/bundle_descriptions.json index 01d37dd7..ba6fe8ce 100644 --- a/bundle/schema/docs/bundle_descriptions.json +++ b/bundle/schema/docs/bundle_descriptions.json @@ -1582,7 +1582,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 job begin or complete.", + "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.", "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.", @@ -4305,7 +4305,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 job begin or complete.", + "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.", "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/csp-enablement-account/csp-enablement-account.go b/cmd/account/csp-enablement-account/csp-enablement-account.go index 79819003..d6fce953 100755 --- a/cmd/account/csp-enablement-account/csp-enablement-account.go +++ b/cmd/account/csp-enablement-account/csp-enablement-account.go @@ -156,4 +156,4 @@ func newUpdate() *cobra.Command { return cmd } -// end service CSPEnablementAccount +// end service CspEnablementAccount diff --git a/cmd/account/esm-enablement-account/esm-enablement-account.go b/cmd/account/esm-enablement-account/esm-enablement-account.go index a2e95ffe..49c21eb4 100755 --- a/cmd/account/esm-enablement-account/esm-enablement-account.go +++ b/cmd/account/esm-enablement-account/esm-enablement-account.go @@ -157,4 +157,4 @@ func newUpdate() *cobra.Command { return cmd } -// end service ESMEnablementAccount +// end service EsmEnablementAccount diff --git a/cmd/workspace/apps/apps.go b/cmd/workspace/apps/apps.go index 1ea50e83..2ccd16c0 100755 --- a/cmd/workspace/apps/apps.go +++ b/cmd/workspace/apps/apps.go @@ -4,6 +4,7 @@ package apps import ( "fmt" + "time" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdio" @@ -19,10 +20,10 @@ var cmdOverrides []func(*cobra.Command) func New() *cobra.Command { cmd := &cobra.Command{ Use: "apps", - Short: `Lakehouse Apps run directly on a customer’s Databricks instance, integrate with their data, use and extend Databricks services, and enable users to interact through single sign-on.`, - Long: `Lakehouse Apps run directly on a customer’s Databricks instance, integrate - with their data, use and extend Databricks services, and enable users to - interact through single sign-on.`, + Short: `Apps run directly on a customer’s Databricks instance, integrate with their data, use and extend Databricks services, and enable users to interact through single sign-on.`, + Long: `Apps run directly on a customer’s Databricks instance, integrate with their + data, use and extend Databricks services, and enable users to interact through + single sign-on.`, GroupID: "serving", Annotations: map[string]string{ "package": "serving", @@ -34,11 +35,15 @@ func New() *cobra.Command { // Add methods cmd.AddCommand(newCreate()) - cmd.AddCommand(newDeleteApp()) - cmd.AddCommand(newGetApp()) - cmd.AddCommand(newGetAppDeploymentStatus()) - cmd.AddCommand(newGetApps()) - cmd.AddCommand(newGetEvents()) + cmd.AddCommand(newCreateDeployment()) + cmd.AddCommand(newDelete()) + cmd.AddCommand(newGet()) + cmd.AddCommand(newGetDeployment()) + cmd.AddCommand(newGetEnvironment()) + cmd.AddCommand(newList()) + cmd.AddCommand(newListDeployments()) + cmd.AddCommand(newStop()) + cmd.AddCommand(newUpdate()) // Apply optional overrides to this command. for _, fn := range cmdOverrides { @@ -54,28 +59,53 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var createOverrides []func( *cobra.Command, - *serving.DeployAppRequest, + *serving.CreateAppRequest, ) func newCreate() *cobra.Command { cmd := &cobra.Command{} - var createReq serving.DeployAppRequest + var createReq serving.CreateAppRequest var createJson flags.JsonFlag + var createSkipWait bool + var createTimeout time.Duration + + cmd.Flags().BoolVar(&createSkipWait, "no-wait", createSkipWait, `do not wait to reach IDLE state`) + cmd.Flags().DurationVar(&createTimeout, "timeout", 20*time.Minute, `maximum amount of time to reach IDLE state`) // TODO: short flags cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`) - // TODO: any: resources + cmd.Flags().StringVar(&createReq.Description, "description", createReq.Description, `The description of the app.`) - cmd.Use = "create" - cmd.Short = `Create and deploy an application.` - cmd.Long = `Create and deploy an application. + cmd.Use = "create NAME" + cmd.Short = `Create an App.` + cmd.Long = `Create an App. - Creates and deploys an application.` + Creates a new app. + + Arguments: + NAME: The name of the app. The name must contain only lowercase alphanumeric + characters and hyphens and be between 2 and 30 characters long. It must be + unique within the workspace.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(0)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'name' in your JSON input") + } + return nil + } + check := root.ExactArgs(1) + return check(cmd, args) + } + cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() @@ -86,15 +116,35 @@ 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.Name = args[0] } - response, err := w.Apps.Create(ctx, createReq) + wait, err := w.Apps.Create(ctx, createReq) if err != nil { return err } - return cmdio.Render(ctx, response) + if createSkipWait { + return cmdio.Render(ctx, wait.Response) + } + spinner := cmdio.Spinner(ctx) + info, err := wait.OnProgress(func(i *serving.App) { + if i.Status == nil { + return + } + status := i.Status.State + statusMessage := fmt.Sprintf("current status: %s", status) + if i.Status != nil { + statusMessage = i.Status.Message + } + spinner <- statusMessage + }).GetWithTimeout(createTimeout) + close(spinner) + if err != nil { + return err + } + return cmdio.Render(ctx, info) } // Disable completions since they are not applicable. @@ -109,30 +159,137 @@ func newCreate() *cobra.Command { return cmd } -// start delete-app command +// start create-deployment command // Slice with functions to override default command behavior. // Functions can be added from the `init()` function in manually curated files in this directory. -var deleteAppOverrides []func( +var createDeploymentOverrides []func( + *cobra.Command, + *serving.CreateAppDeploymentRequest, +) + +func newCreateDeployment() *cobra.Command { + cmd := &cobra.Command{} + + var createDeploymentReq serving.CreateAppDeploymentRequest + var createDeploymentJson flags.JsonFlag + + var createDeploymentSkipWait bool + var createDeploymentTimeout time.Duration + + cmd.Flags().BoolVar(&createDeploymentSkipWait, "no-wait", createDeploymentSkipWait, `do not wait to reach SUCCEEDED state`) + cmd.Flags().DurationVar(&createDeploymentTimeout, "timeout", 20*time.Minute, `maximum amount of time to reach SUCCEEDED state`) + // TODO: short flags + cmd.Flags().Var(&createDeploymentJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Use = "create-deployment APP_NAME SOURCE_CODE_PATH" + cmd.Short = `Create an App Deployment.` + cmd.Long = `Create an App Deployment. + + Creates an app deployment for the app with the supplied name. + + Arguments: + APP_NAME: The name of the app. + SOURCE_CODE_PATH: The source code path of the deployment.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + if cmd.Flags().Changed("json") { + err := root.ExactArgs(1)(cmd, args) + if err != nil { + return fmt.Errorf("when --json flag is specified, provide only APP_NAME as positional arguments. Provide 'source_code_path' in your JSON input") + } + return nil + } + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := root.WorkspaceClient(ctx) + + if cmd.Flags().Changed("json") { + err = createDeploymentJson.Unmarshal(&createDeploymentReq) + if err != nil { + return err + } + } + createDeploymentReq.AppName = args[0] + if !cmd.Flags().Changed("json") { + createDeploymentReq.SourceCodePath = args[1] + } + + wait, err := w.Apps.CreateDeployment(ctx, createDeploymentReq) + if err != nil { + return err + } + if createDeploymentSkipWait { + return cmdio.Render(ctx, wait.Response) + } + spinner := cmdio.Spinner(ctx) + info, err := wait.OnProgress(func(i *serving.AppDeployment) { + if i.Status == nil { + return + } + status := i.Status.State + statusMessage := fmt.Sprintf("current status: %s", status) + if i.Status != nil { + statusMessage = i.Status.Message + } + spinner <- statusMessage + }).GetWithTimeout(createDeploymentTimeout) + close(spinner) + if err != nil { + return err + } + return cmdio.Render(ctx, info) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range createDeploymentOverrides { + fn(cmd, &createDeploymentReq) + } + + return cmd +} + +// start delete command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var deleteOverrides []func( *cobra.Command, *serving.DeleteAppRequest, ) -func newDeleteApp() *cobra.Command { +func newDelete() *cobra.Command { cmd := &cobra.Command{} - var deleteAppReq serving.DeleteAppRequest + var deleteReq serving.DeleteAppRequest // TODO: short flags - cmd.Use = "delete-app NAME" - cmd.Short = `Delete an application.` - cmd.Long = `Delete an application. + cmd.Use = "delete NAME" + cmd.Short = `Delete an App.` + cmd.Long = `Delete an App. - Delete an application definition + Deletes an app. Arguments: - NAME: The name of an application. This field is required.` + NAME: The name of the app.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true cmd.Annotations = make(map[string]string) @@ -146,13 +303,13 @@ func newDeleteApp() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - deleteAppReq.Name = args[0] + deleteReq.Name = args[0] - response, err := w.Apps.DeleteApp(ctx, deleteAppReq) + err = w.Apps.Delete(ctx, deleteReq) if err != nil { return err } - return cmdio.Render(ctx, response) + return nil } // Disable completions since they are not applicable. @@ -160,37 +317,40 @@ func newDeleteApp() *cobra.Command { cmd.ValidArgsFunction = cobra.NoFileCompletions // Apply optional overrides to this command. - for _, fn := range deleteAppOverrides { - fn(cmd, &deleteAppReq) + for _, fn := range deleteOverrides { + fn(cmd, &deleteReq) } return cmd } -// start get-app command +// start get command // Slice with functions to override default command behavior. // Functions can be added from the `init()` function in manually curated files in this directory. -var getAppOverrides []func( +var getOverrides []func( *cobra.Command, *serving.GetAppRequest, ) -func newGetApp() *cobra.Command { +func newGet() *cobra.Command { cmd := &cobra.Command{} - var getAppReq serving.GetAppRequest + var getReq serving.GetAppRequest // TODO: short flags - cmd.Use = "get-app NAME" - cmd.Short = `Get definition for an application.` - cmd.Long = `Get definition for an application. + cmd.Use = "get NAME" + cmd.Short = `Get an App.` + cmd.Long = `Get an App. - Get an application definition + Retrieves information for the app with the supplied name. Arguments: - NAME: The name of an application. This field is required.` + NAME: The name of the app.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true cmd.Annotations = make(map[string]string) @@ -204,9 +364,9 @@ func newGetApp() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - getAppReq.Name = args[0] + getReq.Name = args[0] - response, err := w.Apps.GetApp(ctx, getAppReq) + response, err := w.Apps.Get(ctx, getReq) if err != nil { return err } @@ -218,39 +378,104 @@ func newGetApp() *cobra.Command { cmd.ValidArgsFunction = cobra.NoFileCompletions // Apply optional overrides to this command. - for _, fn := range getAppOverrides { - fn(cmd, &getAppReq) + for _, fn := range getOverrides { + fn(cmd, &getReq) } return cmd } -// start get-app-deployment-status command +// start get-deployment command // Slice with functions to override default command behavior. // Functions can be added from the `init()` function in manually curated files in this directory. -var getAppDeploymentStatusOverrides []func( +var getDeploymentOverrides []func( *cobra.Command, - *serving.GetAppDeploymentStatusRequest, + *serving.GetAppDeploymentRequest, ) -func newGetAppDeploymentStatus() *cobra.Command { +func newGetDeployment() *cobra.Command { cmd := &cobra.Command{} - var getAppDeploymentStatusReq serving.GetAppDeploymentStatusRequest + var getDeploymentReq serving.GetAppDeploymentRequest // TODO: short flags - cmd.Flags().StringVar(&getAppDeploymentStatusReq.IncludeAppLog, "include-app-log", getAppDeploymentStatusReq.IncludeAppLog, `Boolean flag to include application logs.`) - - cmd.Use = "get-app-deployment-status DEPLOYMENT_ID" - cmd.Short = `Get deployment status for an application.` - cmd.Long = `Get deployment status for an application. + cmd.Use = "get-deployment APP_NAME DEPLOYMENT_ID" + cmd.Short = `Get an App Deployment.` + cmd.Long = `Get an App Deployment. - Get deployment status for an application + Retrieves information for the app deployment with the supplied name and + deployment id. Arguments: - DEPLOYMENT_ID: The deployment id for an application. This field is required.` + APP_NAME: The name of the app. + DEPLOYMENT_ID: The unique id of the deployment.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(2) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := root.WorkspaceClient(ctx) + + getDeploymentReq.AppName = args[0] + getDeploymentReq.DeploymentId = args[1] + + response, err := w.Apps.GetDeployment(ctx, getDeploymentReq) + 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`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range getDeploymentOverrides { + fn(cmd, &getDeploymentReq) + } + + return cmd +} + +// start get-environment command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var getEnvironmentOverrides []func( + *cobra.Command, + *serving.GetAppEnvironmentRequest, +) + +func newGetEnvironment() *cobra.Command { + cmd := &cobra.Command{} + + var getEnvironmentReq serving.GetAppEnvironmentRequest + + // TODO: short flags + + cmd.Use = "get-environment NAME" + cmd.Short = `Get App Environment.` + cmd.Long = `Get App Environment. + + Retrieves app environment. + + Arguments: + NAME: The name of the app.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true cmd.Annotations = make(map[string]string) @@ -264,9 +489,9 @@ func newGetAppDeploymentStatus() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - getAppDeploymentStatusReq.DeploymentId = args[0] + getEnvironmentReq.Name = args[0] - response, err := w.Apps.GetAppDeploymentStatus(ctx, getAppDeploymentStatusReq) + response, err := w.Apps.GetEnvironment(ctx, getEnvironmentReq) if err != nil { return err } @@ -278,41 +503,55 @@ func newGetAppDeploymentStatus() *cobra.Command { cmd.ValidArgsFunction = cobra.NoFileCompletions // Apply optional overrides to this command. - for _, fn := range getAppDeploymentStatusOverrides { - fn(cmd, &getAppDeploymentStatusReq) + for _, fn := range getEnvironmentOverrides { + fn(cmd, &getEnvironmentReq) } return cmd } -// start get-apps command +// start list command // Slice with functions to override default command behavior. // Functions can be added from the `init()` function in manually curated files in this directory. -var getAppsOverrides []func( +var listOverrides []func( *cobra.Command, + *serving.ListAppsRequest, ) -func newGetApps() *cobra.Command { +func newList() *cobra.Command { cmd := &cobra.Command{} - cmd.Use = "get-apps" - cmd.Short = `List all applications.` - cmd.Long = `List all applications. + var listReq serving.ListAppsRequest + + // TODO: short flags + + cmd.Flags().IntVar(&listReq.PageSize, "page-size", listReq.PageSize, `Upper bound for items returned.`) + cmd.Flags().StringVar(&listReq.PageToken, "page-token", listReq.PageToken, `Pagination token to go to the next page of apps.`) + + cmd.Use = "list" + cmd.Short = `List Apps.` + cmd.Long = `List Apps. - List all available applications` + Lists all apps in the workspace.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true cmd.Annotations = make(map[string]string) + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(0) + return check(cmd, args) + } + cmd.PreRunE = root.MustWorkspaceClient cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - response, err := w.Apps.GetApps(ctx) - if err != nil { - return err - } - return cmdio.Render(ctx, response) + + response := w.Apps.List(ctx, listReq) + return cmdio.RenderIterator(ctx, response) } // Disable completions since they are not applicable. @@ -320,37 +559,43 @@ func newGetApps() *cobra.Command { cmd.ValidArgsFunction = cobra.NoFileCompletions // Apply optional overrides to this command. - for _, fn := range getAppsOverrides { - fn(cmd) + for _, fn := range listOverrides { + fn(cmd, &listReq) } return cmd } -// start get-events command +// start list-deployments command // Slice with functions to override default command behavior. // Functions can be added from the `init()` function in manually curated files in this directory. -var getEventsOverrides []func( +var listDeploymentsOverrides []func( *cobra.Command, - *serving.GetEventsRequest, + *serving.ListAppDeploymentsRequest, ) -func newGetEvents() *cobra.Command { +func newListDeployments() *cobra.Command { cmd := &cobra.Command{} - var getEventsReq serving.GetEventsRequest + var listDeploymentsReq serving.ListAppDeploymentsRequest // TODO: short flags - cmd.Use = "get-events NAME" - cmd.Short = `Get deployment events for an application.` - cmd.Long = `Get deployment events for an application. + cmd.Flags().IntVar(&listDeploymentsReq.PageSize, "page-size", listDeploymentsReq.PageSize, `Upper bound for items returned.`) + cmd.Flags().StringVar(&listDeploymentsReq.PageToken, "page-token", listDeploymentsReq.PageToken, `Pagination token to go to the next page of apps.`) + + cmd.Use = "list-deployments APP_NAME" + cmd.Short = `List App Deployments.` + cmd.Long = `List App Deployments. - Get deployment events for an application + Lists all app deployments for the app with the supplied name. Arguments: - NAME: The name of an application. This field is required.` + APP_NAME: The name of the app.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true cmd.Annotations = make(map[string]string) @@ -364,9 +609,140 @@ func newGetEvents() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - getEventsReq.Name = args[0] + listDeploymentsReq.AppName = args[0] - response, err := w.Apps.GetEvents(ctx, getEventsReq) + response := w.Apps.ListDeployments(ctx, listDeploymentsReq) + return cmdio.RenderIterator(ctx, response) + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range listDeploymentsOverrides { + fn(cmd, &listDeploymentsReq) + } + + return cmd +} + +// start stop command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var stopOverrides []func( + *cobra.Command, + *serving.StopAppRequest, +) + +func newStop() *cobra.Command { + cmd := &cobra.Command{} + + var stopReq serving.StopAppRequest + + // TODO: short flags + + cmd.Use = "stop NAME" + cmd.Short = `Stop an App.` + cmd.Long = `Stop an App. + + Stops the active deployment of the app in the workspace. + + Arguments: + NAME: The name of the app.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { + ctx := cmd.Context() + w := root.WorkspaceClient(ctx) + + stopReq.Name = args[0] + + err = w.Apps.Stop(ctx, stopReq) + if err != nil { + return err + } + return nil + } + + // Disable completions since they are not applicable. + // Can be overridden by manual implementation in `override.go`. + cmd.ValidArgsFunction = cobra.NoFileCompletions + + // Apply optional overrides to this command. + for _, fn := range stopOverrides { + fn(cmd, &stopReq) + } + + return cmd +} + +// start update command + +// Slice with functions to override default command behavior. +// Functions can be added from the `init()` function in manually curated files in this directory. +var updateOverrides []func( + *cobra.Command, + *serving.UpdateAppRequest, +) + +func newUpdate() *cobra.Command { + cmd := &cobra.Command{} + + var updateReq serving.UpdateAppRequest + var updateJson flags.JsonFlag + + // TODO: short flags + cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`) + + cmd.Flags().StringVar(&updateReq.Description, "description", updateReq.Description, `The description of the app.`) + + cmd.Use = "update NAME" + cmd.Short = `Update an App.` + cmd.Long = `Update an App. + + Updates the app with the supplied name. + + Arguments: + NAME: The name of the app. The name must contain only lowercase alphanumeric + characters and hyphens and be between 2 and 30 characters long. It must be + unique within the workspace.` + + // This command is being previewed; hide from help output. + cmd.Hidden = true + + cmd.Annotations = make(map[string]string) + + cmd.Args = func(cmd *cobra.Command, args []string) error { + check := root.ExactArgs(1) + return check(cmd, args) + } + + cmd.PreRunE = root.MustWorkspaceClient + cmd.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.Name = args[0] + + response, err := w.Apps.Update(ctx, updateReq) if err != nil { return err } @@ -378,8 +754,8 @@ func newGetEvents() *cobra.Command { cmd.ValidArgsFunction = cobra.NoFileCompletions // Apply optional overrides to this command. - for _, fn := range getEventsOverrides { - fn(cmd, &getEventsReq) + for _, fn := range updateOverrides { + fn(cmd, &updateReq) } return cmd diff --git a/cmd/workspace/apps/overrides.go b/cmd/workspace/apps/overrides.go deleted file mode 100644 index e38e139b..00000000 --- a/cmd/workspace/apps/overrides.go +++ /dev/null @@ -1,58 +0,0 @@ -package apps - -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/serving" - "github.com/spf13/cobra" -) - -func createOverride(cmd *cobra.Command, deployReq *serving.DeployAppRequest) { - var manifestYaml flags.YamlFlag - var resourcesYaml flags.YamlFlag - createJson := cmd.Flag("json").Value.(*flags.JsonFlag) - - // TODO: short flags - cmd.Flags().Var(&manifestYaml, "manifest", `either inline YAML string or @path/to/manifest.yaml`) - cmd.Flags().Var(&resourcesYaml, "resources", `either inline YAML string or @path/to/resources.yaml`) - - cmd.Annotations = make(map[string]string) - - cmd.PreRunE = root.MustWorkspaceClient - cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { - ctx := cmd.Context() - w := root.WorkspaceClient(ctx) - if cmd.Flags().Changed("json") { - err = createJson.Unmarshal(&deployReq) - if err != nil { - return err - } - } else if cmd.Flags().Changed("manifest") { - err = manifestYaml.Unmarshal(&deployReq.Manifest) - if err != nil { - return err - } - if cmd.Flags().Changed("resources") { - err = resourcesYaml.Unmarshal(&deployReq.Resources) - if err != nil { - return err - } - } - } else { - return fmt.Errorf("please provide command input in YAML format by specifying the --manifest flag or provide a json payload using the --json flag") - } - response, err := w.Apps.Create(ctx, *deployReq) - if err != nil { - return err - } - - return cmdio.Render(ctx, response) - } -} - -func init() { - createOverrides = append(createOverrides, createOverride) -} diff --git a/cmd/workspace/csp-enablement/csp-enablement.go b/cmd/workspace/compliance-security-profile/compliance-security-profile.go similarity index 89% rename from cmd/workspace/csp-enablement/csp-enablement.go rename to cmd/workspace/compliance-security-profile/compliance-security-profile.go index e82fdc2a..efafb462 100755 --- a/cmd/workspace/csp-enablement/csp-enablement.go +++ b/cmd/workspace/compliance-security-profile/compliance-security-profile.go @@ -1,6 +1,6 @@ // Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. -package csp_enablement +package compliance_security_profile import ( "fmt" @@ -18,7 +18,7 @@ var cmdOverrides []func(*cobra.Command) func New() *cobra.Command { cmd := &cobra.Command{ - Use: "csp-enablement", + Use: "compliance-security-profile", Short: `Controls whether to enable the compliance security profile for the current workspace.`, Long: `Controls whether to enable the compliance security profile for the current workspace. Enabling it on a workspace is permanent. By default, it is turned @@ -48,13 +48,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetCspEnablementSettingRequest, + *settings.GetComplianceSecurityProfileSettingRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - var getReq settings.GetCspEnablementSettingRequest + var getReq settings.GetComplianceSecurityProfileSettingRequest // TODO: short flags @@ -78,7 +78,7 @@ func newGet() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - response, err := w.Settings.CspEnablement().Get(ctx, getReq) + response, err := w.Settings.ComplianceSecurityProfile().Get(ctx, getReq) if err != nil { return err } @@ -103,13 +103,13 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateCspEnablementSettingRequest, + *settings.UpdateComplianceSecurityProfileSettingRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} - var updateReq settings.UpdateCspEnablementSettingRequest + var updateReq settings.UpdateComplianceSecurityProfileSettingRequest var updateJson flags.JsonFlag // TODO: short flags @@ -141,7 +141,7 @@ func newUpdate() *cobra.Command { return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.CspEnablement().Update(ctx, updateReq) + response, err := w.Settings.ComplianceSecurityProfile().Update(ctx, updateReq) if err != nil { return err } @@ -160,4 +160,4 @@ func newUpdate() *cobra.Command { return cmd } -// end service CSPEnablement +// end service ComplianceSecurityProfile diff --git a/cmd/workspace/dashboards/dashboards.go b/cmd/workspace/dashboards/dashboards.go index 0500ebec..1a143538 100755 --- a/cmd/workspace/dashboards/dashboards.go +++ b/cmd/workspace/dashboards/dashboards.go @@ -386,6 +386,7 @@ func newUpdate() *cobra.Command { cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `The title of this dashboard that appears in list views and at the top of the dashboard page.`) cmd.Flags().Var(&updateReq.RunAsRole, "run-as-role", `Sets the **Run as** role for the object. Supported values: [owner, viewer]`) + // TODO: array: tags cmd.Use = "update DASHBOARD_ID" cmd.Short = `Change a dashboard definition.` diff --git a/cmd/workspace/esm-enablement/esm-enablement.go b/cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go similarity index 89% rename from cmd/workspace/esm-enablement/esm-enablement.go rename to cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go index 784c01f2..86b4244d 100755 --- a/cmd/workspace/esm-enablement/esm-enablement.go +++ b/cmd/workspace/enhanced-security-monitoring/enhanced-security-monitoring.go @@ -1,6 +1,6 @@ // Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT. -package esm_enablement +package enhanced_security_monitoring import ( "fmt" @@ -18,7 +18,7 @@ var cmdOverrides []func(*cobra.Command) func New() *cobra.Command { cmd := &cobra.Command{ - Use: "esm-enablement", + Use: "enhanced-security-monitoring", Short: `Controls whether enhanced security monitoring is enabled for the current workspace.`, Long: `Controls whether enhanced security monitoring is enabled for the current workspace. If the compliance security profile is enabled, this is @@ -50,13 +50,13 @@ func New() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var getOverrides []func( *cobra.Command, - *settings.GetEsmEnablementSettingRequest, + *settings.GetEnhancedSecurityMonitoringSettingRequest, ) func newGet() *cobra.Command { cmd := &cobra.Command{} - var getReq settings.GetEsmEnablementSettingRequest + var getReq settings.GetEnhancedSecurityMonitoringSettingRequest // TODO: short flags @@ -80,7 +80,7 @@ func newGet() *cobra.Command { ctx := cmd.Context() w := root.WorkspaceClient(ctx) - response, err := w.Settings.EsmEnablement().Get(ctx, getReq) + response, err := w.Settings.EnhancedSecurityMonitoring().Get(ctx, getReq) if err != nil { return err } @@ -105,13 +105,13 @@ func newGet() *cobra.Command { // Functions can be added from the `init()` function in manually curated files in this directory. var updateOverrides []func( *cobra.Command, - *settings.UpdateEsmEnablementSettingRequest, + *settings.UpdateEnhancedSecurityMonitoringSettingRequest, ) func newUpdate() *cobra.Command { cmd := &cobra.Command{} - var updateReq settings.UpdateEsmEnablementSettingRequest + var updateReq settings.UpdateEnhancedSecurityMonitoringSettingRequest var updateJson flags.JsonFlag // TODO: short flags @@ -143,7 +143,7 @@ func newUpdate() *cobra.Command { return fmt.Errorf("please provide command input in JSON format by specifying the --json flag") } - response, err := w.Settings.EsmEnablement().Update(ctx, updateReq) + response, err := w.Settings.EnhancedSecurityMonitoring().Update(ctx, updateReq) if err != nil { return err } @@ -162,4 +162,4 @@ func newUpdate() *cobra.Command { return cmd } -// end service ESMEnablement +// end service EnhancedSecurityMonitoring diff --git a/cmd/workspace/model-versions/model-versions.go b/cmd/workspace/model-versions/model-versions.go index 7b556c72..034cea2d 100755 --- a/cmd/workspace/model-versions/model-versions.go +++ b/cmd/workspace/model-versions/model-versions.go @@ -288,6 +288,7 @@ func newList() *cobra.Command { schema. There is no guarantee of a specific ordering of the elements in the response. + The elements in the response will not contain any aliases or tags. Arguments: FULL_NAME: The full three-level name of the registered model under which to list diff --git a/cmd/workspace/queries/queries.go b/cmd/workspace/queries/queries.go index 0126097f..b96eb715 100755 --- a/cmd/workspace/queries/queries.go +++ b/cmd/workspace/queries/queries.go @@ -401,6 +401,7 @@ func newUpdate() *cobra.Command { // TODO: any: options cmd.Flags().StringVar(&updateReq.Query, "query", updateReq.Query, `The text of the query to be run.`) cmd.Flags().Var(&updateReq.RunAsRole, "run-as-role", `Sets the **Run as** role for the object. Supported values: [owner, viewer]`) + // TODO: array: tags cmd.Use = "update QUERY_ID" cmd.Short = `Change a query definition.` diff --git a/cmd/workspace/settings/settings.go b/cmd/workspace/settings/settings.go index 38e19e83..214986c7 100755 --- a/cmd/workspace/settings/settings.go +++ b/cmd/workspace/settings/settings.go @@ -6,9 +6,9 @@ import ( "github.com/spf13/cobra" automatic_cluster_update "github.com/databricks/cli/cmd/workspace/automatic-cluster-update" - csp_enablement "github.com/databricks/cli/cmd/workspace/csp-enablement" + compliance_security_profile "github.com/databricks/cli/cmd/workspace/compliance-security-profile" default_namespace "github.com/databricks/cli/cmd/workspace/default-namespace" - esm_enablement "github.com/databricks/cli/cmd/workspace/esm-enablement" + enhanced_security_monitoring "github.com/databricks/cli/cmd/workspace/enhanced-security-monitoring" restrict_workspace_admins "github.com/databricks/cli/cmd/workspace/restrict-workspace-admins" ) @@ -29,9 +29,9 @@ func New() *cobra.Command { // Add subservices cmd.AddCommand(automatic_cluster_update.New()) - cmd.AddCommand(csp_enablement.New()) + cmd.AddCommand(compliance_security_profile.New()) cmd.AddCommand(default_namespace.New()) - cmd.AddCommand(esm_enablement.New()) + cmd.AddCommand(enhanced_security_monitoring.New()) cmd.AddCommand(restrict_workspace_admins.New()) // Apply optional overrides to this command. diff --git a/go.mod b/go.mod index 636fbf44..6c8e845a 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/Masterminds/semver/v3 v3.2.1 // MIT github.com/briandowns/spinner v1.23.0 // Apache 2.0 - github.com/databricks/databricks-sdk-go v0.39.0 // Apache 2.0 + github.com/databricks/databricks-sdk-go v0.40.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.6.0 // BSD-3-Clause @@ -57,8 +57,8 @@ require ( go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/net v0.23.0 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/net v0.24.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.169.0 // indirect diff --git a/go.sum b/go.sum index 3dd6b0cb..222ce1e4 100644 --- a/go.sum +++ b/go.sum @@ -28,8 +28,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.39.0 h1:nVnQYkk47SkEsRSXWkn6j7jBOxXgusjoo6xwbaHTGss= -github.com/databricks/databricks-sdk-go v0.39.0/go.mod h1:Yjy1gREDLK65g4axpVbVNKYAHYE2Sqzj0AB9QWHCBVM= +github.com/databricks/databricks-sdk-go v0.40.1 h1:rE5yP9gIW2oap+6CnumixnZSDIsXwVojAuDBuKUl5GU= +github.com/databricks/databricks-sdk-go v0.40.1/go.mod h1:rLIhh7DvifVLmf2QxMr/vMRGqdrTZazn8VYo4LilfCo= 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= @@ -170,8 +170,8 @@ go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= @@ -186,8 +186,8 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=