-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add ApiVersion support #20930
feat: Add ApiVersion support #20930
Conversation
…ervices into add-apiversion-support
…-api-java-client-services into add-apiversion-support
com.google.api.client.http.HttpHeaders headers = getRequestHeaders(); | ||
if (headers.get(API_VERSION_HEADER) == null) { | ||
headers.set(API_VERSION_HEADER, API_VERSION); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the ApiVersion header has already been set, do not override with the version. This is possible in two different ways:
- Using the AbstractRequest's
setRequestHeader()
: https://github.com/googleapis/google-api-java-client/blob/fbbc37446b2a34b03ca5401bbe9ca038ff087972/google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java#L317-L319 - From a few handwritten Apiary wrapped libraries (i.e. Storage and Bigquery) as Java-Core provides an option to set a HeaderProvider via ServiceOptions: https://github.com/googleapis/sdk-platform-java/blob/e1e1fb66d95adc08baea71c5a0607c20d5a57a8b/java-core/google-cloud-core/src/main/java/com/google/cloud/ServiceOptions.java#L281-L303
Customers can technically set the X-Goog-Api-Version
header themselves via the two options above and this implementation will respect those custom values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Can you record that as source code comment at line 145?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, will add a small comment about not override user set value
Generator changes that depends on Google-Api-Java-Client changes in googleapis/google-api-java-client#2462
Example of the generated code: