mirror of https://github.com/databricks/cli.git
299 lines
7.5 KiB
Go
Executable File
299 lines
7.5 KiB
Go
Executable File
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
|
|
|
package networks
|
|
|
|
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/provisioning"
|
|
"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: "networks",
|
|
Short: `These APIs manage network configurations for customer-managed VPCs (optional).`,
|
|
Long: `These APIs manage network configurations for customer-managed VPCs (optional).
|
|
Its ID is used when creating a new workspace if you use customer-managed VPCs.`,
|
|
GroupID: "provisioning",
|
|
Annotations: map[string]string{
|
|
"package": "provisioning",
|
|
},
|
|
}
|
|
|
|
// 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,
|
|
*provisioning.CreateNetworkRequest,
|
|
)
|
|
|
|
func newCreate() *cobra.Command {
|
|
cmd := &cobra.Command{}
|
|
|
|
var createReq provisioning.CreateNetworkRequest
|
|
var createJson flags.JsonFlag
|
|
|
|
// TODO: short flags
|
|
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
|
|
|
// TODO: complex arg: gcp_network_info
|
|
// TODO: array: security_group_ids
|
|
// TODO: array: subnet_ids
|
|
// TODO: complex arg: vpc_endpoints
|
|
cmd.Flags().StringVar(&createReq.VpcId, "vpc-id", createReq.VpcId, `The ID of the VPC associated with this network.`)
|
|
|
|
cmd.Use = "create NETWORK_NAME"
|
|
cmd.Short = `Create network configuration.`
|
|
cmd.Long = `Create network configuration.
|
|
|
|
Creates a Databricks network configuration that represents an VPC and its
|
|
resources. The VPC will be used for new Databricks clusters. This requires a
|
|
pre-existing VPC and subnets.`
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
|
check := cobra.ExactArgs(1)
|
|
if cmd.Flags().Changed("json") {
|
|
check = cobra.ExactArgs(0)
|
|
}
|
|
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)
|
|
|
|
if cmd.Flags().Changed("json") {
|
|
err = createJson.Unmarshal(&createReq)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
} else {
|
|
createReq.NetworkName = args[0]
|
|
}
|
|
|
|
response, err := a.Networks.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
|
|
}
|
|
|
|
func init() {
|
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
|
cmd.AddCommand(newCreate())
|
|
})
|
|
}
|
|
|
|
// 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,
|
|
*provisioning.DeleteNetworkRequest,
|
|
)
|
|
|
|
func newDelete() *cobra.Command {
|
|
cmd := &cobra.Command{}
|
|
|
|
var deleteReq provisioning.DeleteNetworkRequest
|
|
|
|
// TODO: short flags
|
|
|
|
cmd.Use = "delete NETWORK_ID"
|
|
cmd.Short = `Delete a network configuration.`
|
|
cmd.Long = `Delete a network configuration.
|
|
|
|
Deletes a Databricks network configuration, which represents a cloud VPC and
|
|
its resources. You cannot delete a network that is associated with a
|
|
workspace.
|
|
|
|
This operation is available only if your account is on the E2 version of the
|
|
platform.`
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
|
check := cobra.ExactArgs(1)
|
|
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)
|
|
|
|
deleteReq.NetworkId = args[0]
|
|
|
|
err = a.Networks.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
|
|
}
|
|
|
|
func init() {
|
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
|
cmd.AddCommand(newDelete())
|
|
})
|
|
}
|
|
|
|
// 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,
|
|
*provisioning.GetNetworkRequest,
|
|
)
|
|
|
|
func newGet() *cobra.Command {
|
|
cmd := &cobra.Command{}
|
|
|
|
var getReq provisioning.GetNetworkRequest
|
|
|
|
// TODO: short flags
|
|
|
|
cmd.Use = "get NETWORK_ID"
|
|
cmd.Short = `Get a network configuration.`
|
|
cmd.Long = `Get a network configuration.
|
|
|
|
Gets a Databricks network configuration, which represents a cloud VPC and its
|
|
resources.`
|
|
|
|
cmd.Annotations = make(map[string]string)
|
|
|
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
|
check := cobra.ExactArgs(1)
|
|
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)
|
|
|
|
getReq.NetworkId = args[0]
|
|
|
|
response, err := a.Networks.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
|
|
}
|
|
|
|
func init() {
|
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
|
cmd.AddCommand(newGet())
|
|
})
|
|
}
|
|
|
|
// 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 listOverrides []func(
|
|
*cobra.Command,
|
|
)
|
|
|
|
func newList() *cobra.Command {
|
|
cmd := &cobra.Command{}
|
|
|
|
cmd.Use = "list"
|
|
cmd.Short = `Get all network configurations.`
|
|
cmd.Long = `Get all network configurations.
|
|
|
|
Gets a list of all Databricks network configurations for an account, specified
|
|
by ID.
|
|
|
|
This operation is available only if your account is on the E2 version of the
|
|
platform.`
|
|
|
|
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)
|
|
response, err := a.Networks.List(ctx)
|
|
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 listOverrides {
|
|
fn(cmd)
|
|
}
|
|
|
|
return cmd
|
|
}
|
|
|
|
func init() {
|
|
cmdOverrides = append(cmdOverrides, func(cmd *cobra.Command) {
|
|
cmd.AddCommand(newList())
|
|
})
|
|
}
|
|
|
|
// end service Networks
|