You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Propagate Request Headers through API Client (#135)
## Changes
Based on changes in
databricks/databricks-sdk-go#572.
This PR adds initial support for headers in ApiClient.java. The `*Impl`
classes, when making a request, will construct a map of headers to be
included in the request. These are passed through a new parameter in
each of GET/PUT/POST/PATCH/DELETE.
In the future, to support dynamic headers, we can modify our codegen
template to add those fields to the headers map before calling the
ApiClient.
Alternatives considered:
* **Adding headers in request objects directly**: this would not require
any change in the ApiClient interface. Instead, we would introduce a new
annotation for headers, much like what we do for query parameters, and
reflectively scan the fields of each request object. We could do this,
but for headers that have a fixed value (like `Content-Type` and
`Accept`), these fields would essentially be private final fields that
we could iterate through. Users can never interact with these fields, so
it seems a bit unusual to have them in the request structure, a public
interface.
## Tests
<!-- How is this tested? -->
@@ -26,18 +27,26 @@ class {{.PascalName}}Impl implements {{.PascalName}}Service {
26
27
String path = {{if .PathParts -}}
27
28
String.format("{{range .PathParts}}{{.Prefix}}{{if or .Field .IsAccountId}}%s{{end}}{{ end }}"{{ range .PathParts }}{{if .Field}}, request.get{{.Field.PascalName}}(){{ else if .IsAccountId }}, apiClient.configuredAccountID(){{end}}{{ end }})
28
29
{{- else}}"{{.Path}}"{{end}};
30
+
{{ template "headers" . }}
29
31
{{if .Response -}}
30
-
{{- if .Response.ArrayValue -}} return apiClient.getCollection(path, null, {{template "type" .Response.ArrayValue}}.class);
31
-
{{- else if .Response.MapValue -}} return apiClient.getStringMap(path, request);
0 commit comments