// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package enhanced_security_monitoring
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/settings"
"github.com/spf13/cobra"
)
// Slice with functions to override default command behavior.
// Functions can be added from the `init()` function in manually curated files in this directory.
var cmdOverrides []func(*cobra.Command)
func New() *cobra.Command {
cmd := &cobra.Command{
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
automatically enabled. By default, it is disabled. However, if the compliance
security profile is enabled, this is automatically enabled.
If the compliance security profile is disabled, you can enable or disable this
setting and it is not permanent.`,
}
// Add methods
cmd.AddCommand(newGet())
cmd.AddCommand(newUpdate())
// Apply optional overrides to this command.
for _, fn := range cmdOverrides {
fn(cmd)
return cmd
// start get command
var getOverrides []func(
*cobra.Command,
*settings.GetEnhancedSecurityMonitoringSettingRequest,
func newGet() *cobra.Command {
cmd := &cobra.Command{}
var getReq settings.GetEnhancedSecurityMonitoringSettingRequest
// TODO: short flags
cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`)
cmd.Use = "get"
cmd.Short = `Get the enhanced security monitoring setting.`
cmd.Long = `Get the enhanced security monitoring setting.
Gets the enhanced security monitoring setting.`
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.Settings.EnhancedSecurityMonitoring().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`.
cmd.ValidArgsFunction = cobra.NoFileCompletions
for _, fn := range getOverrides {
fn(cmd, &getReq)
// start update command
var updateOverrides []func(
*settings.UpdateEnhancedSecurityMonitoringSettingRequest,
func newUpdate() *cobra.Command {
var updateReq settings.UpdateEnhancedSecurityMonitoringSettingRequest
var updateJson flags.JsonFlag
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
cmd.Use = "update"
cmd.Short = `Update the enhanced security monitoring setting.`
cmd.Long = `Update the enhanced security monitoring setting.
Updates the enhanced security monitoring setting for the workspace. A fresh
etag needs to be provided in PATCH requests (as part of the setting field).
The etag can be retrieved by making a GET request before the PATCH
request. If the setting is updated concurrently, PATCH fails with 409 and
the request must be retried by using the fresh etag in the 409 response.`
if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq)
} else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
response, err := w.Settings.EnhancedSecurityMonitoring().Update(ctx, updateReq)
for _, fn := range updateOverrides {
fn(cmd, &updateReq)
// end service EnhancedSecurityMonitoring