2023-10-03 11:46:16 +00:00
|
|
|
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
|
|
|
|
|
|
|
package settings
|
|
|
|
|
|
|
|
import (
|
2024-02-15 14:52:17 +00:00
|
|
|
"fmt"
|
|
|
|
|
2023-10-03 11:46:16 +00:00
|
|
|
"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{
|
2023-11-29 13:29:31 +00:00
|
|
|
Use: "settings",
|
|
|
|
Short: `The default namespace setting API allows users to configure the default namespace for a Databricks workspace.`,
|
|
|
|
Long: `The default namespace setting API allows users to configure the default
|
|
|
|
namespace for a Databricks workspace.
|
|
|
|
|
|
|
|
Through this API, users can retrieve, set, or modify the default namespace
|
|
|
|
used when queries do not reference a fully qualified three-level name. For
|
|
|
|
example, if you use the API to set 'retail_prod' as the default catalog, then
|
|
|
|
a query 'SELECT * FROM myTable' would reference the object
|
|
|
|
'retail_prod.default.myTable' (the schema 'default' is always assumed).
|
|
|
|
|
|
|
|
This setting requires a restart of clusters and SQL warehouses to take effect.
|
|
|
|
Additionally, the default namespace only applies when using Unity
|
|
|
|
Catalog-enabled compute.`,
|
2023-10-03 11:46:16 +00:00
|
|
|
GroupID: "settings",
|
|
|
|
Annotations: map[string]string{
|
|
|
|
"package": "settings",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply optional overrides to this command.
|
|
|
|
for _, fn := range cmdOverrides {
|
|
|
|
fn(cmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
// start delete-default-namespace-setting command
|
2023-10-03 11:46:16 +00:00
|
|
|
|
|
|
|
// Slice with functions to override default command behavior.
|
|
|
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
2024-02-15 14:52:17 +00:00
|
|
|
var deleteDefaultNamespaceSettingOverrides []func(
|
2023-10-03 11:46:16 +00:00
|
|
|
*cobra.Command,
|
2024-02-15 14:52:17 +00:00
|
|
|
*settings.DeleteDefaultNamespaceSettingRequest,
|
2023-10-03 11:46:16 +00:00
|
|
|
)
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
func newDeleteDefaultNamespaceSetting() *cobra.Command {
|
2023-10-03 11:46:16 +00:00
|
|
|
cmd := &cobra.Command{}
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
var deleteDefaultNamespaceSettingReq settings.DeleteDefaultNamespaceSettingRequest
|
2023-10-03 11:46:16 +00:00
|
|
|
|
|
|
|
// TODO: short flags
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
cmd.Flags().StringVar(&deleteDefaultNamespaceSettingReq.Etag, "etag", deleteDefaultNamespaceSettingReq.Etag, `etag used for versioning.`)
|
|
|
|
|
|
|
|
cmd.Use = "delete-default-namespace-setting"
|
2023-11-29 13:29:31 +00:00
|
|
|
cmd.Short = `Delete the default namespace setting.`
|
|
|
|
cmd.Long = `Delete the default namespace setting.
|
2023-10-03 11:46:16 +00:00
|
|
|
|
2023-11-29 13:29:31 +00:00
|
|
|
Deletes the default namespace setting for the workspace. A fresh etag needs to
|
|
|
|
be provided in DELETE requests (as a query parameter). The etag can be
|
|
|
|
retrieved by making a GET request before the DELETE request. If the setting is
|
|
|
|
updated/deleted concurrently, DELETE will fail with 409 and the request will
|
2024-02-15 14:52:17 +00:00
|
|
|
need to be retried by using the fresh etag in the 409 response.`
|
2023-10-03 11:46:16 +00:00
|
|
|
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
|
|
|
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
2024-02-15 14:52:17 +00:00
|
|
|
check := cobra.ExactArgs(0)
|
2023-10-03 11:46:16 +00:00
|
|
|
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)
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
response, err := w.Settings.DeleteDefaultNamespaceSetting(ctx, deleteDefaultNamespaceSettingReq)
|
|
|
|
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 deleteDefaultNamespaceSettingOverrides {
|
|
|
|
fn(cmd, &deleteDefaultNamespaceSettingReq)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
|
|
|
cmd.AddCommand(newDeleteDefaultNamespaceSetting())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// start delete-restrict-workspace-admins-setting 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 deleteRestrictWorkspaceAdminsSettingOverrides []func(
|
|
|
|
*cobra.Command,
|
|
|
|
*settings.DeleteRestrictWorkspaceAdminsSettingRequest,
|
|
|
|
)
|
|
|
|
|
|
|
|
func newDeleteRestrictWorkspaceAdminsSetting() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{}
|
|
|
|
|
|
|
|
var deleteRestrictWorkspaceAdminsSettingReq settings.DeleteRestrictWorkspaceAdminsSettingRequest
|
|
|
|
|
|
|
|
// TODO: short flags
|
|
|
|
|
|
|
|
cmd.Flags().StringVar(&deleteRestrictWorkspaceAdminsSettingReq.Etag, "etag", deleteRestrictWorkspaceAdminsSettingReq.Etag, `etag used for versioning.`)
|
|
|
|
|
|
|
|
cmd.Use = "delete-restrict-workspace-admins-setting"
|
|
|
|
cmd.Short = `Delete the restrict workspace admins setting.`
|
|
|
|
cmd.Long = `Delete the restrict workspace admins setting.
|
|
|
|
|
|
|
|
Reverts the restrict workspace admins setting status for the workspace. A
|
|
|
|
fresh etag needs to be provided in DELETE requests (as a query parameter). The
|
|
|
|
etag can be retrieved by making a GET request before the DELETE request. If
|
|
|
|
the setting is updated/deleted concurrently, DELETE will fail with 409 and the
|
|
|
|
request will need to be retried by using the fresh etag in the 409 response.`
|
|
|
|
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
|
|
|
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
|
|
|
check := cobra.ExactArgs(0)
|
|
|
|
return check(cmd, args)
|
|
|
|
}
|
2023-10-03 11:46:16 +00:00
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
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.DeleteRestrictWorkspaceAdminsSetting(ctx, deleteRestrictWorkspaceAdminsSettingReq)
|
2023-10-03 11:46:16 +00:00
|
|
|
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.
|
2024-02-15 14:52:17 +00:00
|
|
|
for _, fn := range deleteRestrictWorkspaceAdminsSettingOverrides {
|
|
|
|
fn(cmd, &deleteRestrictWorkspaceAdminsSettingReq)
|
2023-10-03 11:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
2024-02-15 14:52:17 +00:00
|
|
|
cmd.AddCommand(newDeleteRestrictWorkspaceAdminsSetting())
|
2023-10-03 11:46:16 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
// start get-default-namespace-setting command
|
2023-10-03 11:46:16 +00:00
|
|
|
|
|
|
|
// Slice with functions to override default command behavior.
|
|
|
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
2024-02-15 14:52:17 +00:00
|
|
|
var getDefaultNamespaceSettingOverrides []func(
|
2023-10-03 11:46:16 +00:00
|
|
|
*cobra.Command,
|
2024-02-15 14:52:17 +00:00
|
|
|
*settings.GetDefaultNamespaceSettingRequest,
|
2023-10-03 11:46:16 +00:00
|
|
|
)
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
func newGetDefaultNamespaceSetting() *cobra.Command {
|
2023-10-03 11:46:16 +00:00
|
|
|
cmd := &cobra.Command{}
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
var getDefaultNamespaceSettingReq settings.GetDefaultNamespaceSettingRequest
|
2023-10-03 11:46:16 +00:00
|
|
|
|
|
|
|
// TODO: short flags
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
cmd.Flags().StringVar(&getDefaultNamespaceSettingReq.Etag, "etag", getDefaultNamespaceSettingReq.Etag, `etag used for versioning.`)
|
|
|
|
|
|
|
|
cmd.Use = "get-default-namespace-setting"
|
2023-11-29 13:29:31 +00:00
|
|
|
cmd.Short = `Get the default namespace setting.`
|
|
|
|
cmd.Long = `Get the default namespace setting.
|
2023-10-03 11:46:16 +00:00
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
Gets the default namespace setting.`
|
2023-10-03 11:46:16 +00:00
|
|
|
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
|
|
|
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
2024-02-15 14:52:17 +00:00
|
|
|
check := cobra.ExactArgs(0)
|
2023-10-03 11:46:16 +00:00
|
|
|
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)
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
response, err := w.Settings.GetDefaultNamespaceSetting(ctx, getDefaultNamespaceSettingReq)
|
2023-10-03 11:46:16 +00:00
|
|
|
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.
|
2024-02-15 14:52:17 +00:00
|
|
|
for _, fn := range getDefaultNamespaceSettingOverrides {
|
|
|
|
fn(cmd, &getDefaultNamespaceSettingReq)
|
2023-10-03 11:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
2024-02-15 14:52:17 +00:00
|
|
|
cmd.AddCommand(newGetDefaultNamespaceSetting())
|
2023-10-03 11:46:16 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
// start get-restrict-workspace-admins-setting command
|
2023-10-03 11:46:16 +00:00
|
|
|
|
|
|
|
// Slice with functions to override default command behavior.
|
|
|
|
// Functions can be added from the `init()` function in manually curated files in this directory.
|
2024-02-15 14:52:17 +00:00
|
|
|
var getRestrictWorkspaceAdminsSettingOverrides []func(
|
2023-10-03 11:46:16 +00:00
|
|
|
*cobra.Command,
|
2024-02-15 14:52:17 +00:00
|
|
|
*settings.GetRestrictWorkspaceAdminsSettingRequest,
|
2023-10-03 11:46:16 +00:00
|
|
|
)
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
func newGetRestrictWorkspaceAdminsSetting() *cobra.Command {
|
2023-10-03 11:46:16 +00:00
|
|
|
cmd := &cobra.Command{}
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
var getRestrictWorkspaceAdminsSettingReq settings.GetRestrictWorkspaceAdminsSettingRequest
|
2023-10-03 11:46:16 +00:00
|
|
|
|
|
|
|
// TODO: short flags
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
cmd.Flags().StringVar(&getRestrictWorkspaceAdminsSettingReq.Etag, "etag", getRestrictWorkspaceAdminsSettingReq.Etag, `etag used for versioning.`)
|
|
|
|
|
|
|
|
cmd.Use = "get-restrict-workspace-admins-setting"
|
|
|
|
cmd.Short = `Get the restrict workspace admins setting.`
|
|
|
|
cmd.Long = `Get the restrict workspace admins setting.
|
|
|
|
|
|
|
|
Gets the restrict workspace admins setting.`
|
|
|
|
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
|
|
|
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
|
|
|
check := cobra.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.GetRestrictWorkspaceAdminsSetting(ctx, getRestrictWorkspaceAdminsSettingReq)
|
|
|
|
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 getRestrictWorkspaceAdminsSettingOverrides {
|
|
|
|
fn(cmd, &getRestrictWorkspaceAdminsSettingReq)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
2023-10-03 11:46:16 +00:00
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
func init() {
|
|
|
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
|
|
|
cmd.AddCommand(newGetRestrictWorkspaceAdminsSetting())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// start update-default-namespace-setting 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 updateDefaultNamespaceSettingOverrides []func(
|
|
|
|
*cobra.Command,
|
|
|
|
*settings.UpdateDefaultNamespaceSettingRequest,
|
|
|
|
)
|
|
|
|
|
|
|
|
func newUpdateDefaultNamespaceSetting() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{}
|
|
|
|
|
|
|
|
var updateDefaultNamespaceSettingReq settings.UpdateDefaultNamespaceSettingRequest
|
|
|
|
var updateDefaultNamespaceSettingJson flags.JsonFlag
|
|
|
|
|
|
|
|
// TODO: short flags
|
|
|
|
cmd.Flags().Var(&updateDefaultNamespaceSettingJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
|
|
|
|
|
|
|
cmd.Use = "update-default-namespace-setting"
|
2023-11-29 13:29:31 +00:00
|
|
|
cmd.Short = `Update the default namespace setting.`
|
|
|
|
cmd.Long = `Update the default namespace setting.
|
2023-10-03 11:46:16 +00:00
|
|
|
|
|
|
|
Updates the default namespace setting for the workspace. A fresh etag needs to
|
2023-11-29 13:29:31 +00:00
|
|
|
be provided in PATCH requests (as part of the setting field). The etag can be
|
2023-10-03 11:46:16 +00:00
|
|
|
retrieved by making a GET request before the PATCH request. Note that if the
|
|
|
|
setting does not exist, GET will return a NOT_FOUND error and the etag will be
|
2023-11-29 13:29:31 +00:00
|
|
|
present in the error response, which should be set in the PATCH request. If
|
|
|
|
the setting is updated concurrently, PATCH will fail with 409 and the request
|
|
|
|
will need to be retried by using the fresh etag in the 409 response.`
|
2023-10-03 11:46:16 +00:00
|
|
|
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
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 = updateDefaultNamespaceSettingJson.Unmarshal(&updateDefaultNamespaceSettingReq)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
|
|
|
}
|
|
|
|
|
|
|
|
response, err := w.Settings.UpdateDefaultNamespaceSetting(ctx, updateDefaultNamespaceSettingReq)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return cmdio.Render(ctx, response)
|
2023-10-03 11:46:16 +00:00
|
|
|
}
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
// 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 updateDefaultNamespaceSettingOverrides {
|
|
|
|
fn(cmd, &updateDefaultNamespaceSettingReq)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
|
|
|
cmd.AddCommand(newUpdateDefaultNamespaceSetting())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// start update-restrict-workspace-admins-setting 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 updateRestrictWorkspaceAdminsSettingOverrides []func(
|
|
|
|
*cobra.Command,
|
|
|
|
*settings.UpdateRestrictWorkspaceAdminsSettingRequest,
|
|
|
|
)
|
|
|
|
|
|
|
|
func newUpdateRestrictWorkspaceAdminsSetting() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{}
|
|
|
|
|
|
|
|
var updateRestrictWorkspaceAdminsSettingReq settings.UpdateRestrictWorkspaceAdminsSettingRequest
|
|
|
|
var updateRestrictWorkspaceAdminsSettingJson flags.JsonFlag
|
|
|
|
|
|
|
|
// TODO: short flags
|
|
|
|
cmd.Flags().Var(&updateRestrictWorkspaceAdminsSettingJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
|
|
|
|
|
|
|
cmd.Use = "update-restrict-workspace-admins-setting"
|
|
|
|
cmd.Short = `Update the restrict workspace admins setting.`
|
|
|
|
cmd.Long = `Update the restrict workspace admins setting.
|
|
|
|
|
|
|
|
Updates the restrict workspace admins 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 will fail with 409 and the request will
|
|
|
|
need to be retried by using the fresh etag in the 409 response.`
|
|
|
|
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
|
2023-10-03 11:46:16 +00:00
|
|
|
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") {
|
2024-02-15 14:52:17 +00:00
|
|
|
err = updateRestrictWorkspaceAdminsSettingJson.Unmarshal(&updateRestrictWorkspaceAdminsSettingReq)
|
2023-10-03 11:46:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2024-02-15 14:52:17 +00:00
|
|
|
} else {
|
|
|
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
2023-10-03 11:46:16 +00:00
|
|
|
}
|
|
|
|
|
2024-02-15 14:52:17 +00:00
|
|
|
response, err := w.Settings.UpdateRestrictWorkspaceAdminsSetting(ctx, updateRestrictWorkspaceAdminsSettingReq)
|
2023-10-03 11:46:16 +00:00
|
|
|
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.
|
2024-02-15 14:52:17 +00:00
|
|
|
for _, fn := range updateRestrictWorkspaceAdminsSettingOverrides {
|
|
|
|
fn(cmd, &updateRestrictWorkspaceAdminsSettingReq)
|
2023-10-03 11:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
2024-02-15 14:52:17 +00:00
|
|
|
cmd.AddCommand(newUpdateRestrictWorkspaceAdminsSetting())
|
2023-10-03 11:46:16 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// end service Settings
|