Fixed jobs create command to only accept JSON payload

This commit is contained in:
Andrew Nester 2023-06-19 14:21:47 +02:00
parent 63e80a0b71
commit f88605c032
No known key found for this signature in database
GPG Key ID: 12BC628A44B7DA57
20 changed files with 71 additions and 80 deletions

View File

@ -58,6 +58,7 @@ func init() {
{{if .Request}}// TODO: short flags
{{.CamelName}}Cmd.Flags().Var(&{{.CamelName}}Json, "json", `either inline JSON string or @path/to/file.json with request body`)
{{$method := .}}
{{ if not .OnlyPayload }}
{{range .Request.Fields -}}
{{- if not .Required -}}
{{if .Entity.IsObject }}// TODO: complex arg: {{.Name}}
@ -70,6 +71,7 @@ func init() {
{{end}}
{{- end -}}
{{- end}}
{{- end}}
{{end}}
}
{{- $excludeFromPrompts := list "workspace get-status" -}}
@ -133,7 +135,7 @@ var {{.CamelName}}Cmd = &cobra.Command{
}
{{- end -}}
{{$method := .}}
{{- if .Request.IsAllRequiredFieldsPrimitive -}}
{{- if and .Request.IsAllRequiredFieldsPrimitive (not .OnlyPayload) -}}
{{- range $arg, $field := .Request.RequiredFields}}
{{if not $field.Entity.IsString -}}
_, err = fmt.Sscan(args[{{$arg}}], &{{$method.CamelName}}Req.{{$field.PascalName}})

View File

@ -55,7 +55,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := a.Budgets.Create(ctx, createReq)
@ -254,7 +254,7 @@ var updateCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
err = a.Budgets.Update(ctx, updateReq)

View File

@ -68,7 +68,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := a.Credentials.Create(ctx, createReq)

View File

@ -63,7 +63,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := a.CustomAppIntegration.Create(ctx, createReq)

View File

@ -85,7 +85,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := a.EncryptionKeys.Create(ctx, createReq)

View File

@ -85,7 +85,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := a.IpAccessLists.Create(ctx, createReq)
@ -292,7 +292,7 @@ var replaceCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
err = a.IpAccessLists.Replace(ctx, replaceReq)
@ -351,7 +351,7 @@ var updateCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
err = a.IpAccessLists.Update(ctx, updateReq)

View File

@ -65,7 +65,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := a.Storage.Create(ctx, createReq)

View File

@ -221,7 +221,7 @@ var updateCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
err = a.WorkspaceAssignment.Update(ctx, updateReq)

View File

@ -60,7 +60,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := w.Alerts.Create(ctx, createReq)
@ -260,7 +260,7 @@ var updateCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
err = w.Alerts.Update(ctx, updateReq)

View File

@ -73,7 +73,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := w.Connections.Create(ctx, createReq)
@ -269,7 +269,7 @@ var updateCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := w.Connections.Update(ctx, updateReq)

View File

@ -66,7 +66,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := w.Functions.Create(ctx, createReq)

View File

@ -86,7 +86,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := w.IpAccessLists.Create(ctx, createReq)
@ -295,7 +295,7 @@ var replaceCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
err = w.IpAccessLists.Replace(ctx, replaceReq)
@ -356,7 +356,7 @@ var updateCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
err = w.IpAccessLists.Update(ctx, updateReq)

View File

@ -203,23 +203,6 @@ func init() {
// TODO: short flags
createCmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: array: access_control_list
// TODO: complex arg: continuous
// TODO: complex arg: email_notifications
createCmd.Flags().Var(&createReq.Format, "format", `Used to tell what is the format of the job.`)
// TODO: complex arg: git_source
// TODO: array: job_clusters
createCmd.Flags().IntVar(&createReq.MaxConcurrentRuns, "max-concurrent-runs", createReq.MaxConcurrentRuns, `An optional maximum allowed number of concurrent runs of the job.`)
createCmd.Flags().StringVar(&createReq.Name, "name", createReq.Name, `An optional name for the job.`)
// TODO: complex arg: notification_settings
// TODO: complex arg: run_as
// TODO: complex arg: schedule
// TODO: map via StringToStringVar: tags
// TODO: array: tasks
createCmd.Flags().IntVar(&createReq.TimeoutSeconds, "timeout-seconds", createReq.TimeoutSeconds, `An optional timeout applied to each run of this job.`)
// TODO: complex arg: trigger
// TODO: complex arg: webhook_notifications
}
var createCmd = &cobra.Command{
@ -247,6 +230,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := w.Jobs.Create(ctx, createReq)
@ -912,7 +896,7 @@ var resetCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
err = w.Jobs.Reset(ctx, resetReq)

View File

@ -172,7 +172,7 @@ var installCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
err = w.Libraries.Install(ctx, installReq)
@ -218,7 +218,7 @@ var uninstallCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
err = w.Libraries.Uninstall(ctx, uninstallReq)

View File

@ -349,7 +349,7 @@ var createWebhookCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := w.ModelRegistry.CreateWebhook(ctx, createWebhookReq)

View File

@ -42,8 +42,8 @@ func init() {
// TODO: short flags
createScopeCmd.Flags().Var(&createScopeJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: complex arg: backend_azure_keyvault
createScopeCmd.Flags().StringVar(&createScopeReq.InitialManagePrincipal, "initial-manage-principal", createScopeReq.InitialManagePrincipal, `The principal that is initially granted MANAGE permission to the created scope.`)
// TODO: complex arg: keyvault_metadata
createScopeCmd.Flags().Var(&createScopeReq.ScopeBackendType, "scope-backend-type", `The backend type the scope will be created with.`)
}
@ -502,9 +502,9 @@ var putAclCmd = &cobra.Command{
Throws RESOURCE_DOES_NOT_EXIST if no such secret scope exists. Throws
RESOURCE_ALREADY_EXISTS if a permission for the principal already exists.
Throws INVALID_PARAMETER_VALUE if the permission is invalid. Throws
PERMISSION_DENIED if the user does not have permission to make this API
call.`,
Throws INVALID_PARAMETER_VALUE if the permission or principal is invalid.
Throws PERMISSION_DENIED if the user does not have permission to make this
API call.`,
Annotations: map[string]string{},
Args: func(cmd *cobra.Command, args []string) error {

View File

@ -120,7 +120,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
wait, err := w.ServingEndpoints.Create(ctx, createReq)
@ -470,7 +470,7 @@ var updateConfigCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
wait, err := w.ServingEndpoints.UpdateConfig(ctx, updateConfigReq)

View File

@ -3,6 +3,8 @@
package system_schemas
import (
"fmt"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags"
@ -63,7 +65,10 @@ var disableCmd = &cobra.Command{
}
} else {
disableReq.MetastoreId = args[0]
disableReq.SchemaName = args[1]
_, err = fmt.Sscan(args[1], &disableReq.SchemaName)
if err != nil {
return fmt.Errorf("invalid SCHEMA_NAME: %s", args[1])
}
}
err = w.SystemSchemas.Disable(ctx, disableReq)

View File

@ -72,7 +72,7 @@ var createCmd = &cobra.Command{
return err
}
} else {
return fmt.Errorf("provide command input in JSON format by specifying --json option")
return fmt.Errorf("please provide command input in JSON format by specifying the --json flag")
}
response, err := w.TableConstraints.Create(ctx, createReq)