2024-03-06 09:53:44 +00:00
|
|
|
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
|
|
|
|
|
|
|
package personal_compute
|
|
|
|
|
|
|
|
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: "personal-compute",
|
|
|
|
Short: `The Personal Compute enablement setting lets you control which users can use the Personal Compute default policy to create compute resources.`,
|
|
|
|
Long: `The Personal Compute enablement setting lets you control which users can use
|
|
|
|
the Personal Compute default policy to create compute resources. By default
|
|
|
|
all users in all workspaces have access (ON), but you can change the setting
|
|
|
|
to instead let individual workspaces configure access control (DELEGATE).
|
|
|
|
|
|
|
|
There is only one instance of this setting per account. Since this setting has
|
|
|
|
a default value, this setting is present on all accounts even though it's
|
|
|
|
never set on a given account. Deletion reverts the value of the setting back
|
|
|
|
to the default value.`,
|
|
|
|
|
|
|
|
// This service is being previewed; hide from help output.
|
|
|
|
Hidden: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add methods
|
|
|
|
cmd.AddCommand(newDelete())
|
|
|
|
cmd.AddCommand(newGet())
|
|
|
|
cmd.AddCommand(newUpdate())
|
|
|
|
|
|
|
|
// Apply optional overrides to this command.
|
|
|
|
for _, fn := range cmdOverrides {
|
|
|
|
fn(cmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2024-03-22 13:15:54 +00:00
|
|
|
*settings.DeletePersonalComputeSettingRequest,
|
2024-03-06 09:53:44 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func newDelete() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{}
|
|
|
|
|
2024-03-22 13:15:54 +00:00
|
|
|
var deleteReq settings.DeletePersonalComputeSettingRequest
|
2024-03-06 09:53:44 +00:00
|
|
|
|
|
|
|
// TODO: short flags
|
|
|
|
|
|
|
|
cmd.Flags().StringVar(&deleteReq.Etag, "etag", deleteReq.Etag, `etag used for versioning.`)
|
|
|
|
|
|
|
|
cmd.Use = "delete"
|
|
|
|
cmd.Short = `Delete Personal Compute setting.`
|
|
|
|
cmd.Long = `Delete Personal Compute setting.
|
|
|
|
|
|
|
|
Reverts back the Personal Compute setting value to default (ON)`
|
|
|
|
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
|
|
|
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
2024-03-12 14:12:34 +00:00
|
|
|
check := root.ExactArgs(0)
|
2024-03-06 09:53:44 +00:00
|
|
|
return check(cmd, args)
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.PreRunE = root.MustAccountClient
|
|
|
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
|
|
|
ctx := cmd.Context()
|
|
|
|
a := root.AccountClient(ctx)
|
|
|
|
|
|
|
|
response, err := a.Settings.PersonalCompute().Delete(ctx, deleteReq)
|
|
|
|
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 deleteOverrides {
|
|
|
|
fn(cmd, &deleteReq)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 getOverrides []func(
|
|
|
|
*cobra.Command,
|
2024-03-22 13:15:54 +00:00
|
|
|
*settings.GetPersonalComputeSettingRequest,
|
2024-03-06 09:53:44 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func newGet() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{}
|
|
|
|
|
2024-03-22 13:15:54 +00:00
|
|
|
var getReq settings.GetPersonalComputeSettingRequest
|
2024-03-06 09:53:44 +00:00
|
|
|
|
|
|
|
// TODO: short flags
|
|
|
|
|
|
|
|
cmd.Flags().StringVar(&getReq.Etag, "etag", getReq.Etag, `etag used for versioning.`)
|
|
|
|
|
|
|
|
cmd.Use = "get"
|
|
|
|
cmd.Short = `Get Personal Compute setting.`
|
|
|
|
cmd.Long = `Get Personal Compute setting.
|
|
|
|
|
|
|
|
Gets the value of the Personal Compute setting.`
|
|
|
|
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
|
|
|
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
2024-03-12 14:12:34 +00:00
|
|
|
check := root.ExactArgs(0)
|
2024-03-06 09:53:44 +00:00
|
|
|
return check(cmd, args)
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.PreRunE = root.MustAccountClient
|
|
|
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
|
|
|
ctx := cmd.Context()
|
|
|
|
a := root.AccountClient(ctx)
|
|
|
|
|
|
|
|
response, err := a.Settings.PersonalCompute().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
|
|
|
|
|
|
|
|
// Apply optional overrides to this command.
|
|
|
|
for _, fn := range getOverrides {
|
|
|
|
fn(cmd, &getReq)
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
*settings.UpdatePersonalComputeSettingRequest,
|
|
|
|
)
|
|
|
|
|
|
|
|
func newUpdate() *cobra.Command {
|
|
|
|
cmd := &cobra.Command{}
|
|
|
|
|
|
|
|
var updateReq settings.UpdatePersonalComputeSettingRequest
|
|
|
|
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.Use = "update"
|
|
|
|
cmd.Short = `Update Personal Compute setting.`
|
|
|
|
cmd.Long = `Update Personal Compute setting.
|
|
|
|
|
|
|
|
Updates the value of the Personal Compute setting.`
|
|
|
|
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
|
|
|
|
cmd.PreRunE = root.MustAccountClient
|
|
|
|
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
|
|
|
ctx := cmd.Context()
|
|
|
|
a := root.AccountClient(ctx)
|
|
|
|
|
|
|
|
if cmd.Flags().Changed("json") {
|
|
|
|
err = updateJson.Unmarshal(&updateReq)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
|
|
|
}
|
|
|
|
|
|
|
|
response, err := a.Settings.PersonalCompute().Update(ctx, updateReq)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return cmdio.Render(ctx, response)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable completions since they are not applicable.
|
|
|
|
// Can be overridden by manual implementation in `override.go`.
|
|
|
|
cmd.ValidArgsFunction = cobra.NoFileCompletions
|
|
|
|
|
|
|
|
// Apply optional overrides to this command.
|
|
|
|
for _, fn := range updateOverrides {
|
|
|
|
fn(cmd, &updateReq)
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
// end service PersonalCompute
|