Skip to content
Draft
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
4 changes: 4 additions & 0 deletions v3/generator/operations/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ type RequestTmpl struct {
JSONResponseTarget string
ContentType string
QueryParams map[string]string
// SkipAuth is true for operations that must be called without credentials
// (e.g. list-zones which returns public data and should not trigger IAM enforcement).
SkipAuth bool
}

// serializeRequest serializes the openAPI spec into the request template.
Expand All @@ -446,6 +449,7 @@ func serializeRequest(path, httpMethod, funcName string, op *v3.Operation) (*Req
Name: funcName,
OperationID: op.OperationId,
HTTPMethod: strings.ToUpper(httpMethod),
SkipAuth: op.OperationId == "list-zones",
}
p.Comment = renderDoc(op)
params := getParameters(op, funcName)
Expand Down
14 changes: 8 additions & 6 deletions v3/generator/operations/request.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ func (c Client) {{ .Name }}({{ .Params }}) {{ .ValueReturn }} {
return nil, fmt.Errorf("{{ .Name }}: execute request editors: %w", err)
}

if err := c.signRequest(request); err != nil {
return nil, fmt.Errorf("{{ .Name }}: sign request: %w", err)
}
{{ if not .SkipAuth }}
if err := c.signRequest(request); err != nil {
return nil, fmt.Errorf("{{ .Name }}: sign request: %w", err)
}
{{ end }}

if c.trace {
dumpRequest(request, "{{ .OperationID }}")
}
if c.trace {
dumpRequest(request, "{{ .OperationID }}")
}

response, err := c.httpClient.Do(request)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions v3/operations.go

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

Loading