databricks-cli/cmd/workspace/instance-profiles/instance-profiles.go

177 lines
5.4 KiB
Go
Executable File

// Code generated from OpenAPI specs by Databricks SDK Generator. DO NOT EDIT.
package instance_profiles
import (
"github.com/databricks/bricks/cmd/root"
"github.com/databricks/bricks/libs/cmdio"
"github.com/databricks/databricks-sdk-go/service/compute"
"github.com/spf13/cobra"
)
var Cmd = &cobra.Command{
Use: "instance-profiles",
Short: `The Instance Profiles API allows admins to add, list, and remove instance profiles that users can launch clusters with.`,
Long: `The Instance Profiles API allows admins to add, list, and remove instance
profiles that users can launch clusters with. Regular users can list the
instance profiles available to them. See [Secure access to S3 buckets] using
instance profiles for more information.
[Secure access to S3 buckets]: https://docs.databricks.com/administration-guide/cloud-configurations/aws/instance-profiles.html`,
}
// start add command
var addReq compute.AddInstanceProfile
func init() {
Cmd.AddCommand(addCmd)
// TODO: short flags
addCmd.Flags().StringVar(&addReq.IamRoleArn, "iam-role-arn", addReq.IamRoleArn, `The AWS IAM role ARN of the role associated with the instance profile.`)
addCmd.Flags().BoolVar(&addReq.IsMetaInstanceProfile, "is-meta-instance-profile", addReq.IsMetaInstanceProfile, `By default, Databricks validates that it has sufficient permissions to launch instances with the instance profile.`)
addCmd.Flags().BoolVar(&addReq.SkipValidation, "skip-validation", addReq.SkipValidation, `By default, Databricks validates that it has sufficient permissions to launch instances with the instance profile.`)
}
var addCmd = &cobra.Command{
Use: "add INSTANCE_PROFILE_ARN",
Short: `Register an instance profile.`,
Long: `Register an instance profile.
In the UI, you can select the instance profile when launching clusters. This
API is only available to admin users.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(1),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
addReq.InstanceProfileArn = args[0]
err = w.InstanceProfiles.Add(ctx, addReq)
if err != nil {
return err
}
return nil
},
}
// start edit command
var editReq compute.InstanceProfile
func init() {
Cmd.AddCommand(editCmd)
// TODO: short flags
editCmd.Flags().StringVar(&editReq.IamRoleArn, "iam-role-arn", editReq.IamRoleArn, `The AWS IAM role ARN of the role associated with the instance profile.`)
editCmd.Flags().BoolVar(&editReq.IsMetaInstanceProfile, "is-meta-instance-profile", editReq.IsMetaInstanceProfile, `By default, Databricks validates that it has sufficient permissions to launch instances with the instance profile.`)
}
var editCmd = &cobra.Command{
Use: "edit INSTANCE_PROFILE_ARN",
Short: `Edit an instance profile.`,
Long: `Edit an instance profile.
The only supported field to change is the optional IAM role ARN associated
with the instance profile. It is required to specify the IAM role ARN if both
of the following are true:
* Your role name and instance profile name do not match. The name is the part
after the last slash in each ARN. * You want to use the instance profile with
[Databricks SQL Serverless].
To understand where these fields are in the AWS console, see [Enable
serverless SQL warehouses].
This API is only available to admin users.
[Databricks SQL Serverless]: https://docs.databricks.com/sql/admin/serverless.html
[Enable serverless SQL warehouses]: https://docs.databricks.com/sql/admin/serverless.html`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(1),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
editReq.InstanceProfileArn = args[0]
err = w.InstanceProfiles.Edit(ctx, editReq)
if err != nil {
return err
}
return nil
},
}
// start list command
func init() {
Cmd.AddCommand(listCmd)
}
var listCmd = &cobra.Command{
Use: "list",
Short: `List available instance profiles.`,
Long: `List available instance profiles.
List the instance profiles that the calling user can use to launch a cluster.
This API is available to all users.`,
Annotations: map[string]string{},
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
response, err := w.InstanceProfiles.ListAll(ctx)
if err != nil {
return err
}
return cmdio.Render(ctx, response)
},
}
// start remove command
var removeReq compute.RemoveInstanceProfile
func init() {
Cmd.AddCommand(removeCmd)
// TODO: short flags
}
var removeCmd = &cobra.Command{
Use: "remove INSTANCE_PROFILE_ARN",
Short: `Remove the instance profile.`,
Long: `Remove the instance profile.
Remove the instance profile with the provided ARN. Existing clusters with this
instance profile will continue to function.
This API is only accessible to admin users.`,
Annotations: map[string]string{},
Args: cobra.ExactArgs(1),
PreRunE: root.MustWorkspaceClient,
RunE: func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
w := root.WorkspaceClient(ctx)
removeReq.InstanceProfileArn = args[0]
err = w.InstanceProfiles.Remove(ctx, removeReq)
if err != nil {
return err
}
return nil
},
}
// end service InstanceProfiles