databricks-cli/cmd/account/vpc-endpoints/vpc-endpoints.go

313 lines
8.7 KiB
Go
Executable File

// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package vpc_endpoints
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: "vpc-endpoints",
Short: `These APIs manage VPC endpoint configurations for this account.`,
Long: `These APIs manage VPC endpoint configurations for this account.`,
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.CreateVpcEndpointRequest,
)
func newCreate() *cobra.Command {
cmd := &cobra.Command{}
var createReq provisioning.CreateVpcEndpointRequest
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.AwsVpcEndpointId, "aws-vpc-endpoint-id", createReq.AwsVpcEndpointId, `The ID of the VPC endpoint object in AWS.`)
// TODO: complex arg: gcp_vpc_endpoint_info
cmd.Flags().StringVar(&createReq.Region, "region", createReq.Region, `The AWS region in which this VPC endpoint object exists.`)
cmd.Use = "create VPC_ENDPOINT_NAME"
cmd.Short = `Create VPC endpoint configuration.`
cmd.Long = `Create VPC endpoint configuration.
Creates a VPC endpoint configuration, which represents a [VPC endpoint] object
in AWS used to communicate privately with Databricks over [AWS PrivateLink].
After you create the VPC endpoint configuration, the Databricks [endpoint
service] automatically accepts the VPC endpoint.
Before configuring PrivateLink, read the [Databricks article about
PrivateLink].
[AWS PrivateLink]: https://aws.amazon.com/privatelink
[Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html
[VPC endpoint]: https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints.html
[endpoint service]: https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-share-your-services.html`
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.VpcEndpointName = args[0]
}
response, err := a.VpcEndpoints.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.DeleteVpcEndpointRequest,
)
func newDelete() *cobra.Command {
cmd := &cobra.Command{}
var deleteReq provisioning.DeleteVpcEndpointRequest
// TODO: short flags
cmd.Use = "delete VPC_ENDPOINT_ID"
cmd.Short = `Delete VPC endpoint configuration.`
cmd.Long = `Delete VPC endpoint configuration.
Deletes a VPC endpoint configuration, which represents an [AWS VPC endpoint]
that can communicate privately with Databricks over [AWS PrivateLink].
Before configuring PrivateLink, read the [Databricks article about
PrivateLink].
[AWS PrivateLink]: https://aws.amazon.com/privatelink
[AWS VPC endpoint]: https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html
[Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html`
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.VpcEndpointId = args[0]
err = a.VpcEndpoints.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.GetVpcEndpointRequest,
)
func newGet() *cobra.Command {
cmd := &cobra.Command{}
var getReq provisioning.GetVpcEndpointRequest
// TODO: short flags
cmd.Use = "get VPC_ENDPOINT_ID"
cmd.Short = `Get a VPC endpoint configuration.`
cmd.Long = `Get a VPC endpoint configuration.
Gets a VPC endpoint configuration, which represents a [VPC endpoint] object in
AWS used to communicate privately with Databricks over [AWS PrivateLink].
[AWS PrivateLink]: https://aws.amazon.com/privatelink
[VPC endpoint]: https://docs.aws.amazon.com/vpc/latest/privatelink/concepts.html`
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.VpcEndpointId = args[0]
response, err := a.VpcEndpoints.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 VPC endpoint configurations.`
cmd.Long = `Get all VPC endpoint configurations.
Gets a list of all VPC endpoints for an account, specified by ID.
Before configuring PrivateLink, read the [Databricks article about
PrivateLink].
[Databricks article about PrivateLink]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/privatelink.html`
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.VpcEndpoints.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 VpcEndpoints