Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .codegen/service.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func New() *cobra.Command {
// Functions can be added from the `init()` function in manually curated files in this directory.
var {{.CamelName}}Overrides []func(
*cobra.Command,
{{- if .Request }}
{{- if not .IsLegacyEmptyRequest }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the semantics of .IsLegacyEmptyRequest in the PR description? For which fields will it be set.

*{{.Service.Package.Name}}.{{.Request.PascalName}},
{{- end }}
)
Expand All @@ -124,7 +124,7 @@ func new{{.PascalName}}() *cobra.Command {
cmd := &cobra.Command{}

{{- $canUseJson := and .CanUseJson (not (in $excludeFromJson .KebabName )) -}}
{{- if .Request}}
{{- if not .IsLegacyEmptyRequest}}

var {{.CamelName}}Req {{.Service.Package.Name}}.{{.Request.PascalName}}
{{- if .RequestBodyField }}
Expand All @@ -146,7 +146,7 @@ func new{{.PascalName}}() *cobra.Command {
{{- if .RequestBodyField -}}
{{- $request = .RequestBodyField.Entity -}}
{{- end -}}
{{if $request }}// TODO: short flags
{{if $request }}
{{- if $canUseJson}}
cmd.Flags().Var(&{{.CamelName}}Json, "json", `either inline JSON string or @path/to/file.json with request body`)
{{- end}}
Expand Down Expand Up @@ -188,7 +188,7 @@ func new{{.PascalName}}() *cobra.Command {
{{- $wait := and .Wait (and (not .IsCrudRead) (not (eq .SnakeName "get_run"))) -}}
{{- $hasRequiredArgs := and (not $hasIdPrompt) $hasPosArgs -}}
{{- $hasSingleRequiredRequestBodyFieldWithPrompt := and (and $hasIdPrompt $request) (eq 1 (len $request.RequiredRequestBodyFields)) -}}
{{- $onlyPathArgsRequiredAsPositionalArguments := and .Request (eq (len .RequiredPositionalArguments) (len .Request.RequiredPathFields)) -}}
{{- $onlyPathArgsRequiredAsPositionalArguments := and (not .IsLegacyEmptyRequest) (eq (len .RequiredPositionalArguments) (len .Request.RequiredPathFields)) -}}
{{- $hasDifferentArgsWithJsonFlag := and (not $onlyPathArgsRequiredAsPositionalArguments) (and $canUseJson (or $request.HasRequiredRequestBodyFields )) -}}
{{- $hasCustomArgHandler := or $hasRequiredArgs $hasDifferentArgsWithJsonFlag -}}

Expand Down Expand Up @@ -250,7 +250,7 @@ func new{{.PascalName}}() *cobra.Command {
cmd.RunE = func(cmd *cobra.Command, args []string) (err error) {
ctx := cmd.Context()
{{if .Service.IsAccounts}}a := cmdctx.AccountClient(ctx){{else}}w := cmdctx.WorkspaceClient(ctx){{end}}
{{- if .Request }}
{{- if not .IsLegacyEmptyRequest }}
{{ if $canUseJson }}
if cmd.Flags().Changed("json") {
diags := {{.CamelName}}Json.Unmarshal(&{{.CamelName}}Req{{ if .RequestBodyField }}.{{.RequestBodyField.PascalName}}{{ end }})
Expand All @@ -273,7 +273,7 @@ func new{{.PascalName}}() *cobra.Command {
if len(args) == 0 {
promptSpinner := cmdio.Spinner(ctx)
promptSpinner <- "No{{range $request.RequiredFields}} {{.ConstantName}}{{end}} argument specified. Loading names for {{.Service.TitleName}} drop-down."
names, err := {{if .Service.IsAccounts}}a{{else}}w{{end}}.{{(.Service.TrimPrefix "account").PascalName}}.{{.Service.List.NamedIdMap.PascalName}}(ctx{{if .Service.List.Request}}, {{.Service.Package.Name}}.{{.Service.List.Request.PascalName}}{}{{end}})
names, err := {{if .Service.IsAccounts}}a{{else}}w{{end}}.{{(.Service.TrimPrefix "account").PascalName}}.{{.Service.List.NamedIdMap.PascalName}}(ctx{{if not .Service.List.IsLegacyEmptyRequest}}, {{.Service.Package.Name}}.{{.Service.List.Request.PascalName}}{}{{end}})
close(promptSpinner)
if err != nil {
return fmt.Errorf("failed to load names for {{.Service.TitleName}} drop-down. Please manually specify required arguments. Original error: %w", err)
Expand All @@ -300,7 +300,7 @@ func new{{.PascalName}}() *cobra.Command {
{{- end}}
{{end}}
{{if $wait -}}
wait, err := {{if .Service.IsAccounts}}a{{else}}w{{end}}.{{.Service.PascalName}}.{{.PascalName}}(ctx{{if .Request}}, {{.CamelName}}Req{{end}})
wait, err := {{if .Service.IsAccounts}}a{{else}}w{{end}}.{{.Service.PascalName}}.{{.PascalName}}(ctx{{if not .IsLegacyEmptyRequest}}, {{.CamelName}}Req{{end}})
if err != nil {
return err
}
Expand Down Expand Up @@ -348,7 +348,7 @@ func new{{.PascalName}}() *cobra.Command {

// Apply optional overrides to this command.
for _, fn := range {{.CamelName}}Overrides {
fn(cmd{{if .Request}}, &{{.CamelName}}Req{{end}})
fn(cmd{{if not .IsLegacyEmptyRequest}}, &{{.CamelName}}Req{{end}})
}

return cmd
Expand All @@ -370,7 +370,7 @@ func new{{.PascalName}}() *cobra.Command {
{{- else}}
{{- (.Service.TrimPrefix "account").PascalName}}.
{{- end}}
{{- .PascalName}}(ctx{{if .Request}}, {{.CamelName}}Req{{end}})
{{- .PascalName}}(ctx{{if not .IsLegacyEmptyRequest}}, {{.CamelName}}Req{{end}})
{{- if not (and .Response .Pagination) }}
if err != nil {
return err
Expand Down
5 changes: 0 additions & 5 deletions cmd/account/access-control/access-control.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions cmd/account/billable-usage/billable-usage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions cmd/account/budget-policy/budget-policy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions cmd/account/budgets/budgets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions cmd/account/credentials/credentials.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions cmd/account/csp-enablement-account/csp-enablement-account.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions cmd/account/custom-app-integration/custom-app-integration.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions cmd/account/enable-ip-access-lists/enable-ip-access-lists.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions cmd/account/encryption-keys/encryption-keys.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions cmd/account/esm-enablement-account/esm-enablement-account.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading