mirror of https://github.com/databricks/cli.git
fixed apps and dashboard command generation
This commit is contained in:
parent
da4b856e57
commit
91ad4df7bf
|
@ -115,6 +115,9 @@ func new{{.PascalName}}() *cobra.Command {
|
|||
{{- if .Request}}
|
||||
|
||||
var {{.CamelName}}Req {{.Service.Package.Name}}.{{.Request.PascalName}}
|
||||
{{- if .RequestBodyField }}
|
||||
{{.CamelName}}Req.{{.RequestBodyField.PascalName}} = &{{.Service.Package.Name}}.{{.RequestBodyField.Entity.PascalName}}{}
|
||||
{{- end }}
|
||||
{{- if .CanUseJson}}
|
||||
var {{.CamelName}}Json flags.JsonFlag
|
||||
{{- end}}
|
||||
|
@ -232,7 +235,7 @@ func new{{.PascalName}}() *cobra.Command {
|
|||
{{- if .Request }}
|
||||
{{ if .CanUseJson }}
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req)
|
||||
diags := {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req{{ if .RequestBodyField }}.{{.RequestBodyField.PascalName}}{{ end }})
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
|
@ -392,7 +395,7 @@ func new{{.PascalName}}() *cobra.Command {
|
|||
if err != nil {
|
||||
return fmt.Errorf("invalid {{$field.ConstantName}}: %s", args[{{$arg}}])
|
||||
}{{else -}}
|
||||
{{$method.CamelName}}Req.{{$field.PascalName}} = args[{{$arg}}]
|
||||
{{$method.CamelName}}Req.{{ if $method.RequestBodyField }}{{$method.RequestBodyField.PascalName}}.{{end}}{{$field.PascalName}} = args[{{$arg}}]
|
||||
{{- end -}}
|
||||
{{- if $optionalIfJsonIsUsed }}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ func newCreate() *cobra.Command {
|
|||
cmd := &cobra.Command{}
|
||||
|
||||
var createReq apps.CreateAppRequest
|
||||
createReq.App = &apps.App{}
|
||||
var createJson flags.JsonFlag
|
||||
|
||||
var createSkipWait bool
|
||||
|
@ -79,16 +80,20 @@ func newCreate() *cobra.Command {
|
|||
|
||||
// TODO: complex arg: app
|
||||
|
||||
cmd.Use = "create"
|
||||
cmd.Use = "create NAME"
|
||||
cmd.Short = `Create an app.`
|
||||
cmd.Long = `Create an app.
|
||||
|
||||
Creates a new app.`
|
||||
Creates a new app.
|
||||
|
||||
Arguments:
|
||||
NAME: The name of the app. The name must contain only lowercase alphanumeric
|
||||
characters and hyphens. It must be unique within the workspace.`
|
||||
|
||||
cmd.Annotations = make(map[string]string)
|
||||
|
||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||
check := root.ExactArgs(0)
|
||||
check := root.ExactArgs(1)
|
||||
return check(cmd, args)
|
||||
}
|
||||
|
||||
|
@ -98,7 +103,7 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
diags := createJson.Unmarshal(&createReq.App)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
|
@ -109,6 +114,9 @@ func newCreate() *cobra.Command {
|
|||
}
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("json") {
|
||||
createReq.App.Name = args[0]
|
||||
}
|
||||
|
||||
wait, err := w.Apps.Create(ctx, createReq)
|
||||
if err != nil {
|
||||
|
@ -219,6 +227,7 @@ func newDeploy() *cobra.Command {
|
|||
cmd := &cobra.Command{}
|
||||
|
||||
var deployReq apps.CreateAppDeploymentRequest
|
||||
deployReq.AppDeployment = &apps.AppDeployment{}
|
||||
var deployJson flags.JsonFlag
|
||||
|
||||
var deploySkipWait bool
|
||||
|
@ -231,19 +240,16 @@ func newDeploy() *cobra.Command {
|
|||
|
||||
// TODO: complex arg: app_deployment
|
||||
|
||||
cmd.Use = "deploy APP_NAME"
|
||||
cmd.Use = "deploy"
|
||||
cmd.Short = `Create an app deployment.`
|
||||
cmd.Long = `Create an app deployment.
|
||||
|
||||
Creates an app deployment for the app with the supplied name.
|
||||
|
||||
Arguments:
|
||||
APP_NAME: The name of the app.`
|
||||
Creates an app deployment for the app with the supplied name.`
|
||||
|
||||
cmd.Annotations = make(map[string]string)
|
||||
|
||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||
check := root.ExactArgs(1)
|
||||
check := root.ExactArgs(0)
|
||||
return check(cmd, args)
|
||||
}
|
||||
|
||||
|
@ -253,7 +259,7 @@ func newDeploy() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := deployJson.Unmarshal(&deployReq)
|
||||
diags := deployJson.Unmarshal(&deployReq.AppDeployment)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
|
@ -264,7 +270,6 @@ func newDeploy() *cobra.Command {
|
|||
}
|
||||
}
|
||||
}
|
||||
deployReq.AppName = args[0]
|
||||
|
||||
wait, err := w.Apps.Deploy(ctx, deployReq)
|
||||
if err != nil {
|
||||
|
@ -903,6 +908,7 @@ func newUpdate() *cobra.Command {
|
|||
cmd := &cobra.Command{}
|
||||
|
||||
var updateReq apps.UpdateAppRequest
|
||||
updateReq.App = &apps.App{}
|
||||
var updateJson flags.JsonFlag
|
||||
|
||||
// TODO: short flags
|
||||
|
@ -917,7 +923,8 @@ func newUpdate() *cobra.Command {
|
|||
Updates the app with the supplied name.
|
||||
|
||||
Arguments:
|
||||
NAME: The name of the app.`
|
||||
NAME: The name of the app. The name must contain only lowercase alphanumeric
|
||||
characters and hyphens. It must be unique within the workspace.`
|
||||
|
||||
cmd.Annotations = make(map[string]string)
|
||||
|
||||
|
@ -932,7 +939,7 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
diags := updateJson.Unmarshal(&updateReq.App)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
|
@ -943,7 +950,9 @@ func newUpdate() *cobra.Command {
|
|||
}
|
||||
}
|
||||
}
|
||||
updateReq.Name = args[0]
|
||||
if !cmd.Flags().Changed("json") {
|
||||
updateReq.App.Name = args[0]
|
||||
}
|
||||
|
||||
response, err := w.Apps.Update(ctx, updateReq)
|
||||
if err != nil {
|
||||
|
|
|
@ -70,6 +70,7 @@ func newCreate() *cobra.Command {
|
|||
cmd := &cobra.Command{}
|
||||
|
||||
var createReq dashboards.CreateDashboardRequest
|
||||
createReq.Dashboard = &dashboards.Dashboard{}
|
||||
var createJson flags.JsonFlag
|
||||
|
||||
// TODO: short flags
|
||||
|
@ -96,7 +97,7 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
diags := createJson.Unmarshal(&createReq.Dashboard)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
|
@ -140,6 +141,7 @@ func newCreateSchedule() *cobra.Command {
|
|||
cmd := &cobra.Command{}
|
||||
|
||||
var createScheduleReq dashboards.CreateScheduleRequest
|
||||
createScheduleReq.Schedule = &dashboards.Schedule{}
|
||||
var createScheduleJson flags.JsonFlag
|
||||
|
||||
// TODO: short flags
|
||||
|
@ -147,30 +149,22 @@ func newCreateSchedule() *cobra.Command {
|
|||
|
||||
// TODO: complex arg: schedule
|
||||
|
||||
cmd.Use = "create-schedule DASHBOARD_ID"
|
||||
cmd.Use = "create-schedule"
|
||||
cmd.Short = `Create dashboard schedule.`
|
||||
cmd.Long = `Create dashboard schedule.
|
||||
|
||||
Arguments:
|
||||
DASHBOARD_ID: UUID identifying the dashboard to which the schedule belongs.`
|
||||
cmd.Long = `Create dashboard schedule.`
|
||||
|
||||
// This command is being previewed; hide from help output.
|
||||
cmd.Hidden = true
|
||||
|
||||
cmd.Annotations = make(map[string]string)
|
||||
|
||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||
check := root.ExactArgs(1)
|
||||
return check(cmd, args)
|
||||
}
|
||||
|
||||
cmd.PreRunE = root.MustWorkspaceClient
|
||||
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||
ctx := cmd.Context()
|
||||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createScheduleJson.Unmarshal(&createScheduleReq)
|
||||
diags := createScheduleJson.Unmarshal(&createScheduleReq.Schedule)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
|
@ -181,7 +175,6 @@ func newCreateSchedule() *cobra.Command {
|
|||
}
|
||||
}
|
||||
}
|
||||
createScheduleReq.DashboardId = args[0]
|
||||
|
||||
response, err := w.Lakeview.CreateSchedule(ctx, createScheduleReq)
|
||||
if err != nil {
|
||||
|
@ -215,6 +208,7 @@ func newCreateSubscription() *cobra.Command {
|
|||
cmd := &cobra.Command{}
|
||||
|
||||
var createSubscriptionReq dashboards.CreateSubscriptionRequest
|
||||
createSubscriptionReq.Subscription = &dashboards.Subscription{}
|
||||
var createSubscriptionJson flags.JsonFlag
|
||||
|
||||
// TODO: short flags
|
||||
|
@ -222,31 +216,22 @@ func newCreateSubscription() *cobra.Command {
|
|||
|
||||
// TODO: complex arg: subscription
|
||||
|
||||
cmd.Use = "create-subscription DASHBOARD_ID SCHEDULE_ID"
|
||||
cmd.Use = "create-subscription"
|
||||
cmd.Short = `Create schedule subscription.`
|
||||
cmd.Long = `Create schedule subscription.
|
||||
|
||||
Arguments:
|
||||
DASHBOARD_ID: UUID identifying the dashboard to which the subscription belongs.
|
||||
SCHEDULE_ID: UUID identifying the schedule to which the subscription belongs.`
|
||||
cmd.Long = `Create schedule subscription.`
|
||||
|
||||
// This command is being previewed; hide from help output.
|
||||
cmd.Hidden = true
|
||||
|
||||
cmd.Annotations = make(map[string]string)
|
||||
|
||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||
check := root.ExactArgs(2)
|
||||
return check(cmd, args)
|
||||
}
|
||||
|
||||
cmd.PreRunE = root.MustWorkspaceClient
|
||||
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||
ctx := cmd.Context()
|
||||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createSubscriptionJson.Unmarshal(&createSubscriptionReq)
|
||||
diags := createSubscriptionJson.Unmarshal(&createSubscriptionReq.Subscription)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
|
@ -257,8 +242,6 @@ func newCreateSubscription() *cobra.Command {
|
|||
}
|
||||
}
|
||||
}
|
||||
createSubscriptionReq.DashboardId = args[0]
|
||||
createSubscriptionReq.ScheduleId = args[1]
|
||||
|
||||
response, err := w.Lakeview.CreateSubscription(ctx, createSubscriptionReq)
|
||||
if err != nil {
|
||||
|
@ -1108,6 +1091,7 @@ func newUpdate() *cobra.Command {
|
|||
cmd := &cobra.Command{}
|
||||
|
||||
var updateReq dashboards.UpdateDashboardRequest
|
||||
updateReq.Dashboard = &dashboards.Dashboard{}
|
||||
var updateJson flags.JsonFlag
|
||||
|
||||
// TODO: short flags
|
||||
|
@ -1115,19 +1099,16 @@ func newUpdate() *cobra.Command {
|
|||
|
||||
// TODO: complex arg: dashboard
|
||||
|
||||
cmd.Use = "update DASHBOARD_ID"
|
||||
cmd.Use = "update"
|
||||
cmd.Short = `Update dashboard.`
|
||||
cmd.Long = `Update dashboard.
|
||||
|
||||
Update a draft dashboard.
|
||||
|
||||
Arguments:
|
||||
DASHBOARD_ID: UUID identifying the dashboard.`
|
||||
Update a draft dashboard.`
|
||||
|
||||
cmd.Annotations = make(map[string]string)
|
||||
|
||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||
check := root.ExactArgs(1)
|
||||
check := root.ExactArgs(0)
|
||||
return check(cmd, args)
|
||||
}
|
||||
|
||||
|
@ -1137,7 +1118,7 @@ func newUpdate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateJson.Unmarshal(&updateReq)
|
||||
diags := updateJson.Unmarshal(&updateReq.Dashboard)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
|
@ -1148,7 +1129,6 @@ func newUpdate() *cobra.Command {
|
|||
}
|
||||
}
|
||||
}
|
||||
updateReq.DashboardId = args[0]
|
||||
|
||||
response, err := w.Lakeview.Update(ctx, updateReq)
|
||||
if err != nil {
|
||||
|
@ -1182,6 +1162,7 @@ func newUpdateSchedule() *cobra.Command {
|
|||
cmd := &cobra.Command{}
|
||||
|
||||
var updateScheduleReq dashboards.UpdateScheduleRequest
|
||||
updateScheduleReq.Schedule = &dashboards.Schedule{}
|
||||
var updateScheduleJson flags.JsonFlag
|
||||
|
||||
// TODO: short flags
|
||||
|
@ -1189,31 +1170,22 @@ func newUpdateSchedule() *cobra.Command {
|
|||
|
||||
// TODO: complex arg: schedule
|
||||
|
||||
cmd.Use = "update-schedule DASHBOARD_ID SCHEDULE_ID"
|
||||
cmd.Use = "update-schedule"
|
||||
cmd.Short = `Update dashboard schedule.`
|
||||
cmd.Long = `Update dashboard schedule.
|
||||
|
||||
Arguments:
|
||||
DASHBOARD_ID: UUID identifying the dashboard to which the schedule belongs.
|
||||
SCHEDULE_ID: UUID identifying the schedule.`
|
||||
cmd.Long = `Update dashboard schedule.`
|
||||
|
||||
// This command is being previewed; hide from help output.
|
||||
cmd.Hidden = true
|
||||
|
||||
cmd.Annotations = make(map[string]string)
|
||||
|
||||
cmd.Args = func(cmd *cobra.Command, args []string) error {
|
||||
check := root.ExactArgs(2)
|
||||
return check(cmd, args)
|
||||
}
|
||||
|
||||
cmd.PreRunE = root.MustWorkspaceClient
|
||||
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
|
||||
ctx := cmd.Context()
|
||||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := updateScheduleJson.Unmarshal(&updateScheduleReq)
|
||||
diags := updateScheduleJson.Unmarshal(&updateScheduleReq.Schedule)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
|
@ -1224,8 +1196,6 @@ func newUpdateSchedule() *cobra.Command {
|
|||
}
|
||||
}
|
||||
}
|
||||
updateScheduleReq.DashboardId = args[0]
|
||||
updateScheduleReq.ScheduleId = args[1]
|
||||
|
||||
response, err := w.Lakeview.UpdateSchedule(ctx, updateScheduleReq)
|
||||
if err != nil {
|
||||
|
|
|
@ -55,6 +55,7 @@ func newCreate() *cobra.Command {
|
|||
cmd := &cobra.Command{}
|
||||
|
||||
var createReq catalog.CreateOnlineTableRequest
|
||||
createReq.Table = &catalog.OnlineTable{}
|
||||
var createJson flags.JsonFlag
|
||||
|
||||
var createSkipWait bool
|
||||
|
@ -86,7 +87,7 @@ func newCreate() *cobra.Command {
|
|||
w := root.WorkspaceClient(ctx)
|
||||
|
||||
if cmd.Flags().Changed("json") {
|
||||
diags := createJson.Unmarshal(&createReq)
|
||||
diags := createJson.Unmarshal(&createReq.Table)
|
||||
if diags.HasError() {
|
||||
return diags.Error()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue