-
Notifications
You must be signed in to change notification settings - Fork 702
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 #2462
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
519ca65
feat: Add ApiVersion Support
lqiu96 b25b5ed
feat: Update tests
lqiu96 906a09e
chore: Update test cases
lqiu96 da170db
chore: Fix lint issues
lqiu96 5ee91bd
chore: Change constant access to protected
lqiu96 1ac3ae8
doc: Add comment for the constant
lqiu96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
import com.google.api.client.http.HttpHeaders; | ||
import com.google.api.client.http.UriTemplate; | ||
import com.google.api.client.util.Beta; | ||
import com.google.common.base.Strings; | ||
|
||
/** | ||
* {@link Beta} <br> | ||
|
@@ -46,7 +47,32 @@ public MockGoogleClientRequest( | |
String uriTemplate, | ||
HttpContent content, | ||
Class<T> responseClass) { | ||
this(client, method, uriTemplate, content, responseClass, null); | ||
} | ||
|
||
/** | ||
* @param client Google client | ||
* @param method HTTP Method | ||
* @param uriTemplate URI template for the path relative to the base URL. If it starts with a "/" | ||
* the base path from the base URL will be stripped out. The URI template can also be a full | ||
* URL. URI template expansion is done using {@link UriTemplate#expand(String, String, Object, | ||
* boolean)} | ||
* @param content HTTP content or {@code null} for none | ||
* @param responseClass response class to parse into | ||
* @param apiVersion ApiVersion to be passed to the header | ||
*/ | ||
public MockGoogleClientRequest( | ||
AbstractGoogleClient client, | ||
String method, | ||
String uriTemplate, | ||
HttpContent content, | ||
Class<T> responseClass, | ||
String apiVersion) { | ||
super(client, method, uriTemplate, content, responseClass); | ||
// Matches generator code: Null or Empty String is not set to the header | ||
if (!Strings.isNullOrEmpty(apiVersion)) { | ||
getRequestHeaders().set(API_VERSION_HEADER, apiVersion); | ||
} | ||
Comment on lines
+53
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a constructor with new ApiVersion param. This allows us to mimic the behavior where the generated clients pass the apiVersion to the AbstractGoogleClientRequest class. |
||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
protected access as this will be used in the generated client classes.
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.
Can you add that (the generated code uses this field to set the header) in the source code comment?
Also if there's any public document available for API versions in https://google.aip.dev, reference it from here.