Added JSON input validation for CLI commands (#1771)

## Changes
Added JSON input validation for CLI commands. Now when invalid JSON
passed as a payload to CLI commands, CLI performs input normalisation
and detects if there are any mismatches such as incorrect types, unknown
fields and etc.

This diagnostic information is printed in standard error output and does
not block command execution, so the change is backward compatible.

Fixes #1769 #1764 #1625 #1560


## Tests
Added unit tests

```
andrew.nester@HFW9Y94129 ~ % databricks jobs create --json '{"seeti}'
Error: error decoding JSON at (inline):1:2: unexpected EOF


andrew.nester@HFW9Y94129 ~ % databricks jobs create --json '{"seeti": true}'
Warning: unknown field: seeti
  in (inline):1:9

Error: Job settings must be specified.
```

---------

Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
This commit is contained in:
Andrew Nester 2024-10-11 16:39:53 +02:00 committed by GitHub
parent 08a0d083c3
commit f0e2981596
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
118 changed files with 3378 additions and 1042 deletions

View File

@ -5,6 +5,7 @@ package {{(.TrimPrefix "account").SnakeName}}
import ( import (
"github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/flags"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/cmd/root" "github.com/databricks/cli/cmd/root"
"github.com/databricks/databricks-sdk-go/service/{{.Package.Name}}" "github.com/databricks/databricks-sdk-go/service/{{.Package.Name}}"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -231,10 +232,16 @@ func new{{.PascalName}}() *cobra.Command {
{{- if .Request }} {{- if .Request }}
{{ if .CanUseJson }} {{ if .CanUseJson }}
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req) diags := {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
}{{end}}{{ if .MustUseJson }}else { }{{end}}{{ if .MustUseJson }}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}}

View File

@ -8,6 +8,7 @@ import (
"text/template" "text/template"
"github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/diag" "github.com/databricks/cli/libs/diag"
"github.com/databricks/databricks-sdk-go/service/iam" "github.com/databricks/databricks-sdk-go/service/iam"
"github.com/fatih/color" "github.com/fatih/color"
@ -28,48 +29,6 @@ var renderFuncMap = template.FuncMap{
}, },
} }
const errorTemplate = `{{ "Error" | red }}: {{ .Summary }}
{{- range $index, $element := .Paths }}
{{ if eq $index 0 }}at {{else}} {{ end}}{{ $element.String | green }}
{{- end }}
{{- range $index, $element := .Locations }}
{{ if eq $index 0 }}in {{else}} {{ end}}{{ $element.String | cyan }}
{{- end }}
{{- if .Detail }}
{{ .Detail }}
{{- end }}
`
const warningTemplate = `{{ "Warning" | yellow }}: {{ .Summary }}
{{- range $index, $element := .Paths }}
{{ if eq $index 0 }}at {{else}} {{ end}}{{ $element.String | green }}
{{- end }}
{{- range $index, $element := .Locations }}
{{ if eq $index 0 }}in {{else}} {{ end}}{{ $element.String | cyan }}
{{- end }}
{{- if .Detail }}
{{ .Detail }}
{{- end }}
`
const recommendationTemplate = `{{ "Recommendation" | blue }}: {{ .Summary }}
{{- range $index, $element := .Paths }}
{{ if eq $index 0 }}at {{else}} {{ end}}{{ $element.String | green }}
{{- end }}
{{- range $index, $element := .Locations }}
{{ if eq $index 0 }}in {{else}} {{ end}}{{ $element.String | cyan }}
{{- end }}
{{- if .Detail }}
{{ .Detail }}
{{- end }}
`
const summaryTemplate = `{{- if .Name -}} const summaryTemplate = `{{- if .Name -}}
Name: {{ .Name | bold }} Name: {{ .Name | bold }}
{{- if .Target }} {{- if .Target }}
@ -153,22 +112,7 @@ func renderSummaryTemplate(out io.Writer, b *bundle.Bundle, diags diag.Diagnosti
} }
func renderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics) error { func renderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics) error {
errorT := template.Must(template.New("error").Funcs(renderFuncMap).Parse(errorTemplate))
warningT := template.Must(template.New("warning").Funcs(renderFuncMap).Parse(warningTemplate))
recommendationT := template.Must(template.New("recommendation").Funcs(renderFuncMap).Parse(recommendationTemplate))
// Print errors and warnings.
for _, d := range diags { for _, d := range diags {
var t *template.Template
switch d.Severity {
case diag.Error:
t = errorT
case diag.Warning:
t = warningT
case diag.Recommendation:
t = recommendationT
}
for i := range d.Locations { for i := range d.Locations {
if b == nil { if b == nil {
break break
@ -183,15 +127,9 @@ func renderDiagnostics(out io.Writer, b *bundle.Bundle, diags diag.Diagnostics)
} }
} }
} }
// Render the diagnostic with the appropriate template.
err := t.Execute(out, d)
if err != nil {
return fmt.Errorf("failed to render template: %w", err)
}
} }
return nil return cmdio.RenderDiagnostics(out, diags)
} }
// RenderOptions contains options for rendering diagnostics. // RenderOptions contains options for rendering diagnostics.

View File

