mirror of https://github.com/databricks/cli.git
Fixed requiring positional arguments for API URL parameters (#878)
## Changes Some commands such as update commands have an argument in their url, for example in pipeline we have `PUT pipelines/<id>` to update the pipeline. Such parameters must be required and respected even if `--json` flag with the payload passed. Note: this depends on these PRs in Go SDK: https://github.com/databricks/databricks-sdk-go/pull/660 https://github.com/databricks/databricks-sdk-go/pull/661 ## Tests Manually running `databricks pipelines update`
This commit is contained in:
parent
3700785dfa
commit
4ad68eb314
|
@ -78,8 +78,7 @@ var {{.CamelName}}Overrides []func(
|
||||||
func new{{.PascalName}}() *cobra.Command {
|
func new{{.PascalName}}() *cobra.Command {
|
||||||
cmd := &cobra.Command{}
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
{{- $useJsonForAllFields := or .IsJsonOnly (and .Request (or (not .Request.IsAllRequiredFieldsPrimitive) .Request.HasRequiredNonBodyField)) -}}
|
{{- $needJsonFlag := or .CanSetRequiredFieldsFromJson (and .Request (not .Request.IsOnlyPrimitiveFields)) -}}
|
||||||
{{- $needJsonFlag := or $useJsonForAllFields (and .Request (not .Request.IsOnlyPrimitiveFields)) -}}
|
|
||||||
|
|
||||||
{{- if .Request}}
|
{{- if .Request}}
|
||||||
|
|
||||||
|
@ -143,7 +142,7 @@ func new{{.PascalName}}() *cobra.Command {
|
||||||
{{if $hasRequiredArgs }}
|
{{if $hasRequiredArgs }}
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
check := cobra.ExactArgs({{len .Request.RequiredFields}})
|
check := cobra.ExactArgs({{len .Request.RequiredFields}})
|
||||||
{{- if $useJsonForAllFields }}
|
{{- if .CanSetRequiredFieldsFromJson }}
|
||||||
if cmd.Flags().Changed("json") {
|
if cmd.Flags().Changed("json") {
|
||||||
check = cobra.ExactArgs(0)
|
check = cobra.ExactArgs(0)
|
||||||
}
|
}
|
||||||
|
@ -162,7 +161,7 @@ func new{{.PascalName}}() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}{{end}}{{if $useJsonForAllFields }} else {
|
}{{end}}{{if .CanSetRequiredFieldsFromJson }} else {
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $hasIdPrompt}}
|
{{- if $hasIdPrompt}}
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
|
@ -196,7 +195,7 @@ func new{{.PascalName}}() *cobra.Command {
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{if $useJsonForAllFields }}
|
{{if .CanSetRequiredFieldsFromJson }}
|
||||||
}
|
}
|
||||||
{{end }}
|
{{end }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -478,26 +478,25 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if len(args) == 0 {
|
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
|
|
||||||
names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{})
|
|
||||||
close(promptSpinner)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err)
|
|
||||||
}
|
|
||||||
id, err := cmdio.Select(ctx, names, "Databricks group ID")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args = append(args, id)
|
|
||||||
}
|
|
||||||
if len(args) != 1 {
|
|
||||||
return fmt.Errorf("expected to have databricks group id")
|
|
||||||
}
|
|
||||||
updateReq.Id = args[0]
|
|
||||||
}
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
|
||||||
|
names, err := a.Groups.GroupDisplayNameToIdMap(ctx, iam.ListAccountGroupsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Account Groups drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "Databricks group ID")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have databricks group id")
|
||||||
|
}
|
||||||
|
updateReq.Id = args[0]
|
||||||
|
|
||||||
err = a.Groups.Update(ctx, updateReq)
|
err = a.Groups.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -480,26 +480,25 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if len(args) == 0 {
|
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
|
|
||||||
names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{})
|
|
||||||
close(promptSpinner)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
|
|
||||||
}
|
|
||||||
id, err := cmdio.Select(ctx, names, "Databricks service principal ID")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args = append(args, id)
|
|
||||||
}
|
|
||||||
if len(args) != 1 {
|
|
||||||
return fmt.Errorf("expected to have databricks service principal id")
|
|
||||||
}
|
|
||||||
updateReq.Id = args[0]
|
|
||||||
}
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
|
||||||
|
names, err := a.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListAccountServicePrincipalsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Account Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "Databricks service principal ID")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have databricks service principal id")
|
||||||
|
}
|
||||||
|
updateReq.Id = args[0]
|
||||||
|
|
||||||
err = a.ServicePrincipals.Update(ctx, updateReq)
|
err = a.ServicePrincipals.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -488,26 +488,25 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if len(args) == 0 {
|
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
|
|
||||||
names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{})
|
|
||||||
close(promptSpinner)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err)
|
|
||||||
}
|
|
||||||
id, err := cmdio.Select(ctx, names, "Databricks user ID")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args = append(args, id)
|
|
||||||
}
|
|
||||||
if len(args) != 1 {
|
|
||||||
return fmt.Errorf("expected to have databricks user id")
|
|
||||||
}
|
|
||||||
updateReq.Id = args[0]
|
|
||||||
}
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
|
||||||
|
names, err := a.Users.UserUserNameToIdMap(ctx, iam.ListAccountUsersRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Account Users drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "Databricks user ID")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have databricks user id")
|
||||||
|
}
|
||||||
|
updateReq.Id = args[0]
|
||||||
|
|
||||||
err = a.Users.Update(ctx, updateReq)
|
err = a.Users.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -337,9 +337,6 @@ func newUpdate() *cobra.Command {
|
||||||
|
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
check := cobra.ExactArgs(1)
|
check := cobra.ExactArgs(1)
|
||||||
if cmd.Flags().Changed("json") {
|
|
||||||
check = cobra.ExactArgs(0)
|
|
||||||
}
|
|
||||||
return check(cmd, args)
|
return check(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,9 +350,8 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
updateReq.Name = args[0]
|
|
||||||
}
|
}
|
||||||
|
updateReq.Name = args[0]
|
||||||
|
|
||||||
response, err := w.Catalogs.Update(ctx, updateReq)
|
response, err := w.Catalogs.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -346,9 +346,6 @@ func newUpdate() *cobra.Command {
|
||||||
|
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
check := cobra.ExactArgs(1)
|
check := cobra.ExactArgs(1)
|
||||||
if cmd.Flags().Changed("json") {
|
|
||||||
check = cobra.ExactArgs(0)
|
|
||||||
}
|
|
||||||
return check(cmd, args)
|
return check(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,9 +359,8 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
updateReq.Name = args[0]
|
|
||||||
}
|
}
|
||||||
|
updateReq.Name = args[0]
|
||||||
|
|
||||||
response, err := w.ExternalLocations.Update(ctx, updateReq)
|
response, err := w.ExternalLocations.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -478,26 +478,25 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if len(args) == 0 {
|
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Groups drop-down."
|
|
||||||
names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{})
|
|
||||||
close(promptSpinner)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err)
|
|
||||||
}
|
|
||||||
id, err := cmdio.Select(ctx, names, "Databricks group ID")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args = append(args, id)
|
|
||||||
}
|
|
||||||
if len(args) != 1 {
|
|
||||||
return fmt.Errorf("expected to have databricks group id")
|
|
||||||
}
|
|
||||||
updateReq.Id = args[0]
|
|
||||||
}
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No ID argument specified. Loading names for Groups drop-down."
|
||||||
|
names, err := w.Groups.GroupDisplayNameToIdMap(ctx, iam.ListGroupsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Groups drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "Databricks group ID")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have databricks group id")
|
||||||
|
}
|
||||||
|
updateReq.Id = args[0]
|
||||||
|
|
||||||
err = w.Groups.Update(ctx, updateReq)
|
err = w.Groups.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1130,26 +1130,25 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if len(args) == 0 {
|
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
|
||||||
promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down."
|
|
||||||
names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{})
|
|
||||||
close(promptSpinner)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err)
|
|
||||||
}
|
|
||||||
id, err := cmdio.Select(ctx, names, "Unique identifier for this pipeline")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args = append(args, id)
|
|
||||||
}
|
|
||||||
if len(args) != 1 {
|
|
||||||
return fmt.Errorf("expected to have unique identifier for this pipeline")
|
|
||||||
}
|
|
||||||
updateReq.PipelineId = args[0]
|
|
||||||
}
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down."
|
||||||
|
names, err := w.Pipelines.PipelineStateInfoNameToPipelineIdMap(ctx, pipelines.ListPipelinesRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Pipelines drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "Unique identifier for this pipeline")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have unique identifier for this pipeline")
|
||||||
|
}
|
||||||
|
updateReq.PipelineId = args[0]
|
||||||
|
|
||||||
err = w.Pipelines.Update(ctx, updateReq)
|
err = w.Pipelines.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -432,10 +432,8 @@ func newUpdate() *cobra.Command {
|
||||||
cmd := &cobra.Command{}
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
var updateReq sharing.UpdateProvider
|
var updateReq sharing.UpdateProvider
|
||||||
var updateJson flags.JsonFlag
|
|
||||||
|
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
|
||||||
|
|
||||||
cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `Description about the provider.`)
|
cmd.Flags().StringVar(&updateReq.Comment, "comment", updateReq.Comment, `Description about the provider.`)
|
||||||
cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `The name of the Provider.`)
|
cmd.Flags().StringVar(&updateReq.Name, "name", updateReq.Name, `The name of the Provider.`)
|
||||||
|
@ -458,31 +456,24 @@ func newUpdate() *cobra.Command {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
if len(args) == 0 {
|
||||||
err = updateJson.Unmarshal(&updateReq)
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No NAME argument specified. Loading names for Providers drop-down."
|
||||||
|
names, err := w.Providers.ProviderInfoNameToMetastoreIdMap(ctx, sharing.ListProvidersRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Providers drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The name of the Provider")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
args = append(args, id)
|
||||||
if len(args) == 0 {
|
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
|
||||||
promptSpinner <- "No NAME argument specified. Loading names for Providers drop-down."
|
|
||||||
names, err := w.Providers.ProviderInfoNameToMetastoreIdMap(ctx, sharing.ListProvidersRequest{})
|
|
||||||
close(promptSpinner)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to load names for Providers drop-down. Please manually specify required arguments. Original error: %w", err)
|
|
||||||
}
|
|
||||||
id, err := cmdio.Select(ctx, names, "The name of the Provider")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args = append(args, id)
|
|
||||||
}
|
|
||||||
if len(args) != 1 {
|
|
||||||
return fmt.Errorf("expected to have the name of the provider")
|
|
||||||
}
|
|
||||||
updateReq.Name = args[0]
|
|
||||||
}
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the name of the provider")
|
||||||
|
}
|
||||||
|
updateReq.Name = args[0]
|
||||||
|
|
||||||
response, err := w.Providers.Update(ctx, updateReq)
|
response, err := w.Providers.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -547,26 +547,25 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if len(args) == 0 {
|
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
|
||||||
promptSpinner <- "No NAME argument specified. Loading names for Recipients drop-down."
|
|
||||||
names, err := w.Recipients.RecipientInfoNameToMetastoreIdMap(ctx, sharing.ListRecipientsRequest{})
|
|
||||||
close(promptSpinner)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to load names for Recipients drop-down. Please manually specify required arguments. Original error: %w", err)
|
|
||||||
}
|
|
||||||
id, err := cmdio.Select(ctx, names, "Name of Recipient")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args = append(args, id)
|
|
||||||
}
|
|
||||||
if len(args) != 1 {
|
|
||||||
return fmt.Errorf("expected to have name of recipient")
|
|
||||||
}
|
|
||||||
updateReq.Name = args[0]
|
|
||||||
}
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No NAME argument specified. Loading names for Recipients drop-down."
|
||||||
|
names, err := w.Recipients.RecipientInfoNameToMetastoreIdMap(ctx, sharing.ListRecipientsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Recipients drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "Name of Recipient")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have name of recipient")
|
||||||
|
}
|
||||||
|
updateReq.Name = args[0]
|
||||||
|
|
||||||
err = w.Recipients.Update(ctx, updateReq)
|
err = w.Recipients.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -477,10 +477,8 @@ func newSetAlias() *cobra.Command {
|
||||||
cmd := &cobra.Command{}
|
cmd := &cobra.Command{}
|
||||||
|
|
||||||
var setAliasReq catalog.SetRegisteredModelAliasRequest
|
var setAliasReq catalog.SetRegisteredModelAliasRequest
|
||||||
var setAliasJson flags.JsonFlag
|
|
||||||
|
|
||||||
// TODO: short flags
|
// TODO: short flags
|
||||||
cmd.Flags().Var(&setAliasJson, "json", `either inline JSON string or @path/to/file.json with request body`)
|
|
||||||
|
|
||||||
cmd.Use = "set-alias FULL_NAME ALIAS VERSION_NUM"
|
cmd.Use = "set-alias FULL_NAME ALIAS VERSION_NUM"
|
||||||
cmd.Short = `Set a Registered Model Alias.`
|
cmd.Short = `Set a Registered Model Alias.`
|
||||||
|
@ -497,9 +495,6 @@ func newSetAlias() *cobra.Command {
|
||||||
|
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
check := cobra.ExactArgs(3)
|
check := cobra.ExactArgs(3)
|
||||||
if cmd.Flags().Changed("json") {
|
|
||||||
check = cobra.ExactArgs(0)
|
|
||||||
}
|
|
||||||
return check(cmd, args)
|
return check(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,18 +503,11 @@ func newSetAlias() *cobra.Command {
|
||||||
ctx := cmd.Context()
|
ctx := cmd.Context()
|
||||||
w := root.WorkspaceClient(ctx)
|
w := root.WorkspaceClient(ctx)
|
||||||
|
|
||||||
if cmd.Flags().Changed("json") {
|
setAliasReq.FullName = args[0]
|
||||||
err = setAliasJson.Unmarshal(&setAliasReq)
|
setAliasReq.Alias = args[1]
|
||||||
if err != nil {
|
_, err = fmt.Sscan(args[2], &setAliasReq.VersionNum)
|
||||||
return err
|
if err != nil {
|
||||||
}
|
return fmt.Errorf("invalid VERSION_NUM: %s", args[2])
|
||||||
} else {
|
|
||||||
setAliasReq.FullName = args[0]
|
|
||||||
setAliasReq.Alias = args[1]
|
|
||||||
_, err = fmt.Sscan(args[2], &setAliasReq.VersionNum)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("invalid VERSION_NUM: %s", args[2])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := w.RegisteredModels.SetAlias(ctx, setAliasReq)
|
response, err := w.RegisteredModels.SetAlias(ctx, setAliasReq)
|
||||||
|
|
|
@ -480,26 +480,25 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if len(args) == 0 {
|
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Service Principals drop-down."
|
|
||||||
names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{})
|
|
||||||
close(promptSpinner)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
|
|
||||||
}
|
|
||||||
id, err := cmdio.Select(ctx, names, "Databricks service principal ID")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args = append(args, id)
|
|
||||||
}
|
|
||||||
if len(args) != 1 {
|
|
||||||
return fmt.Errorf("expected to have databricks service principal id")
|
|
||||||
}
|
|
||||||
updateReq.Id = args[0]
|
|
||||||
}
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No ID argument specified. Loading names for Service Principals drop-down."
|
||||||
|
names, err := w.ServicePrincipals.ServicePrincipalDisplayNameToIdMap(ctx, iam.ListServicePrincipalsRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Service Principals drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "Databricks service principal ID")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have databricks service principal id")
|
||||||
|
}
|
||||||
|
updateReq.Id = args[0]
|
||||||
|
|
||||||
err = w.ServicePrincipals.Update(ctx, updateReq)
|
err = w.ServicePrincipals.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -398,9 +398,6 @@ func newUpdate() *cobra.Command {
|
||||||
|
|
||||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||||
check := cobra.ExactArgs(1)
|
check := cobra.ExactArgs(1)
|
||||||
if cmd.Flags().Changed("json") {
|
|
||||||
check = cobra.ExactArgs(0)
|
|
||||||
}
|
|
||||||
return check(cmd, args)
|
return check(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,9 +411,8 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
updateReq.Name = args[0]
|
|
||||||
}
|
}
|
||||||
|
updateReq.Name = args[0]
|
||||||
|
|
||||||
response, err := w.Shares.Update(ctx, updateReq)
|
response, err := w.Shares.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -378,26 +378,25 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if len(args) == 0 {
|
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
|
||||||
promptSpinner <- "No NAME argument specified. Loading names for Storage Credentials drop-down."
|
|
||||||
names, err := w.StorageCredentials.StorageCredentialInfoNameToIdMap(ctx)
|
|
||||||
close(promptSpinner)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to load names for Storage Credentials drop-down. Please manually specify required arguments. Original error: %w", err)
|
|
||||||
}
|
|
||||||
id, err := cmdio.Select(ctx, names, "The credential name")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args = append(args, id)
|
|
||||||
}
|
|
||||||
if len(args) != 1 {
|
|
||||||
return fmt.Errorf("expected to have the credential name")
|
|
||||||
}
|
|
||||||
updateReq.Name = args[0]
|
|
||||||
}
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No NAME argument specified. Loading names for Storage Credentials drop-down."
|
||||||
|
names, err := w.StorageCredentials.StorageCredentialInfoNameToIdMap(ctx)
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Storage Credentials drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "The credential name")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have the credential name")
|
||||||
|
}
|
||||||
|
updateReq.Name = args[0]
|
||||||
|
|
||||||
response, err := w.StorageCredentials.Update(ctx, updateReq)
|
response, err := w.StorageCredentials.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -660,26 +660,25 @@ func newUpdate() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if len(args) == 0 {
|
|
||||||
promptSpinner := cmdio.Spinner(ctx)
|
|
||||||
promptSpinner <- "No ID argument specified. Loading names for Users drop-down."
|
|
||||||
names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{})
|
|
||||||
close(promptSpinner)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err)
|
|
||||||
}
|
|
||||||
id, err := cmdio.Select(ctx, names, "Databricks user ID")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
args = append(args, id)
|
|
||||||
}
|
|
||||||
if len(args) != 1 {
|
|
||||||
return fmt.Errorf("expected to have databricks user id")
|
|
||||||
}
|
|
||||||
updateReq.Id = args[0]
|
|
||||||
}
|
}
|
||||||
|
if len(args) == 0 {
|
||||||
|
promptSpinner := cmdio.Spinner(ctx)
|
||||||
|
promptSpinner <- "No ID argument specified. Loading names for Users drop-down."
|
||||||
|
names, err := w.Users.UserUserNameToIdMap(ctx, iam.ListUsersRequest{})
|
||||||
|
close(promptSpinner)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to load names for Users drop-down. Please manually specify required arguments. Original error: %w", err)
|
||||||
|
}
|
||||||
|
id, err := cmdio.Select(ctx, names, "Databricks user ID")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args = append(args, id)
|
||||||
|
}
|
||||||
|
if len(args) != 1 {
|
||||||
|
return fmt.Errorf("expected to have databricks user id")
|
||||||
|
}
|
||||||
|
updateReq.Id = args[0]
|
||||||
|
|
||||||
err = w.Users.Update(ctx, updateReq)
|
err = w.Users.Update(ctx, updateReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue