mirror of https://github.com/databricks/cli.git
226 lines
5.6 KiB
Go
Executable File
226 lines
5.6 KiB
Go
Executable File
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
|
|
|
package online_tables
|
|
|
|
import (
|
|
"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/catalog"
|
|
"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: "online-tables",
|
|
Short: `Online tables provide lower latency and higher QPS access to data from Delta tables.`,
|
|
Long: `Online tables provide lower latency and higher QPS access to data from Delta
|
|
tables.`,
|
|
GroupID: "catalog",
|
|
Annotations: map[string]string{
|
|
"package": "catalog",
|
|
},
|
|
}
|
|
|
|
// Add methods
|
|
cmd.AddCommand(newCreate())
|
|
cmd.AddCommand(newDelete())
|
|
cmd.AddCommand(newGet())
|
|
|
|
// Apply optional overrides to this command.
|
|
for _, fn := range cmdOverrides {
|
|
fn(cmd)
|
|
}
|
|
|
|
return cmd
|
|
}
|
|
|
|
// start create 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 createOverrides []func(
|
|
*cobra.Command,
|
|
*catalog.CreateOnlineTableRequest,
|
|
)
|
|
|
|
func newCreate() *cobra.Command {
|
|
cmd := &cobra.Command{}
|
|
|
|
var createReq catalog.CreateOnlineTableRequest
|
|
var createJson flags.JsonFlag
|
|
|
|
// TODO: short flags
|
|
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
|
|
|
cmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `Full three-part (catalog, schema, table) name of the table.`)
|
|
// TODO: complex arg: spec
|
|
|
|
cmd.Use = "create"
|
|
cmd.Short = `Create an Online Table.`
|
|
cmd.Long = `Create an Online Table.
|
|
|
|
Create a new Online Table.`
|
|
|
|
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)
|
|
|
|
if cmd.Flags().Changed("json") {
|
|
err = createJson.Unmarshal(&createReq)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
response, err := w.OnlineTables.Create(ctx, createReq)
|
|
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 createOverrides {
|
|
fn(cmd, &createReq)
|
|
}
|
|
|
|
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,
|
|
*catalog.DeleteOnlineTableRequest,
|
|
)
|
|
|
|
func newDelete() *cobra.Command {
|
|
cmd := &cobra.Command{}
|
|
|
|
var deleteReq catalog.DeleteOnlineTableRequest
|
|
|
|
// TODO: short flags
|
|
|
|
cmd.Use = "delete NAME"
|
|
cmd.Short = `Delete an Online Table.`
|
|
cmd.Long = `Delete an Online Table.
|
|
|
|
Delete an online table. Warning: This will delete all the data in the online
|
|
table. If the source Delta table was deleted or modified since this Online
|
|
Table was created, this will lose the data forever!
|
|
|
|
Arguments:
|
|
NAME: Full three-part (catalog, schema, table) name of the table.`
|
|
|
|
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)
|
|
|
|
deleteReq.Name = args[0]
|
|
|
|
err = w.OnlineTables.Delete(ctx, deleteReq)
|
|
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 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,
|
|
*catalog.GetOnlineTableRequest,
|
|
)
|
|
|
|
func newGet() *cobra.Command {
|
|
cmd := &cobra.Command{}
|
|
|
|
var getReq catalog.GetOnlineTableRequest
|
|
|
|
// TODO: short flags
|
|
|
|
cmd.Use = "get NAME"
|
|
cmd.Short = `Get an Online Table.`
|
|
cmd.Long = `Get an Online Table.
|
|
|
|
Get information about an existing online table and its status.
|
|
|
|
Arguments:
|
|
NAME: Full three-part (catalog, schema, table) name of the table.`
|
|
|
|
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)
|
|
|
|
getReq.Name = args[0]
|
|
|
|
response, err := w.OnlineTables.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
|
|
}
|
|
|
|
// end service OnlineTables
|