mirror of https://github.com/databricks/cli.git
239 lines
6.2 KiB
Go
Executable File
239 lines
6.2 KiB
Go
Executable File
// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
|
|
|
|
package metastores
|
|
|
|
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"
|
|
)
|
|
|
|
var Cmd = &cobra.Command{
|
|
Use: "metastores",
|
|
Short: `These APIs manage Unity Catalog metastores for an account.`,
|
|
Long: `These APIs manage Unity Catalog metastores for an account. A metastore
|
|
contains catalogs that can be associated with workspaces`,
|
|
Annotations: map[string]string{
|
|
"package": "catalog",
|
|
},
|
|
}
|
|
|
|
// start create command
|
|
var createReq catalog.AccountsCreateMetastore
|
|
var createJson flags.JsonFlag
|
|
|
|
func init() {
|
|
Cmd.AddCommand(createCmd)
|
|
// TODO: short flags
|
|
createCmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
|
|
|
// TODO: complex arg: metastore_info
|
|
|
|
}
|
|
|
|
var createCmd = &cobra.Command{
|
|
Use: "create",
|
|
Short: `Create metastore.`,
|
|
Long: `Create metastore.
|
|
|
|
Creates a Unity Catalog metastore. Please add a header
|
|
X-Databricks-Account-Console-API-Version: 2.0 to access this API.`,
|
|
|
|
Annotations: map[string]string{},
|
|
Args: func(cmd *cobra.Command, args []string) error {
|
|
check := cobra.ExactArgs(0)
|
|
if cmd.Flags().Changed("json") {
|
|
check = cobra.ExactArgs(0)
|
|
}
|
|
return check(cmd, args)
|
|
},
|
|
PreRunE: root.MustAccountClient,
|
|
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 {
|
|
}
|
|
|
|
response, err := a.Metastores.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`.
|
|
ValidArgsFunction: cobra.NoFileCompletions,
|
|
}
|
|
|
|
// start delete command
|
|
var deleteReq catalog.DeleteAccountMetastoreRequest
|
|
|
|
func init() {
|
|
Cmd.AddCommand(deleteCmd)
|
|
// TODO: short flags
|
|
|
|
}
|
|
|
|
var deleteCmd = &cobra.Command{
|
|
Use: "delete METASTORE_ID",
|
|
Short: `Delete a metastore.`,
|
|
Long: `Delete a metastore.
|
|
|
|
Deletes a Unity Catalog metastore for an account, both specified by ID. Please
|
|
add a header X-Databricks-Account-Console-API-Version: 2.0 to access this API.`,
|
|
|
|
Annotations: map[string]string{},
|
|
Args: func(cmd *cobra.Command, args []string) error {
|
|
check := cobra.ExactArgs(1)
|
|
return check(cmd, args)
|
|
},
|
|
PreRunE: root.MustAccountClient,
|
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
|
ctx := cmd.Context()
|
|
a := root.AccountClient(ctx)
|
|
|
|
deleteReq.MetastoreId = args[0]
|
|
|
|
err = a.Metastores.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`.
|
|
ValidArgsFunction: cobra.NoFileCompletions,
|
|
}
|
|
|
|
// start get command
|
|
var getReq catalog.GetAccountMetastoreRequest
|
|
|
|
func init() {
|
|
Cmd.AddCommand(getCmd)
|
|
// TODO: short flags
|
|
|
|
}
|
|
|
|
var getCmd = &cobra.Command{
|
|
Use: "get METASTORE_ID",
|
|
Short: `Get a metastore.`,
|
|
Long: `Get a metastore.
|
|
|
|
Gets a Unity Catalog metastore from an account, both specified by ID. Please
|
|
add a header X-Databricks-Account-Console-API-Version: 2.0 to access this API.`,
|
|
|
|
Annotations: map[string]string{},
|
|
Args: func(cmd *cobra.Command, args []string) error {
|
|
check := cobra.ExactArgs(1)
|
|
return check(cmd, args)
|
|
},
|
|
PreRunE: root.MustAccountClient,
|
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
|
ctx := cmd.Context()
|
|
a := root.AccountClient(ctx)
|
|
|
|
getReq.MetastoreId = args[0]
|
|
|
|
response, err := a.Metastores.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`.
|
|
ValidArgsFunction: cobra.NoFileCompletions,
|
|
}
|
|
|
|
// start list command
|
|
|
|
func init() {
|
|
Cmd.AddCommand(listCmd)
|
|
|
|
}
|
|
|
|
var listCmd = &cobra.Command{
|
|
Use: "list",
|
|
Short: `Get all metastores associated with an account.`,
|
|
Long: `Get all metastores associated with an account.
|
|
|
|
Gets all Unity Catalog metastores associated with an account specified by ID.
|
|
Please add a header X-Databricks-Account-Console-API-Version: 2.0 to access
|
|
this API.`,
|
|
|
|
Annotations: map[string]string{},
|
|
PreRunE: root.MustAccountClient,
|
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
|
ctx := cmd.Context()
|
|
a := root.AccountClient(ctx)
|
|
response, err := a.Metastores.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`.
|
|
ValidArgsFunction: cobra.NoFileCompletions,
|
|
}
|
|
|
|
// start update command
|
|
var updateReq catalog.AccountsUpdateMetastore
|
|
var updateJson flags.JsonFlag
|
|
|
|
func init() {
|
|
Cmd.AddCommand(updateCmd)
|
|
// TODO: short flags
|
|
updateCmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
|
|
|
// TODO: complex arg: metastore_info
|
|
|
|
}
|
|
|
|
var updateCmd = &cobra.Command{
|
|
Use: "update METASTORE_ID",
|
|
Short: `Update a metastore.`,
|
|
Long: `Update a metastore.
|
|
|
|
Updates an existing Unity Catalog metastore. Please add a header
|
|
X-Databricks-Account-Console-API-Version: 2.0 to access this API.`,
|
|
|
|
Annotations: map[string]string{},
|
|
Args: func(cmd *cobra.Command, args []string) error {
|
|
check := cobra.ExactArgs(1)
|
|
return check(cmd, args)
|
|
},
|
|
PreRunE: root.MustAccountClient,
|
|
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
|
|
}
|
|
}
|
|
updateReq.MetastoreId = args[0]
|
|
|
|
response, err := a.Metastores.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`.
|
|
ValidArgsFunction: cobra.NoFileCompletions,
|
|
}
|
|
|
|
// end service AccountMetastores
|