@ -205,10 +205,16 @@ func newUpdateRuleSet() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateRuleSetJson.Unmarshal(&updateRuleSetReq) diags := updateRuleSetJson.Unmarshal(&updateRuleSetReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -78,10 +78,16 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -316,10 +322,16 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -90,10 +90,16 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -129,10 +129,16 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -88,11 +88,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := a.CustomAppIntegration.Create(ctx, createReq) response, err := a.CustomAppIntegration.Create(ctx, createReq)
if err != nil { if err != nil {
@ -320,11 +326,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.IntegrationId = args[0] updateReq.IntegrationId = args[0]
err = a.CustomAppIntegration.Update(ctx, updateReq) err = a.CustomAppIntegration.Update(ctx, updateReq)

View File

@ -185,10 +185,16 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -107,10 +107,16 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -127,10 +127,16 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -97,11 +97,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := a.Groups.Create(ctx, createReq) response, err := a.Groups.Create(ctx, createReq)
if err != nil { if err != nil {
@ -358,11 +364,17 @@ func newPatch() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down." promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."
@ -446,11 +458,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down." promptSpinner <- "No ID argument specified. Loading names for Account Groups drop-down."

View File

@ -132,11 +132,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Label = args[0] createReq.Label = args[0]
} }
@ -411,11 +417,17 @@ func newReplace() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = replaceJson.Unmarshal(&replaceReq) diags := replaceJson.Unmarshal(&replaceReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
replaceReq.IpAccessListId = args[0] replaceReq.IpAccessListId = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
replaceReq.Label = args[1] replaceReq.Label = args[1]
@ -505,11 +517,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No IP_ACCESS_LIST_ID argument specified. Loading names for Account Ip Access Lists drop-down." promptSpinner <- "No IP_ACCESS_LIST_ID argument specified. Loading names for Account Ip Access Lists drop-down."

View File

@ -162,11 +162,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := a.LogDelivery.Create(ctx, createReq) response, err := a.LogDelivery.Create(ctx, createReq)
if err != nil { if err != nil {
@ -369,11 +375,17 @@ func newPatchStatus() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchStatusJson.Unmarshal(&patchStatusReq) diags := patchStatusJson.Unmarshal(&patchStatusReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
patchStatusReq.LogDeliveryConfigurationId = args[0] patchStatusReq.LogDeliveryConfigurationId = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[1], &patchStatusReq.Status) _, err = fmt.Sscan(args[1], &patchStatusReq.Status)

View File

@ -85,11 +85,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
_, err = fmt.Sscan(args[0], &createReq.WorkspaceId) _, err = fmt.Sscan(args[0], &createReq.WorkspaceId)
if err != nil { if err != nil {
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
@ -343,11 +349,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId) _, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)
if err != nil { if err != nil {
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])

View File

@ -80,11 +80,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := a.Metastores.Create(ctx, createReq) response, err := a.Metastores.Create(ctx, createReq)
if err != nil { if err != nil {
@ -304,11 +310,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.MetastoreId = args[0] updateReq.MetastoreId = args[0]
response, err := a.Metastores.Update(ctx, updateReq) response, err := a.Metastores.Update(ctx, updateReq)

View File

@ -96,11 +96,17 @@ func newCreateNetworkConnectivityConfiguration() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq) diags := createNetworkConnectivityConfigurationJson.Unmarshal(&createNetworkConnectivityConfigurationReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createNetworkConnectivityConfigurationReq.Name = args[0] createNetworkConnectivityConfigurationReq.Name = args[0]
} }
@ -187,11 +193,17 @@ func newCreatePrivateEndpointRule() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq) diags := createPrivateEndpointRuleJson.Unmarshal(&createPrivateEndpointRuleReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
createPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0] createPrivateEndpointRuleReq.NetworkConnectivityConfigId = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createPrivateEndpointRuleReq.ResourceId = args[1] createPrivateEndpointRuleReq.ResourceId = args[1]

View File

@ -97,11 +97,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.NetworkName = args[0] createReq.NetworkName = args[0]
} }

View File

@ -189,10 +189,16 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -109,11 +109,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.PrivateAccessSettingsName = args[0] createReq.PrivateAccessSettingsName = args[0]
} }
@ -411,11 +417,17 @@ func newReplace() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = replaceJson.Unmarshal(&replaceReq) diags := replaceJson.Unmarshal(&replaceReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
replaceReq.PrivateAccessSettingsId = args[0] replaceReq.PrivateAccessSettingsId = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
replaceReq.PrivateAccessSettingsName = args[1] replaceReq.PrivateAccessSettingsName = args[1]

View File

@ -85,11 +85,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := a.PublishedAppIntegration.Create(ctx, createReq) response, err := a.PublishedAppIntegration.Create(ctx, createReq)
if err != nil { if err != nil {
@ -315,11 +321,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.IntegrationId = args[0] updateReq.IntegrationId = args[0]
err = a.PublishedAppIntegration.Update(ctx, updateReq) err = a.PublishedAppIntegration.Update(ctx, updateReq)

View File

@ -95,11 +95,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := a.ServicePrincipals.Create(ctx, createReq) response, err := a.ServicePrincipals.Create(ctx, createReq)
if err != nil { if err != nil {
@ -358,11 +364,17 @@ func newPatch() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down." promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."
@ -448,11 +460,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down." promptSpinner <- "No ID argument specified. Loading names for Account Service Principals drop-down."

View File

@ -88,11 +88,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
createReq.MetastoreId = args[0] createReq.MetastoreId = args[0]
response, err := a.StorageCredentials.Create(ctx, createReq) response, err := a.StorageCredentials.Create(ctx, createReq)
@ -340,11 +346,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.MetastoreId = args[0] updateReq.MetastoreId = args[0]
updateReq.StorageCredentialName = args[1] updateReq.StorageCredentialName = args[1]

View File

@ -87,10 +87,16 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -80,11 +80,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := a.UsageDashboards.Create(ctx, createReq) response, err := a.UsageDashboards.Create(ctx, createReq)
if err != nil { if err != nil {

View File

@ -103,11 +103,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := a.Users.Create(ctx, createReq) response, err := a.Users.Create(ctx, createReq)
if err != nil { if err != nil {
@ -374,11 +380,17 @@ func newPatch() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down." promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."
@ -465,11 +477,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down." promptSpinner <- "No ID argument specified. Loading names for Account Users drop-down."

View File

@ -104,11 +104,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.VpcEndpointName = args[0] createReq.VpcEndpointName = args[0]
} }

View File

@ -273,11 +273,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
_, err = fmt.Sscan(args[0], &updateReq.WorkspaceId) _, err = fmt.Sscan(args[0], &updateReq.WorkspaceId)
if err != nil { if err != nil {
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])

View File

@ -133,11 +133,17 @@ func newCreate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.WorkspaceName = args[0] createReq.WorkspaceName = args[0]
} }
@ -551,11 +557,17 @@ func newUpdate() *cobra.Command {
a := root.AccountClient(ctx) a := root.AccountClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Workspaces drop-down." promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Workspaces drop-down."

View File

@ -42,9 +42,9 @@ func makeCommand(method string) *cobra.Command {
var path = args[0] var path = args[0]
var request any var request any
err := payload.Unmarshal(&request) diags := payload.Unmarshal(&request)
if err != nil { if diags.HasError() {
return err return diags.Error()
} }
cfg := &config.Config{} cfg := &config.Config{}

View File

@ -93,10 +93,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -357,10 +363,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -85,11 +85,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.Alerts.Create(ctx, createReq) response, err := w.Alerts.Create(ctx, createReq)
if err != nil { if err != nil {
@ -354,11 +360,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.Id = args[0] updateReq.Id = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateReq.UpdateMask = args[1] updateReq.UpdateMask = args[1]

View File

@ -113,11 +113,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Name = args[0] createReq.Name = args[0]
} }
@ -267,11 +273,17 @@ func newDeploy() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deployJson.Unmarshal(&deployReq) diags := deployJson.Unmarshal(&deployReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
deployReq.AppName = args[0] deployReq.AppName = args[0]
wait, err := w.Apps.Deploy(ctx, deployReq) wait, err := w.Apps.Deploy(ctx, deployReq)
@ -702,11 +714,17 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
setPermissionsReq.AppName = args[0] setPermissionsReq.AppName = args[0]
response, err := w.Apps.SetPermissions(ctx, setPermissionsReq) response, err := w.Apps.SetPermissions(ctx, setPermissionsReq)
@ -936,11 +954,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.Name = args[0] updateReq.Name = args[0]
response, err := w.Apps.Update(ctx, updateReq) response, err := w.Apps.Update(ctx, updateReq)
@ -1005,11 +1029,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updatePermissionsReq.AppName = args[0] updatePermissionsReq.AppName = args[0]
response, err := w.Apps.UpdatePermissions(ctx, updatePermissionsReq) response, err := w.Apps.UpdatePermissions(ctx, updatePermissionsReq)

View File

@ -145,10 +145,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -127,10 +127,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -105,11 +105,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Name = args[0] createReq.Name = args[0]
} }
@ -363,11 +369,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.Name = args[0] updateReq.Name = args[0]
response, err := w.Catalogs.Update(ctx, updateReq) response, err := w.Catalogs.Update(ctx, updateReq)

View File

@ -85,10 +85,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -344,11 +350,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.Name = args[0] updateReq.Name = args[0]
response, err := w.CleanRooms.Update(ctx, updateReq) response, err := w.CleanRooms.Update(ctx, updateReq)

View File

@ -113,11 +113,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.ClusterPolicies.Create(ctx, createReq) response, err := w.ClusterPolicies.Create(ctx, createReq)
if err != nil { if err != nil {
@ -185,10 +191,16 @@ func newDelete() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteJson.Unmarshal(&deleteReq) diags := deleteJson.Unmarshal(&deleteReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -284,10 +296,16 @@ func newEdit() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = editJson.Unmarshal(&editReq) diags := editJson.Unmarshal(&editReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -630,11 +648,17 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down." promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."
@ -711,11 +735,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down." promptSpinner <- "No CLUSTER_POLICY_ID argument specified. Loading names for Cluster Policies drop-down."

View File

@ -134,11 +134,17 @@ func newChangeOwner() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = changeOwnerJson.Unmarshal(&changeOwnerReq) diags := changeOwnerJson.Unmarshal(&changeOwnerReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
changeOwnerReq.ClusterId = args[0] changeOwnerReq.ClusterId = args[0]
} }
@ -268,11 +274,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.SparkVersion = args[0] createReq.SparkVersion = args[0]
} }
@ -362,10 +374,16 @@ func newDelete() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteJson.Unmarshal(&deleteReq) diags := deleteJson.Unmarshal(&deleteReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -519,11 +537,17 @@ func newEdit() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = editJson.Unmarshal(&editReq) diags := editJson.Unmarshal(&editReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
editReq.ClusterId = args[0] editReq.ClusterId = args[0]
} }
@ -617,10 +641,16 @@ func newEvents() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = eventsJson.Unmarshal(&eventsReq) diags := eventsJson.Unmarshal(&eventsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1069,10 +1099,16 @@ func newPermanentDelete() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = permanentDeleteJson.Unmarshal(&permanentDeleteReq) diags := permanentDeleteJson.Unmarshal(&permanentDeleteReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1161,10 +1197,16 @@ func newPin() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = pinJson.Unmarshal(&pinReq) diags := pinJson.Unmarshal(&pinReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1260,10 +1302,16 @@ func newResize() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = resizeJson.Unmarshal(&resizeReq) diags := resizeJson.Unmarshal(&resizeReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1370,10 +1418,16 @@ func newRestart() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = restartJson.Unmarshal(&restartReq) diags := restartJson.Unmarshal(&restartReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1464,11 +1518,17 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down." promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."
@ -1608,10 +1668,16 @@ func newStart() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = startJson.Unmarshal(&startReq) diags := startJson.Unmarshal(&startReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1712,10 +1778,16 @@ func newUnpin() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = unpinJson.Unmarshal(&unpinReq) diags := unpinJson.Unmarshal(&unpinReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1824,11 +1896,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateReq.ClusterId = args[0] updateReq.ClusterId = args[0]
} }
@ -1905,11 +1983,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down." promptSpinner <- "No CLUSTER_ID argument specified. Loading names for Clusters drop-down."

View File

@ -130,10 +130,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -92,10 +92,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -355,10 +361,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -86,11 +86,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
createReq.ListingId = args[0] createReq.ListingId = args[0]
response, err := w.ConsumerInstallations.Create(ctx, createReq) response, err := w.ConsumerInstallations.Create(ctx, createReq)
@ -319,10 +325,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -85,10 +85,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -75,10 +75,16 @@ func newExchangeToken() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = exchangeTokenJson.Unmarshal(&exchangeTokenReq) diags := exchangeTokenJson.Unmarshal(&exchangeTokenReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -75,10 +75,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -196,10 +202,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -78,10 +78,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -405,11 +411,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No DASHBOARD_ID argument specified. Loading names for Dashboards drop-down." promptSpinner <- "No DASHBOARD_ID argument specified. Loading names for Dashboards drop-down."

View File

@ -199,10 +199,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -187,10 +187,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -132,10 +132,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -130,11 +130,17 @@ func newCreateExperiment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createExperimentJson.Unmarshal(&createExperimentReq) diags := createExperimentJson.Unmarshal(&createExperimentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createExperimentReq.Name = args[0] createExperimentReq.Name = args[0]
} }
@ -203,11 +209,17 @@ func newCreateRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createRunJson.Unmarshal(&createRunReq) diags := createRunJson.Unmarshal(&createRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.Experiments.CreateRun(ctx, createRunReq) response, err := w.Experiments.CreateRun(ctx, createRunReq)
if err != nil { if err != nil {
@ -277,11 +289,17 @@ func newDeleteExperiment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteExperimentJson.Unmarshal(&deleteExperimentReq) diags := deleteExperimentJson.Unmarshal(&deleteExperimentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
deleteExperimentReq.ExperimentId = args[0] deleteExperimentReq.ExperimentId = args[0]
} }
@ -352,11 +370,17 @@ func newDeleteRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteRunJson.Unmarshal(&deleteRunReq) diags := deleteRunJson.Unmarshal(&deleteRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
deleteRunReq.RunId = args[0] deleteRunReq.RunId = args[0]
} }
@ -435,11 +459,17 @@ func newDeleteRuns() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteRunsJson.Unmarshal(&deleteRunsReq) diags := deleteRunsJson.Unmarshal(&deleteRunsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
deleteRunsReq.ExperimentId = args[0] deleteRunsReq.ExperimentId = args[0]
} }
@ -518,11 +548,17 @@ func newDeleteTag() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteTagJson.Unmarshal(&deleteTagReq) diags := deleteTagJson.Unmarshal(&deleteTagReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
deleteTagReq.RunId = args[0] deleteTagReq.RunId = args[0]
} }
@ -1108,11 +1144,17 @@ func newLogBatch() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = logBatchJson.Unmarshal(&logBatchReq) diags := logBatchJson.Unmarshal(&logBatchReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
err = w.Experiments.LogBatch(ctx, logBatchReq) err = w.Experiments.LogBatch(ctx, logBatchReq)
if err != nil { if err != nil {
@ -1174,11 +1216,17 @@ func newLogInputs() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = logInputsJson.Unmarshal(&logInputsReq) diags := logInputsJson.Unmarshal(&logInputsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
err = w.Experiments.LogInputs(ctx, logInputsReq) err = w.Experiments.LogInputs(ctx, logInputsReq)
if err != nil { if err != nil {
@ -1254,11 +1302,17 @@ func newLogMetric() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = logMetricJson.Unmarshal(&logMetricReq) diags := logMetricJson.Unmarshal(&logMetricReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
logMetricReq.Key = args[0] logMetricReq.Key = args[0]
} }
@ -1335,11 +1389,17 @@ func newLogModel() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = logModelJson.Unmarshal(&logModelReq) diags := logModelJson.Unmarshal(&logModelReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
err = w.Experiments.LogModel(ctx, logModelReq) err = w.Experiments.LogModel(ctx, logModelReq)
if err != nil { if err != nil {
@ -1414,11 +1474,17 @@ func newLogParam() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = logParamJson.Unmarshal(&logParamReq) diags := logParamJson.Unmarshal(&logParamReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
logParamReq.Key = args[0] logParamReq.Key = args[0]
} }
@ -1497,11 +1563,17 @@ func newRestoreExperiment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = restoreExperimentJson.Unmarshal(&restoreExperimentReq) diags := restoreExperimentJson.Unmarshal(&restoreExperimentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
restoreExperimentReq.ExperimentId = args[0] restoreExperimentReq.ExperimentId = args[0]
} }
@ -1572,11 +1644,17 @@ func newRestoreRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = restoreRunJson.Unmarshal(&restoreRunReq) diags := restoreRunJson.Unmarshal(&restoreRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
restoreRunReq.RunId = args[0] restoreRunReq.RunId = args[0]
} }
@ -1655,11 +1733,17 @@ func newRestoreRuns() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = restoreRunsJson.Unmarshal(&restoreRunsReq) diags := restoreRunsJson.Unmarshal(&restoreRunsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
restoreRunsReq.ExperimentId = args[0] restoreRunsReq.ExperimentId = args[0]
} }
@ -1732,11 +1816,17 @@ func newSearchExperiments() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = searchExperimentsJson.Unmarshal(&searchExperimentsReq) diags := searchExperimentsJson.Unmarshal(&searchExperimentsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response := w.Experiments.SearchExperiments(ctx, searchExperimentsReq) response := w.Experiments.SearchExperiments(ctx, searchExperimentsReq)
return cmdio.RenderIterator(ctx, response) return cmdio.RenderIterator(ctx, response)
@ -1800,11 +1890,17 @@ func newSearchRuns() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = searchRunsJson.Unmarshal(&searchRunsReq) diags := searchRunsJson.Unmarshal(&searchRunsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response := w.Experiments.SearchRuns(ctx, searchRunsReq) response := w.Experiments.SearchRuns(ctx, searchRunsReq)
return cmdio.RenderIterator(ctx, response) return cmdio.RenderIterator(ctx, response)
@ -1874,11 +1970,17 @@ func newSetExperimentTag() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setExperimentTagJson.Unmarshal(&setExperimentTagReq) diags := setExperimentTagJson.Unmarshal(&setExperimentTagReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
setExperimentTagReq.ExperimentId = args[0] setExperimentTagReq.ExperimentId = args[0]
} }
@ -1951,11 +2053,17 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
setPermissionsReq.ExperimentId = args[0] setPermissionsReq.ExperimentId = args[0]
response, err := w.Experiments.SetPermissions(ctx, setPermissionsReq) response, err := w.Experiments.SetPermissions(ctx, setPermissionsReq)
@ -2032,11 +2140,17 @@ func newSetTag() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setTagJson.Unmarshal(&setTagReq) diags := setTagJson.Unmarshal(&setTagReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
setTagReq.Key = args[0] setTagReq.Key = args[0]
} }
@ -2112,11 +2226,17 @@ func newUpdateExperiment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateExperimentJson.Unmarshal(&updateExperimentReq) diags := updateExperimentJson.Unmarshal(&updateExperimentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateExperimentReq.ExperimentId = args[0] updateExperimentReq.ExperimentId = args[0]
} }
@ -2183,11 +2303,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updatePermissionsReq.ExperimentId = args[0] updatePermissionsReq.ExperimentId = args[0]
response, err := w.Experiments.UpdatePermissions(ctx, updatePermissionsReq) response, err := w.Experiments.UpdatePermissions(ctx, updatePermissionsReq)
@ -2251,11 +2377,17 @@ func newUpdateRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateRunJson.Unmarshal(&updateRunReq) diags := updateRunJson.Unmarshal(&updateRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.Experiments.UpdateRun(ctx, updateRunReq) response, err := w.Experiments.UpdateRun(ctx, updateRunReq)
if err != nil { if err != nil {

View File

@ -112,11 +112,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Name = args[0] createReq.Name = args[0]
} }
@ -381,11 +387,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.Name = args[0] updateReq.Name = args[0]
response, err := w.ExternalLocations.Update(ctx, updateReq) response, err := w.ExternalLocations.Update(ctx, updateReq)

View File

@ -85,10 +85,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -381,11 +387,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No NAME argument specified. Loading names for Functions drop-down." promptSpinner <- "No NAME argument specified. Loading names for Functions drop-down."

View File

@ -105,11 +105,17 @@ func newCreateMessage() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createMessageJson.Unmarshal(&createMessageReq) diags := createMessageJson.Unmarshal(&createMessageReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
createMessageReq.SpaceId = args[0] createMessageReq.SpaceId = args[0]
createMessageReq.ConversationId = args[1] createMessageReq.ConversationId = args[1]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -392,11 +398,17 @@ func newStartConversation() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = startConversationJson.Unmarshal(&startConversationReq) diags := startConversationJson.Unmarshal(&startConversationReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
startConversationReq.SpaceId = args[0] startConversationReq.SpaceId = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
startConversationReq.Content = args[1] startConversationReq.Content = args[1]

View File

@ -103,11 +103,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.GitProvider = args[0] createReq.GitProvider = args[0]
} }
@ -371,11 +377,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
_, err = fmt.Sscan(args[0], &updateReq.CredentialId) _, err = fmt.Sscan(args[0], &updateReq.CredentialId)
if err != nil { if err != nil {
return fmt.Errorf("invalid CREDENTIAL_ID: %s", args[0]) return fmt.Errorf("invalid CREDENTIAL_ID: %s", args[0])

View File

@ -101,11 +101,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Name = args[0] createReq.Name = args[0]
} }
@ -367,11 +373,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.ScriptId = args[0] updateReq.ScriptId = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateReq.Name = args[1] updateReq.Name = args[1]

View File

@ -223,11 +223,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
_, err = fmt.Sscan(args[0], &updateReq.SecurableType) _, err = fmt.Sscan(args[0], &updateReq.SecurableType)
if err != nil { if err != nil {
return fmt.Errorf("invalid SECURABLE_TYPE: %s", args[0]) return fmt.Errorf("invalid SECURABLE_TYPE: %s", args[0])

View File

@ -97,11 +97,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.Groups.Create(ctx, createReq) response, err := w.Groups.Create(ctx, createReq)
if err != nil { if err != nil {
@ -358,11 +364,17 @@ func newPatch() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Groups drop-down." promptSpinner <- "No ID argument specified. Loading names for Groups drop-down."
@ -446,11 +458,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Groups drop-down." promptSpinner <- "No ID argument specified. Loading names for Groups drop-down."

View File

@ -128,11 +128,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.InstancePoolName = args[0] createReq.InstancePoolName = args[0]
} }
@ -206,10 +212,16 @@ func newDelete() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteJson.Unmarshal(&deleteReq) diags := deleteJson.Unmarshal(&deleteReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -309,11 +321,17 @@ func newEdit() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = editJson.Unmarshal(&editReq) diags := editJson.Unmarshal(&editReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
editReq.InstancePoolId = args[0] editReq.InstancePoolId = args[0]
} }
@ -631,11 +649,17 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down." promptSpinner <- "No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down."
@ -712,11 +736,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down." promptSpinner <- "No INSTANCE_POOL_ID argument specified. Loading names for Instance Pools drop-down."

View File

@ -99,11 +99,17 @@ func newAdd() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = addJson.Unmarshal(&addReq) diags := addJson.Unmarshal(&addReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
addReq.InstanceProfileArn = args[0] addReq.InstanceProfileArn = args[0]
} }
@ -192,11 +198,17 @@ func newEdit() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = editJson.Unmarshal(&editReq) diags := editJson.Unmarshal(&editReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
editReq.InstanceProfileArn = args[0] editReq.InstanceProfileArn = args[0]
} }
@ -311,11 +323,17 @@ func newRemove() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = removeJson.Unmarshal(&removeReq) diags := removeJson.Unmarshal(&removeReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
removeReq.InstanceProfileArn = args[0] removeReq.InstanceProfileArn = args[0]
} }

View File

@ -133,11 +133,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Label = args[0] createReq.Label = args[0]
} }
@ -414,11 +420,17 @@ func newReplace() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = replaceJson.Unmarshal(&replaceReq) diags := replaceJson.Unmarshal(&replaceReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
replaceReq.IpAccessListId = args[0] replaceReq.IpAccessListId = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
replaceReq.Label = args[1] replaceReq.Label = args[1]
@ -510,11 +522,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No IP_ACCESS_LIST_ID argument specified. Loading names for Ip Access Lists drop-down." promptSpinner <- "No IP_ACCESS_LIST_ID argument specified. Loading names for Ip Access Lists drop-down."

View File

@ -116,11 +116,17 @@ func newCancelAllRuns() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = cancelAllRunsJson.Unmarshal(&cancelAllRunsReq) diags := cancelAllRunsJson.Unmarshal(&cancelAllRunsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
err = w.Jobs.CancelAllRuns(ctx, cancelAllRunsReq) err = w.Jobs.CancelAllRuns(ctx, cancelAllRunsReq)
if err != nil { if err != nil {
@ -193,10 +199,16 @@ func newCancelRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = cancelRunJson.Unmarshal(&cancelRunReq) diags := cancelRunJson.Unmarshal(&cancelRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -291,10 +303,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -364,10 +382,16 @@ func newDelete() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteJson.Unmarshal(&deleteReq) diags := deleteJson.Unmarshal(&deleteReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -457,10 +481,16 @@ func newDeleteRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteRunJson.Unmarshal(&deleteRunReq) diags := deleteRunJson.Unmarshal(&deleteRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1143,10 +1173,16 @@ func newRepairRun() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = repairRunJson.Unmarshal(&repairRunReq) diags := repairRunJson.Unmarshal(&repairRunReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1242,10 +1278,16 @@ func newReset() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = resetJson.Unmarshal(&resetReq) diags := resetJson.Unmarshal(&resetReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -1332,10 +1374,16 @@ func newRunNow() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = runNowJson.Unmarshal(&runNowReq) diags := runNowJson.Unmarshal(&runNowReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1436,11 +1484,17 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No JOB_ID argument specified. Loading names for Jobs drop-down." promptSpinner <- "No JOB_ID argument specified. Loading names for Jobs drop-down."
@ -1538,11 +1592,17 @@ func newSubmit() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = submitJson.Unmarshal(&submitReq) diags := submitJson.Unmarshal(&submitReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
wait, err := w.Jobs.Submit(ctx, submitReq) wait, err := w.Jobs.Submit(ctx, submitReq)
if err != nil { if err != nil {
@ -1632,10 +1692,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
@ -1717,11 +1783,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No JOB_ID argument specified. Loading names for Jobs drop-down." promptSpinner <- "No JOB_ID argument specified. Loading names for Jobs drop-down."

View File

@ -108,11 +108,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.DisplayName = args[0] createReq.DisplayName = args[0]
} }
@ -180,10 +186,16 @@ func newCreateSchedule() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createScheduleJson.Unmarshal(&createScheduleReq) diags := createScheduleJson.Unmarshal(&createScheduleReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -250,10 +262,16 @@ func newCreateSubscription() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createSubscriptionJson.Unmarshal(&createSubscriptionReq) diags := createSubscriptionJson.Unmarshal(&createSubscriptionReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -870,11 +888,17 @@ func newMigrate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = migrateJson.Unmarshal(&migrateReq) diags := migrateJson.Unmarshal(&migrateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
migrateReq.SourceDashboardId = args[0] migrateReq.SourceDashboardId = args[0]
} }
@ -941,11 +965,17 @@ func newPublish() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = publishJson.Unmarshal(&publishReq) diags := publishJson.Unmarshal(&publishReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
publishReq.DashboardId = args[0] publishReq.DashboardId = args[0]
response, err := w.Lakeview.Publish(ctx, publishReq) response, err := w.Lakeview.Publish(ctx, publishReq)
@ -1128,11 +1158,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.DashboardId = args[0] updateReq.DashboardId = args[0]
response, err := w.Lakeview.Update(ctx, updateReq) response, err := w.Lakeview.Update(ctx, updateReq)
@ -1200,10 +1236,16 @@ func newUpdateSchedule() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateScheduleJson.Unmarshal(&updateScheduleReq) diags := updateScheduleJson.Unmarshal(&updateScheduleReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -190,10 +190,16 @@ func newInstall() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = installJson.Unmarshal(&installReq) diags := installJson.Unmarshal(&installReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -251,10 +257,16 @@ func newUninstall() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = uninstallJson.Unmarshal(&uninstallReq) diags := uninstallJson.Unmarshal(&uninstallReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -112,11 +112,17 @@ func newAssign() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = assignJson.Unmarshal(&assignReq) diags := assignJson.Unmarshal(&assignReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
_, err = fmt.Sscan(args[0], &assignReq.WorkspaceId) _, err = fmt.Sscan(args[0], &assignReq.WorkspaceId)
if err != nil { if err != nil {
return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0]) return fmt.Errorf("invalid WORKSPACE_ID: %s", args[0])
@ -201,11 +207,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Name = args[0] createReq.Name = args[0]
} }
@ -606,11 +618,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Metastores drop-down." promptSpinner <- "No ID argument specified. Loading names for Metastores drop-down."
@ -690,11 +708,17 @@ func newUpdateAssignment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateAssignmentJson.Unmarshal(&updateAssignmentReq) diags := updateAssignmentJson.Unmarshal(&updateAssignmentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Metastores drop-down." promptSpinner <- "No WORKSPACE_ID argument specified. Loading names for Metastores drop-down."

View File

@ -141,11 +141,17 @@ func newApproveTransitionRequest() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = approveTransitionRequestJson.Unmarshal(&approveTransitionRequestReq) diags := approveTransitionRequestJson.Unmarshal(&approveTransitionRequestReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
approveTransitionRequestReq.Name = args[0] approveTransitionRequestReq.Name = args[0]
} }
@ -235,11 +241,17 @@ func newCreateComment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createCommentJson.Unmarshal(&createCommentReq) diags := createCommentJson.Unmarshal(&createCommentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createCommentReq.Name = args[0] createCommentReq.Name = args[0]
} }
@ -322,11 +334,17 @@ func newCreateModel() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createModelJson.Unmarshal(&createModelReq) diags := createModelJson.Unmarshal(&createModelReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createModelReq.Name = args[0] createModelReq.Name = args[0]
} }
@ -403,11 +421,17 @@ func newCreateModelVersion() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createModelVersionJson.Unmarshal(&createModelVersionReq) diags := createModelVersionJson.Unmarshal(&createModelVersionReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createModelVersionReq.Name = args[0] createModelVersionReq.Name = args[0]
} }
@ -493,11 +517,17 @@ func newCreateTransitionRequest() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createTransitionRequestJson.Unmarshal(&createTransitionRequestReq) diags := createTransitionRequestJson.Unmarshal(&createTransitionRequestReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createTransitionRequestReq.Name = args[0] createTransitionRequestReq.Name = args[0]
} }
@ -570,10 +600,16 @@ func newCreateWebhook() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createWebhookJson.Unmarshal(&createWebhookReq) diags := createWebhookJson.Unmarshal(&createWebhookReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -1079,11 +1115,17 @@ func newGetLatestVersions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = getLatestVersionsJson.Unmarshal(&getLatestVersionsReq) diags := getLatestVersionsJson.Unmarshal(&getLatestVersionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
getLatestVersionsReq.Name = args[0] getLatestVersionsReq.Name = args[0]
} }
@ -1629,11 +1671,17 @@ func newRejectTransitionRequest() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = rejectTransitionRequestJson.Unmarshal(&rejectTransitionRequestReq) diags := rejectTransitionRequestJson.Unmarshal(&rejectTransitionRequestReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
rejectTransitionRequestReq.Name = args[0] rejectTransitionRequestReq.Name = args[0]
} }
@ -1715,11 +1763,17 @@ func newRenameModel() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = renameModelJson.Unmarshal(&renameModelReq) diags := renameModelJson.Unmarshal(&renameModelReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
renameModelReq.Name = args[0] renameModelReq.Name = args[0]
} }
@ -1907,11 +1961,17 @@ func newSetModelTag() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setModelTagJson.Unmarshal(&setModelTagReq) diags := setModelTagJson.Unmarshal(&setModelTagReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
setModelTagReq.Name = args[0] setModelTagReq.Name = args[0]
} }
@ -1996,11 +2056,17 @@ func newSetModelVersionTag() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setModelVersionTagJson.Unmarshal(&setModelVersionTagReq) diags := setModelVersionTagJson.Unmarshal(&setModelVersionTagReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
setModelVersionTagReq.Name = args[0] setModelVersionTagReq.Name = args[0]
} }
@ -2076,11 +2142,17 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
setPermissionsReq.RegisteredModelId = args[0] setPermissionsReq.RegisteredModelId = args[0]
response, err := w.ModelRegistry.SetPermissions(ctx, setPermissionsReq) response, err := w.ModelRegistry.SetPermissions(ctx, setPermissionsReq)
@ -2166,11 +2238,17 @@ func newTestRegistryWebhook() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = testRegistryWebhookJson.Unmarshal(&testRegistryWebhookReq) diags := testRegistryWebhookJson.Unmarshal(&testRegistryWebhookReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
testRegistryWebhookReq.Id = args[0] testRegistryWebhookReq.Id = args[0]
} }
@ -2259,11 +2337,17 @@ func newTransitionStage() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = transitionStageJson.Unmarshal(&transitionStageReq) diags := transitionStageJson.Unmarshal(&transitionStageReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
transitionStageReq.Name = args[0] transitionStageReq.Name = args[0]
} }
@ -2350,11 +2434,17 @@ func newUpdateComment() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateCommentJson.Unmarshal(&updateCommentReq) diags := updateCommentJson.Unmarshal(&updateCommentReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateCommentReq.Id = args[0] updateCommentReq.Id = args[0]
} }
@ -2430,11 +2520,17 @@ func newUpdateModel() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateModelJson.Unmarshal(&updateModelReq) diags := updateModelJson.Unmarshal(&updateModelReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateModelReq.Name = args[0] updateModelReq.Name = args[0]
} }
@ -2508,11 +2604,17 @@ func newUpdateModelVersion() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateModelVersionJson.Unmarshal(&updateModelVersionReq) diags := updateModelVersionJson.Unmarshal(&updateModelVersionReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateModelVersionReq.Name = args[0] updateModelVersionReq.Name = args[0]
} }
@ -2582,11 +2684,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updatePermissionsReq.RegisteredModelId = args[0] updatePermissionsReq.RegisteredModelId = args[0]
response, err := w.ModelRegistry.UpdatePermissions(ctx, updatePermissionsReq) response, err := w.ModelRegistry.UpdatePermissions(ctx, updatePermissionsReq)
@ -2663,11 +2771,17 @@ func newUpdateWebhook() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateWebhookJson.Unmarshal(&updateWebhookReq) diags := updateWebhookJson.Unmarshal(&updateWebhookReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateWebhookReq.Id = args[0] updateWebhookReq.Id = args[0]
} }

View File

@ -377,11 +377,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.FullName = args[0] updateReq.FullName = args[0]
_, err = fmt.Sscan(args[1], &updateReq.Version) _, err = fmt.Sscan(args[1], &updateReq.Version)
if err != nil { if err != nil {

View File

@ -84,11 +84,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.NotificationDestinations.Create(ctx, createReq) response, err := w.NotificationDestinations.Create(ctx, createReq)
if err != nil { if err != nil {
@ -313,11 +319,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.Id = args[0] updateReq.Id = args[0]
response, err := w.NotificationDestinations.Update(ctx, updateReq) response, err := w.NotificationDestinations.Update(ctx, updateReq)

View File

@ -79,11 +79,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.OnlineTables.Create(ctx, createReq) response, err := w.OnlineTables.Create(ctx, createReq)
if err != nil { if err != nil {

View File

@ -92,11 +92,17 @@ func newMigratePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = migratePermissionsJson.Unmarshal(&migratePermissionsReq) diags := migratePermissionsJson.Unmarshal(&migratePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[0], &migratePermissionsReq.WorkspaceId) _, err = fmt.Sscan(args[0], &migratePermissionsReq.WorkspaceId)
if err != nil { if err != nil {

View File

@ -265,11 +265,17 @@ func newSet() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setJson.Unmarshal(&setReq) diags := setJson.Unmarshal(&setReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
setReq.RequestObjectType = args[0] setReq.RequestObjectType = args[0]
setReq.RequestObjectId = args[1] setReq.RequestObjectId = args[1]
@ -340,11 +346,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.RequestObjectType = args[0] updateReq.RequestObjectType = args[0]
updateReq.RequestObjectId = args[1] updateReq.RequestObjectId = args[1]

View File

@ -98,10 +98,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -699,11 +705,17 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down." promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down."
@ -788,11 +800,17 @@ func newStartUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = startUpdateJson.Unmarshal(&startUpdateReq) diags := startUpdateJson.Unmarshal(&startUpdateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down." promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down."
@ -977,11 +995,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down." promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down."
@ -1058,11 +1082,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down." promptSpinner <- "No PIPELINE_ID argument specified. Loading names for Pipelines drop-down."

View File

@ -110,11 +110,17 @@ func newEnforceCompliance() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = enforceComplianceJson.Unmarshal(&enforceComplianceReq) diags := enforceComplianceJson.Unmarshal(&enforceComplianceReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
enforceComplianceReq.ClusterId = args[0] enforceComplianceReq.ClusterId = args[0]
} }

View File

@ -104,11 +104,17 @@ func newEnforceCompliance() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = enforceComplianceJson.Unmarshal(&enforceComplianceReq) diags := enforceComplianceJson.Unmarshal(&enforceComplianceReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[0], &enforceComplianceReq.JobId) _, err = fmt.Sscan(args[0], &enforceComplianceReq.JobId)
if err != nil { if err != nil {

View File

@ -73,10 +73,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -259,10 +265,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -91,11 +91,17 @@ func newAddListingToExchange() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = addListingToExchangeJson.Unmarshal(&addListingToExchangeReq) diags := addListingToExchangeJson.Unmarshal(&addListingToExchangeReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
addListingToExchangeReq.ListingId = args[0] addListingToExchangeReq.ListingId = args[0]
} }
@ -154,10 +160,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -546,10 +558,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -77,10 +77,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -273,10 +279,16 @@ func newList() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = listJson.Unmarshal(&listReq) diags := listJson.Unmarshal(&listReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -75,10 +75,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -326,10 +332,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -142,11 +142,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.ListingId = args[0] updateReq.ListingId = args[0]
updateReq.RequestId = args[1] updateReq.RequestId = args[1]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {

View File

@ -208,11 +208,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.Id = args[0] updateReq.Id = args[0]
response, err := w.ProviderProviderAnalyticsDashboards.Update(ctx, updateReq) response, err := w.ProviderProviderAnalyticsDashboards.Update(ctx, updateReq)

View File

@ -74,10 +74,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -325,10 +331,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -97,11 +97,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Name = args[0] createReq.Name = args[0]
} }
@ -446,11 +452,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No NAME argument specified. Loading names for Providers drop-down." promptSpinner <- "No NAME argument specified. Loading names for Providers drop-down."

View File

@ -196,11 +196,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
createReq.TableName = args[0] createReq.TableName = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.AssetsDir = args[1] createReq.AssetsDir = args[1]
@ -559,11 +565,17 @@ func newRegenerateDashboard() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = regenerateDashboardJson.Unmarshal(&regenerateDashboardReq) diags := regenerateDashboardJson.Unmarshal(&regenerateDashboardReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
regenerateDashboardReq.TableName = args[0] regenerateDashboardReq.TableName = args[0]
response, err := w.QualityMonitors.RegenerateDashboard(ctx, regenerateDashboardReq) response, err := w.QualityMonitors.RegenerateDashboard(ctx, regenerateDashboardReq)
@ -724,11 +736,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.TableName = args[0] updateReq.TableName = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateReq.OutputSchemaName = args[1] updateReq.OutputSchemaName = args[1]

View File

@ -96,10 +96,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -454,11 +460,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No QUERY_ID argument specified. Loading names for Queries Legacy drop-down." promptSpinner <- "No QUERY_ID argument specified. Loading names for Queries Legacy drop-down."

View File

@ -85,11 +85,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.Queries.Create(ctx, createReq) response, err := w.Queries.Create(ctx, createReq)
if err != nil { if err != nil {
@ -425,11 +431,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.Id = args[0] updateReq.Id = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateReq.UpdateMask = args[1] updateReq.UpdateMask = args[1]

View File

@ -87,10 +87,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -222,10 +228,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -84,11 +84,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.QueryVisualizations.Create(ctx, createReq) response, err := w.QueryVisualizations.Create(ctx, createReq)
if err != nil { if err != nil {
@ -217,11 +223,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.Id = args[0] updateReq.Id = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
updateReq.UpdateMask = args[1] updateReq.UpdateMask = args[1]

View File

@ -118,11 +118,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Name = args[0] createReq.Name = args[0]
} }
@ -404,11 +410,17 @@ func newRotateToken() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = rotateTokenJson.Unmarshal(&rotateTokenReq) diags := rotateTokenJson.Unmarshal(&rotateTokenReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
rotateTokenReq.Name = args[0] rotateTokenReq.Name = args[0]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
_, err = fmt.Sscan(args[1], &rotateTokenReq.ExistingTokenExpireInSeconds) _, err = fmt.Sscan(args[1], &rotateTokenReq.ExistingTokenExpireInSeconds)
@ -554,11 +566,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No NAME argument specified. Loading names for Recipients drop-down." promptSpinner <- "No NAME argument specified. Loading names for Recipients drop-down."

View File

@ -135,11 +135,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.CatalogName = args[0] createReq.CatalogName = args[0]
} }
@ -509,11 +515,17 @@ func newSetAlias() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setAliasJson.Unmarshal(&setAliasReq) diags := setAliasJson.Unmarshal(&setAliasReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
setAliasReq.FullName = args[0] setAliasReq.FullName = args[0]
setAliasReq.Alias = args[1] setAliasReq.Alias = args[1]
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
@ -589,11 +601,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No FULL_NAME argument specified. Loading names for Registered Models drop-down." promptSpinner <- "No FULL_NAME argument specified. Loading names for Registered Models drop-down."

View File

@ -7,6 +7,7 @@ import (
"github.com/databricks/cli/cmd/root" "github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/flags"
"github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/workspace" "github.com/databricks/databricks-sdk-go/service/workspace"
@ -35,10 +36,16 @@ func createOverride(createCmd *cobra.Command, createReq *workspace.CreateRepoReq
ctx := cmd.Context() ctx := cmd.Context()
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(createReq) diags := createJson.Unmarshal(createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
createReq.Url = args[0] createReq.Url = args[0]
if len(args) > 1 { if len(args) > 1 {
@ -101,12 +108,19 @@ func updateOverride(updateCmd *cobra.Command, updateReq *workspace.UpdateRepoReq
updateJson := updateCmd.Flag("json").Value.(*flags.JsonFlag) updateJson := updateCmd.Flag("json").Value.(*flags.JsonFlag)
updateCmd.RunE = func(cmd *cobra.Command, args []string) (err error) { updateCmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context() ctx := cmd.Context()
var diags diag.Diagnostics
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags = updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
updateReq.RepoId, err = repoArgumentToRepoID(ctx, w, args) updateReq.RepoId, err = repoArgumentToRepoID(ctx, w, args)
if err != nil { if err != nil {

View File

@ -111,11 +111,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Url = args[0] createReq.Url = args[0]
} }
@ -521,11 +527,17 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down." promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down."
@ -604,11 +616,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down." promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down."
@ -688,11 +706,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down." promptSpinner <- "No REPO_ID argument specified. Loading names for Repos drop-down."

View File

@ -197,10 +197,16 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -100,11 +100,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Name = args[0] createReq.Name = args[0]
} }
@ -386,11 +392,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No FULL_NAME argument specified. Loading names for Schemas drop-down." promptSpinner <- "No FULL_NAME argument specified. Loading names for Schemas drop-down."

View File

@ -8,6 +8,7 @@ import (
"github.com/databricks/cli/cmd/root" "github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/flags" "github.com/databricks/cli/libs/flags"
"github.com/databricks/databricks-sdk-go/service/workspace" "github.com/databricks/databricks-sdk-go/service/workspace"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -60,6 +61,7 @@ func newPutSecret() *cobra.Command {
cmd.PreRunE = root.MustWorkspaceClient cmd.PreRunE = root.MustWorkspaceClient
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) { cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context() ctx := cmd.Context()
var diags diag.Diagnostics
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
bytesValueChanged := cmd.Flags().Changed("bytes-value") bytesValueChanged := cmd.Flags().Changed("bytes-value")
@ -69,10 +71,16 @@ func newPutSecret() *cobra.Command {
} }
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = putSecretJson.Unmarshal(&putSecretReq) diags = putSecretJson.Unmarshal(&putSecretReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} else { } else {
putSecretReq.Scope = args[0] putSecretReq.Scope = args[0]
putSecretReq.Key = args[1] putSecretReq.Key = args[1]

View File

@ -110,11 +110,17 @@ func newCreateScope() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createScopeJson.Unmarshal(&createScopeReq) diags := createScopeJson.Unmarshal(&createScopeReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createScopeReq.Scope = args[0] createScopeReq.Scope = args[0]
} }
@ -191,11 +197,17 @@ func newDeleteAcl() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteAclJson.Unmarshal(&deleteAclReq) diags := deleteAclJson.Unmarshal(&deleteAclReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
deleteAclReq.Scope = args[0] deleteAclReq.Scope = args[0]
} }
@ -273,11 +285,17 @@ func newDeleteScope() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteScopeJson.Unmarshal(&deleteScopeReq) diags := deleteScopeJson.Unmarshal(&deleteScopeReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
deleteScopeReq.Scope = args[0] deleteScopeReq.Scope = args[0]
} }
@ -354,11 +372,17 @@ func newDeleteSecret() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = deleteSecretJson.Unmarshal(&deleteSecretReq) diags := deleteSecretJson.Unmarshal(&deleteSecretReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
deleteSecretReq.Scope = args[0] deleteSecretReq.Scope = args[0]
} }
@ -759,11 +783,17 @@ func newPutAcl() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = putAclJson.Unmarshal(&putAclReq) diags := putAclJson.Unmarshal(&putAclReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
putAclReq.Scope = args[0] putAclReq.Scope = args[0]
} }

View File

@ -95,11 +95,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.ServicePrincipals.Create(ctx, createReq) response, err := w.ServicePrincipals.Create(ctx, createReq)
if err != nil { if err != nil {
@ -358,11 +364,17 @@ func newPatch() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Service Principals drop-down." promptSpinner <- "No ID argument specified. Loading names for Service Principals drop-down."
@ -448,11 +460,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No ID argument specified. Loading names for Service Principals drop-down." promptSpinner <- "No ID argument specified. Loading names for Service Principals drop-down."

View File

@ -169,10 +169,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }
@ -706,11 +712,17 @@ func newPatch() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = patchJson.Unmarshal(&patchReq) diags := patchJson.Unmarshal(&patchReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
patchReq.Name = args[0] patchReq.Name = args[0]
response, err := w.ServingEndpoints.Patch(ctx, patchReq) response, err := w.ServingEndpoints.Patch(ctx, patchReq)
@ -777,11 +789,17 @@ func newPut() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = putJson.Unmarshal(&putReq) diags := putJson.Unmarshal(&putReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
putReq.Name = args[0] putReq.Name = args[0]
response, err := w.ServingEndpoints.Put(ctx, putReq) response, err := w.ServingEndpoints.Put(ctx, putReq)
@ -850,11 +868,17 @@ func newPutAiGateway() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = putAiGatewayJson.Unmarshal(&putAiGatewayReq) diags := putAiGatewayJson.Unmarshal(&putAiGatewayReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
putAiGatewayReq.Name = args[0] putAiGatewayReq.Name = args[0]
response, err := w.ServingEndpoints.PutAiGateway(ctx, putAiGatewayReq) response, err := w.ServingEndpoints.PutAiGateway(ctx, putAiGatewayReq)
@ -928,11 +952,17 @@ func newQuery() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = queryJson.Unmarshal(&queryReq) diags := queryJson.Unmarshal(&queryReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
queryReq.Name = args[0] queryReq.Name = args[0]
response, err := w.ServingEndpoints.Query(ctx, queryReq) response, err := w.ServingEndpoints.Query(ctx, queryReq)
@ -997,11 +1027,17 @@ func newSetPermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = setPermissionsJson.Unmarshal(&setPermissionsReq) diags := setPermissionsJson.Unmarshal(&setPermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
setPermissionsReq.ServingEndpointId = args[0] setPermissionsReq.ServingEndpointId = args[0]
response, err := w.ServingEndpoints.SetPermissions(ctx, setPermissionsReq) response, err := w.ServingEndpoints.SetPermissions(ctx, setPermissionsReq)
@ -1076,11 +1112,17 @@ func newUpdateConfig() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateConfigJson.Unmarshal(&updateConfigReq) diags := updateConfigJson.Unmarshal(&updateConfigReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateConfigReq.Name = args[0] updateConfigReq.Name = args[0]
wait, err := w.ServingEndpoints.UpdateConfig(ctx, updateConfigReq) wait, err := w.ServingEndpoints.UpdateConfig(ctx, updateConfigReq)
@ -1158,11 +1200,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updatePermissionsReq.ServingEndpointId = args[0] updatePermissionsReq.ServingEndpointId = args[0]
response, err := w.ServingEndpoints.UpdatePermissions(ctx, updatePermissionsReq) response, err := w.ServingEndpoints.UpdatePermissions(ctx, updatePermissionsReq)

View File

@ -100,11 +100,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Name = args[0] createReq.Name = args[0]
} }
@ -427,11 +433,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updateReq.Name = args[0] updateReq.Name = args[0]
response, err := w.Shares.Update(ctx, updateReq) response, err := w.Shares.Update(ctx, updateReq)
@ -501,11 +513,17 @@ func newUpdatePermissions() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updatePermissionsJson.Unmarshal(&updatePermissionsReq) diags := updatePermissionsJson.Unmarshal(&updatePermissionsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
updatePermissionsReq.Name = args[0] updatePermissionsReq.Name = args[0]
err = w.Shares.UpdatePermissions(ctx, updatePermissionsReq) err = w.Shares.UpdatePermissions(ctx, updatePermissionsReq)

View File

@ -111,11 +111,17 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if !cmd.Flags().Changed("json") { if !cmd.Flags().Changed("json") {
createReq.Name = args[0] createReq.Name = args[0]
} }
@ -377,11 +383,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No NAME argument specified. Loading names for Storage Credentials drop-down." promptSpinner <- "No NAME argument specified. Loading names for Storage Credentials drop-down."
@ -478,11 +490,17 @@ func newValidate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = validateJson.Unmarshal(&validateReq) diags := validateJson.Unmarshal(&validateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.StorageCredentials.Validate(ctx, validateReq) response, err := w.StorageCredentials.Validate(ctx, validateReq)
if err != nil { if err != nil {

View File

@ -92,10 +92,16 @@ func newCreate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = createJson.Unmarshal(&createReq) diags := createJson.Unmarshal(&createReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
}
} 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")
} }

View File

@ -479,11 +479,17 @@ func newUpdate() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = updateJson.Unmarshal(&updateReq) diags := updateJson.Unmarshal(&updateReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
if len(args) == 0 { if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx) promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No FULL_NAME argument specified. Loading names for Tables drop-down." promptSpinner <- "No FULL_NAME argument specified. Loading names for Tables drop-down."

View File

@ -94,11 +94,17 @@ func newGenerateTemporaryTableCredentials() *cobra.Command {
w := root.WorkspaceClient(ctx) w := root.WorkspaceClient(ctx)
if cmd.Flags().Changed("json") { if cmd.Flags().Changed("json") {
err = generateTemporaryTableCredentialsJson.Unmarshal(&generateTemporaryTableCredentialsReq) diags := generateTemporaryTableCredentialsJson.Unmarshal(&generateTemporaryTableCredentialsReq)
if diags.HasError() {
return diags.Error()
}
if len(diags) > 0 {
err := cmdio.RenderDiagnosticsToErrorOut(ctx, diags)
if err != nil { if err != nil {
return err return err
} }
} }
}
response, err := w.TemporaryTableCredentials.GenerateTemporaryTableCredentials(ctx, generateTemporaryTableCredentialsReq) response, err := w.TemporaryTableCredentials.GenerateTemporaryTableCredentials(ctx, generateTemporaryTableCredentialsReq)
if err != nil { if err != nil {

Some files were not shown because too many files have changed in this diff Show More