flatten request body into params

This commit is contained in:
Andrew Nester 2024-11-08 14:12:35 +01:00
parent 3d96565d04
commit b452f53ccf
No known key found for this signature in database
GPG Key ID: 12BC628A44B7DA57
5 changed files with 123 additions and 27 deletions

View File

@ -130,21 +130,25 @@ func new{{.PascalName}}() *cobra.Command {
cmd.Flags().BoolVar(&{{.CamelName}}SkipWait, "no-wait", {{.CamelName}}SkipWait, `do not wait to reach {{range $i, $e := .Wait.Success}}{{if $i}} or {{end}}{{.Content}}{{end}} state`)
cmd.Flags().DurationVar(&{{.CamelName}}Timeout, "timeout", {{.Wait.Timeout}}*time.Minute, `maximum amount of time to reach {{range $i, $e := .Wait.Success}}{{if $i}} or {{end}}{{.Content}}{{end}} state`)
{{end -}}
{{if .Request}}// TODO: short flags
{{- $request := .Request -}}
{{- if .RequestBodyField -}}
{{- $request = .RequestBodyField.Entity -}}
{{- end -}}
{{if $request }}// TODO: short flags
{{- if .CanUseJson}}
cmd.Flags().Var(&{{.CamelName}}Json, "json", `either inline JSON string or @path/to/file.json with request body`)
{{- end}}
{{$method := .}}
{{ if not .IsJsonOnly }}
{{range .Request.Fields -}}
{{range $request.Fields -}}
{{- if not .Required -}}
{{if .Entity.IsObject }}// TODO: complex arg: {{.Name}}
{{else if .Entity.IsAny }}// TODO: any: {{.Name}}
{{else if .Entity.ArrayValue }}// TODO: array: {{.Name}}
{{else if .Entity.MapValue }}// TODO: map via StringToStringVar: {{.Name}}
{{else if .Entity.IsEmpty }}// TODO: output-only field
{{else if .Entity.Enum }}cmd.Flags().Var(&{{$method.CamelName}}Req.{{.PascalName}}, "{{.KebabName}}", `{{.Summary | without "`" | trimSuffix "."}}. Supported values: {{template "printArray" .Entity.Enum}}`)
{{else}}cmd.Flags().{{template "arg-type" .Entity}}(&{{$method.CamelName}}Req.{{.PascalName}}, "{{.KebabName}}", {{$method.CamelName}}Req.{{.PascalName}}, `{{.Summary | without "`"}}`)
{{else if .Entity.Enum }}cmd.Flags().Var(&{{- template "request-body-obj" (dict "Method" $method)}}.{{.PascalName}}, "{{.KebabName}}", `{{.Summary | without "`" | trimSuffix "."}}. Supported values: {{template "printArray" .Entity.Enum}}`)
{{else}}cmd.Flags().{{template "arg-type" .Entity}}(&{{- template "request-body-obj" (dict "Method" $method)}}.{{.PascalName}}, "{{.KebabName}}", {{- template "request-body-obj" (dict "Method" $method)}}.{{.PascalName}}, `{{.Summary | without "`"}}`)
{{end}}
{{- end -}}
{{- end}}
@ -164,14 +168,14 @@ func new{{.PascalName}}() *cobra.Command {
{{- $noPrompt := or .IsCrudCreate (in $excludeFromPrompts $fullCommandName) }}
{{- $hasPosArgs := .HasRequiredPositionalArguments -}}
{{- $hasSinglePosArg := and $hasPosArgs (eq 1 (len .Request.RequiredFields)) -}}
{{- $hasSinglePosArg := and $hasPosArgs (eq 1 (len $request.RequiredFields)) -}}
{{- $serviceHasNamedIdMap := and (and .Service.List .Service.List.NamedIdMap) (not (eq .PascalName "List")) -}}
{{- $hasIdPrompt := and (not $noPrompt) (and $hasSinglePosArg $serviceHasNamedIdMap) -}}
{{- $wait := and .Wait (and (not .IsCrudRead) (not (eq .SnakeName "get_run"))) -}}
{{- $hasRequiredArgs := and (not $hasIdPrompt) $hasPosArgs -}}
{{- $hasSingleRequiredRequestBodyFieldWithPrompt := and (and $hasIdPrompt .Request) (eq 1 (len .Request.RequiredRequestBodyFields)) -}}
{{- $onlyPathArgsRequiredAsPositionalArguments := and .Request (eq (len .RequiredPositionalArguments) (len .Request.RequiredPathFields)) -}}
{{- $hasDifferentArgsWithJsonFlag := and (not $onlyPathArgsRequiredAsPositionalArguments) (and .CanUseJson .Request.HasRequiredRequestBodyFields) -}}
{{- $hasSingleRequiredRequestBodyFieldWithPrompt := and (and $hasIdPrompt $request) (eq 1 (len $request.RequiredRequestBodyFields)) -}}
{{- $onlyPathArgsRequiredAsPositionalArguments := and $request (eq (len .RequiredPositionalArguments) (len $request.RequiredPathFields)) -}}
{{- $hasDifferentArgsWithJsonFlag := and (not $onlyPathArgsRequiredAsPositionalArguments) (and .CanUseJson (or $request.HasRequiredRequestBodyFields )) -}}
{{- $hasCustomArgHandler := or $hasRequiredArgs $hasDifferentArgsWithJsonFlag -}}
{{- $atleastOneArgumentWithDescription := false -}}
@ -209,12 +213,12 @@ func new{{.PascalName}}() *cobra.Command {
cmd.Args = func(cmd *cobra.Command, args []string) error {
{{- if $hasDifferentArgsWithJsonFlag }}
if cmd.Flags().Changed("json") {
err := root.ExactArgs({{len .Request.RequiredPathFields}})(cmd, args)
err := root.ExactArgs({{len $request.RequiredPathFields}})(cmd, args)
if err != nil {
{{- if eq 0 (len .Request.RequiredPathFields) }}
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide{{- range $index, $field := .Request.RequiredFields}}{{if $index}},{{end}} '{{$field.Name}}'{{end}} in your JSON input")
{{- if eq 0 (len $request.RequiredPathFields) }}
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide{{- range $index, $field := $request.RequiredFields}}{{if $index}},{{end}} '{{$field.Name}}'{{end}} in your JSON input")
{{- else }}
return fmt.Errorf("when --json flag is specified, provide only{{- range $index, $field := .Request.RequiredPathFields}}{{if $index}},{{end}} {{$field.ConstantName}}{{end}} as positional arguments. Provide{{- range $index, $field := .Request.RequiredRequestBodyFields}}{{if $index}},{{end}} '{{$field.Name}}'{{end}} in your JSON input")
return fmt.Errorf("when --json flag is specified, provide only{{- range $index, $field := $request.RequiredPathFields}}{{if $index}},{{end}} {{$field.ConstantName}}{{end}} as positional arguments. Provide{{- range $index, $field := $request.RequiredRequestBodyFields}}{{if $index}},{{end}} '{{$field.Name}}'{{end}} in your JSON input")
{{- end }}
}
return nil
@ -254,20 +258,20 @@ func new{{.PascalName}}() *cobra.Command {
{{- if $hasIdPrompt}}
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No{{range .Request.RequiredFields}} {{.ConstantName}}{{end}} argument specified. Loading names for {{.Service.TitleName}} drop-down."
promptSpinner <- "No{{range $request.RequiredFields}} {{.ConstantName}}{{end}} argument specified. Loading names for {{.Service.TitleName}} drop-down."
names, err := {{if .Service.IsAccounts}}a{{else}}w{{end}}.{{(.Service.TrimPrefix "account").PascalName}}.{{.Service.List.NamedIdMap.PascalName}}(ctx{{if .Service.List.Request}}, {{.Service.Package.Name}}.{{.Service.List.Request.PascalName}}{}{{end}})
close(promptSpinner)
if err != nil {
return fmt.Errorf("failed to load names for {{.Service.TitleName}} drop-down. Please manually specify required arguments. Original error: %w", err)
}
id, err := cmdio.Select(ctx, names, "{{range .Request.RequiredFields}}{{.Summary | trimSuffix "."}}{{end}}")
id, err := cmdio.Select(ctx, names, "{{range $request.RequiredFields}}{{.Summary | trimSuffix "."}}{{end}}")
if err != nil {
return err
}
args = append(args, id)
}
if len(args) != 1 {
return fmt.Errorf("expected to have {{range .Request.RequiredFields}}{{.Summary | trimSuffix "." | lower}}{{end}}")
return fmt.Errorf("expected to have {{range $request.RequiredFields}}{{.Summary | trimSuffix "." | lower}}{{end}}")
}
{{- end -}}
@ -391,13 +395,18 @@ func new{{.PascalName}}() *cobra.Command {
if !cmd.Flags().Changed("json") {
{{- end }}
{{if not $field.Entity.IsString -}}
_, err = fmt.Sscan(args[{{$arg}}], &{{$method.CamelName}}Req.{{$field.PascalName}})
_, err = fmt.Sscan(args[{{$arg}}], &{{- template "request-body-obj" (dict "Method" $method)}}.{{$field.PascalName}})
if err != nil {
return fmt.Errorf("invalid {{$field.ConstantName}}: %s", args[{{$arg}}])
}{{else -}}
{{$method.CamelName}}Req.{{ if $method.RequestBodyField }}{{$method.RequestBodyField.PascalName}}.{{end}}{{$field.PascalName}} = args[{{$arg}}]
{{- template "request-body-obj" (dict "Method" $method)}}.{{$field.PascalName}} = args[{{$arg}}]
{{- end -}}
{{- if $optionalIfJsonIsUsed }}
}
{{- end }}
{{- end -}}
{{- define "request-body-obj" -}}
{{- $method := .Method -}}
{{$method.CamelName}}Req{{ if $method.RequestBodyField }}.{{$method.RequestBodyField.PascalName}}{{end}}
{{- end -}}

View File

@ -28,7 +28,7 @@ func TestTranslatePathsDashboards_FilePathRelativeSubDirectory(t *testing.T) {
Resources: config.Resources{
Dashboards: map[string]*resources.Dashboard{
"dashboard": {
CreateDashboardRequest: &dashboards.CreateDashboardRequest{
Dashboard: &dashboards.Dashboard{
DisplayName: "My Dashboard",
},
FilePath: "../src/my_dashboard.lvdash.json",

View File

@ -78,7 +78,20 @@ func newCreate() *cobra.Command {
// TODO: short flags
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: complex arg: app
// TODO: complex arg: active_deployment
// TODO: complex arg: app_status
// TODO: complex arg: compute_status
cmd.Flags().StringVar(&createReq.App.CreateTime, "create-time", createReq.App.CreateTime, `The creation time of the app.`)
cmd.Flags().StringVar(&createReq.App.Creator, "creator", createReq.App.Creator, `The email of the user that created the app.`)
cmd.Flags().StringVar(&createReq.App.DefaultSourceCodePath, "default-source-code-path", createReq.App.DefaultSourceCodePath, `The default workspace file system path of the source code from which app deployment are created.`)
cmd.Flags().StringVar(&createReq.App.Description, "description", createReq.App.Description, `The description of the app.`)
// TODO: complex arg: pending_deployment
// TODO: array: resources
cmd.Flags().Int64Var(&createReq.App.ServicePrincipalId, "service-principal-id", createReq.App.ServicePrincipalId, ``)
cmd.Flags().StringVar(&createReq.App.ServicePrincipalName, "service-principal-name", createReq.App.ServicePrincipalName, ``)
cmd.Flags().StringVar(&createReq.App.UpdateTime, "update-time", createReq.App.UpdateTime, `The update time of the app.`)
cmd.Flags().StringVar(&createReq.App.Updater, "updater", createReq.App.Updater, `The email of the user that last updated the app.`)
cmd.Flags().StringVar(&createReq.App.Url, "url", createReq.App.Url, `The URL of the app once it is deployed.`)
cmd.Use = "create NAME"
cmd.Short = `Create an app.`
@ -93,6 +106,13 @@ func newCreate() *cobra.Command {
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("json") {
err := root.ExactArgs(0)(cmd, args)
if err != nil {
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'name' in your JSON input")
}
return nil
}
check := root.ExactArgs(1)
return check(cmd, args)
}
@ -238,7 +258,14 @@ func newDeploy() *cobra.Command {
// TODO: short flags
cmd.Flags().Var(&deployJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: complex arg: app_deployment
cmd.Flags().StringVar(&deployReq.AppDeployment.CreateTime, "create-time", deployReq.AppDeployment.CreateTime, `The creation time of the deployment.`)
cmd.Flags().StringVar(&deployReq.AppDeployment.Creator, "creator", deployReq.AppDeployment.Creator, `The email of the user creates the deployment.`)
// TODO: complex arg: deployment_artifacts
cmd.Flags().StringVar(&deployReq.AppDeployment.DeploymentId, "deployment-id", deployReq.AppDeployment.DeploymentId, `The unique id of the deployment.`)
cmd.Flags().Var(&deployReq.AppDeployment.Mode, "mode", `The mode of which the deployment will manage the source code. Supported values: [AUTO_SYNC, SNAPSHOT]`)
cmd.Flags().StringVar(&deployReq.AppDeployment.SourceCodePath, "source-code-path", deployReq.AppDeployment.SourceCodePath, `The workspace file system path of the source code used to create the app deployment.`)
// TODO: complex arg: status
cmd.Flags().StringVar(&deployReq.AppDeployment.UpdateTime, "update-time", deployReq.AppDeployment.UpdateTime, `The update time of the deployment.`)
cmd.Use = "deploy"
cmd.Short = `Create an app deployment.`
@ -914,7 +941,20 @@ func newUpdate() *cobra.Command {
// TODO: short flags
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: complex arg: app
// TODO: complex arg: active_deployment
// TODO: complex arg: app_status
// TODO: complex arg: compute_status
cmd.Flags().StringVar(&updateReq.App.CreateTime, "create-time", updateReq.App.CreateTime, `The creation time of the app.`)
cmd.Flags().StringVar(&updateReq.App.Creator, "creator", updateReq.App.Creator, `The email of the user that created the app.`)
cmd.Flags().StringVar(&updateReq.App.DefaultSourceCodePath, "default-source-code-path", updateReq.App.DefaultSourceCodePath, `The default workspace file system path of the source code from which app deployment are created.`)
cmd.Flags().StringVar(&updateReq.App.Description, "description", updateReq.App.Description, `The description of the app.`)
// TODO: complex arg: pending_deployment
// TODO: array: resources
cmd.Flags().Int64Var(&updateReq.App.ServicePrincipalId, "service-principal-id", updateReq.App.ServicePrincipalId, ``)
cmd.Flags().StringVar(&updateReq.App.ServicePrincipalName, "service-principal-name", updateReq.App.ServicePrincipalName, ``)
cmd.Flags().StringVar(&updateReq.App.UpdateTime, "update-time", updateReq.App.UpdateTime, `The update time of the app.`)
cmd.Flags().StringVar(&updateReq.App.Updater, "updater", updateReq.App.Updater, `The email of the user that last updated the app.`)
cmd.Flags().StringVar(&updateReq.App.Url, "url", updateReq.App.Url, `The URL of the app once it is deployed.`)
cmd.Use = "update NAME"
cmd.Short = `Update an app.`
@ -929,6 +969,13 @@ func newUpdate() *cobra.Command {
cmd.Annotations = make(map[string]string)
cmd.Args = func(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed("json") {
err := root.ExactArgs(0)(cmd, args)
if err != nil {
return fmt.Errorf("when --json flag is specified, no positional arguments are required. Provide 'name' in your JSON input")
}
return nil
}
check := root.ExactArgs(1)
return check(cmd, args)
}

View File

@ -76,7 +76,16 @@ func newCreate() *cobra.Command {
// TODO: short flags
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: complex arg: dashboard
cmd.Flags().StringVar(&createReq.Dashboard.CreateTime, "create-time", createReq.Dashboard.CreateTime, `The timestamp of when the dashboard was created.`)
cmd.Flags().StringVar(&createReq.Dashboard.DashboardId, "dashboard-id", createReq.Dashboard.DashboardId, `UUID identifying the dashboard.`)
cmd.Flags().StringVar(&createReq.Dashboard.DisplayName, "display-name", createReq.Dashboard.DisplayName, `The display name of the dashboard.`)
cmd.Flags().StringVar(&createReq.Dashboard.Etag, "etag", createReq.Dashboard.Etag, `The etag for the dashboard.`)
cmd.Flags().Var(&createReq.Dashboard.LifecycleState, "lifecycle-state", `The state of the dashboard resource. Supported values: [ACTIVE, TRASHED]`)
cmd.Flags().StringVar(&createReq.Dashboard.ParentPath, "parent-path", createReq.Dashboard.ParentPath, `The workspace path of the folder containing the dashboard.`)
cmd.Flags().StringVar(&createReq.Dashboard.Path, "path", createReq.Dashboard.Path, `The workspace path of the dashboard asset, including the file name.`)
cmd.Flags().StringVar(&createReq.Dashboard.SerializedDashboard, "serialized-dashboard", createReq.Dashboard.SerializedDashboard, `The contents of the dashboard in serialized string form.`)
cmd.Flags().StringVar(&createReq.Dashboard.UpdateTime, "update-time", createReq.Dashboard.UpdateTime, `The timestamp of when the dashboard was last updated by the user.`)
cmd.Flags().StringVar(&createReq.Dashboard.WarehouseId, "warehouse-id", createReq.Dashboard.WarehouseId, `The warehouse ID used to run the dashboard.`)
cmd.Use = "create"
cmd.Short = `Create dashboard.`
@ -147,7 +156,13 @@ func newCreateSchedule() *cobra.Command {
// TODO: short flags
cmd.Flags().Var(&createScheduleJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: complex arg: schedule
cmd.Flags().StringVar(&createScheduleReq.Schedule.CreateTime, "create-time", createScheduleReq.Schedule.CreateTime, `A timestamp indicating when the schedule was created.`)
cmd.Flags().StringVar(&createScheduleReq.Schedule.DashboardId, "dashboard-id", createScheduleReq.Schedule.DashboardId, `UUID identifying the dashboard to which the schedule belongs.`)
cmd.Flags().StringVar(&createScheduleReq.Schedule.DisplayName, "display-name", createScheduleReq.Schedule.DisplayName, `The display name for schedule.`)
cmd.Flags().StringVar(&createScheduleReq.Schedule.Etag, "etag", createScheduleReq.Schedule.Etag, `The etag for the schedule.`)
cmd.Flags().Var(&createScheduleReq.Schedule.PauseStatus, "pause-status", `The status indicates whether this schedule is paused or not. Supported values: [PAUSED, UNPAUSED]`)
cmd.Flags().StringVar(&createScheduleReq.Schedule.ScheduleId, "schedule-id", createScheduleReq.Schedule.ScheduleId, `UUID identifying the schedule.`)
cmd.Flags().StringVar(&createScheduleReq.Schedule.UpdateTime, "update-time", createScheduleReq.Schedule.UpdateTime, `A timestamp indicating when the schedule was last updated.`)
cmd.Use = "create-schedule"
cmd.Short = `Create dashboard schedule.`
@ -214,7 +229,13 @@ func newCreateSubscription() *cobra.Command {
// TODO: short flags
cmd.Flags().Var(&createSubscriptionJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: complex arg: subscription
cmd.Flags().StringVar(&createSubscriptionReq.Subscription.CreateTime, "create-time", createSubscriptionReq.Subscription.CreateTime, `A timestamp indicating when the subscription was created.`)
cmd.Flags().Int64Var(&createSubscriptionReq.Subscription.CreatedByUserId, "created-by-user-id", createSubscriptionReq.Subscription.CreatedByUserId, `UserId of the user who adds subscribers (users or notification destinations) to the dashboard's schedule.`)
cmd.Flags().StringVar(&createSubscriptionReq.Subscription.DashboardId, "dashboard-id", createSubscriptionReq.Subscription.DashboardId, `UUID identifying the dashboard to which the subscription belongs.`)
cmd.Flags().StringVar(&createSubscriptionReq.Subscription.Etag, "etag", createSubscriptionReq.Subscription.Etag, `The etag for the subscription.`)
cmd.Flags().StringVar(&createSubscriptionReq.Subscription.ScheduleId, "schedule-id", createSubscriptionReq.Subscription.ScheduleId, `UUID identifying the schedule to which the subscription belongs.`)
cmd.Flags().StringVar(&createSubscriptionReq.Subscription.SubscriptionId, "subscription-id", createSubscriptionReq.Subscription.SubscriptionId, `UUID identifying the subscription.`)
cmd.Flags().StringVar(&createSubscriptionReq.Subscription.UpdateTime, "update-time", createSubscriptionReq.Subscription.UpdateTime, `A timestamp indicating when the subscription was last updated.`)
cmd.Use = "create-subscription"
cmd.Short = `Create schedule subscription.`
@ -1097,7 +1118,16 @@ func newUpdate() *cobra.Command {
// TODO: short flags
cmd.Flags().Var(&updateJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: complex arg: dashboard
cmd.Flags().StringVar(&updateReq.Dashboard.CreateTime, "create-time", updateReq.Dashboard.CreateTime, `The timestamp of when the dashboard was created.`)
cmd.Flags().StringVar(&updateReq.Dashboard.DashboardId, "dashboard-id", updateReq.Dashboard.DashboardId, `UUID identifying the dashboard.`)
cmd.Flags().StringVar(&updateReq.Dashboard.DisplayName, "display-name", updateReq.Dashboard.DisplayName, `The display name of the dashboard.`)
cmd.Flags().StringVar(&updateReq.Dashboard.Etag, "etag", updateReq.Dashboard.Etag, `The etag for the dashboard.`)
cmd.Flags().Var(&updateReq.Dashboard.LifecycleState, "lifecycle-state", `The state of the dashboard resource. Supported values: [ACTIVE, TRASHED]`)
cmd.Flags().StringVar(&updateReq.Dashboard.ParentPath, "parent-path", updateReq.Dashboard.ParentPath, `The workspace path of the folder containing the dashboard.`)
cmd.Flags().StringVar(&updateReq.Dashboard.Path, "path", updateReq.Dashboard.Path, `The workspace path of the dashboard asset, including the file name.`)
cmd.Flags().StringVar(&updateReq.Dashboard.SerializedDashboard, "serialized-dashboard", updateReq.Dashboard.SerializedDashboard, `The contents of the dashboard in serialized string form.`)
cmd.Flags().StringVar(&updateReq.Dashboard.UpdateTime, "update-time", updateReq.Dashboard.UpdateTime, `The timestamp of when the dashboard was last updated by the user.`)
cmd.Flags().StringVar(&updateReq.Dashboard.WarehouseId, "warehouse-id", updateReq.Dashboard.WarehouseId, `The warehouse ID used to run the dashboard.`)
cmd.Use = "update"
cmd.Short = `Update dashboard.`
@ -1168,7 +1198,13 @@ func newUpdateSchedule() *cobra.Command {
// TODO: short flags
cmd.Flags().Var(&updateScheduleJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: complex arg: schedule
cmd.Flags().StringVar(&updateScheduleReq.Schedule.CreateTime, "create-time", updateScheduleReq.Schedule.CreateTime, `A timestamp indicating when the schedule was created.`)
cmd.Flags().StringVar(&updateScheduleReq.Schedule.DashboardId, "dashboard-id", updateScheduleReq.Schedule.DashboardId, `UUID identifying the dashboard to which the schedule belongs.`)
cmd.Flags().StringVar(&updateScheduleReq.Schedule.DisplayName, "display-name", updateScheduleReq.Schedule.DisplayName, `The display name for schedule.`)
cmd.Flags().StringVar(&updateScheduleReq.Schedule.Etag, "etag", updateScheduleReq.Schedule.Etag, `The etag for the schedule.`)
cmd.Flags().Var(&updateScheduleReq.Schedule.PauseStatus, "pause-status", `The status indicates whether this schedule is paused or not. Supported values: [PAUSED, UNPAUSED]`)
cmd.Flags().StringVar(&updateScheduleReq.Schedule.ScheduleId, "schedule-id", updateScheduleReq.Schedule.ScheduleId, `UUID identifying the schedule.`)
cmd.Flags().StringVar(&updateScheduleReq.Schedule.UpdateTime, "update-time", updateScheduleReq.Schedule.UpdateTime, `A timestamp indicating when the schedule was last updated.`)
cmd.Use = "update-schedule"
cmd.Short = `Update dashboard schedule.`

View File

@ -66,7 +66,11 @@ func newCreate() *cobra.Command {
// TODO: short flags
cmd.Flags().Var(&createJson, "json", `either inline JSON string or @path/to/file.json with request body`)
// TODO: complex arg: table
cmd.Flags().StringVar(&createReq.Table.Name, "name", createReq.Table.Name, `Full three-part (catalog, schema, table) name of the table.`)
// TODO: complex arg: spec
// TODO: complex arg: status
cmd.Flags().StringVar(&createReq.Table.TableServingUrl, "table-serving-url", createReq.Table.TableServingUrl, `Data serving REST API URL for this table.`)
cmd.Flags().Var(&createReq.Table.UnityCatalogProvisioningState, "unity-catalog-provisioning-state", `The provisioning state of the online table entity in Unity Catalog. Supported values: [ACTIVE, DELETING, FAILED, PROVISIONING, UPDATING]`)
cmd.Use = "create"
cmd.Short = `Create an Online Table.`