-
Notifications
You must be signed in to change notification settings - Fork 53
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
fix: Check additional_binding's custom FieldsExtractor #1565
Conversation
...ava/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ProtoMessageRequestFormatter.java
Show resolved
Hide resolved
private ProtoMessageRequestFormatter( | ||
FieldsExtractor<RequestT, String> requestBodyExtractor, | ||
FieldsExtractor<RequestT, Map<String, List<String>>> queryParamsExtractor, | ||
String rawPath, | ||
PathTemplate pathTemplate, | ||
FieldsExtractor<RequestT, Map<String, String>> pathVarsExtractor, | ||
List<String> additionalRawPaths, | ||
List<PathTemplate> additionalPathTemplates) { | ||
Map<PathTemplate, FieldsExtractor<RequestT, Map<String, String>>> | ||
additionalPathsExtractorMap) { |
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.
This is a private constructor which should give us some flexibility to update the parameters.
private final FieldsExtractor<ListOperationsRequest, Map<String, String>> | ||
LRO_LIST_PATH_EXTRACTOR = | ||
request -> { | ||
Map<String, String> fields = new HashMap<>(); | ||
ProtoRestSerializer<ListOperationsRequest> serializer = ProtoRestSerializer.create(); | ||
serializer.putPathParam(fields, "name", request.getName()); | ||
return fields; | ||
}; | ||
private final FieldsExtractor<GetOperationRequest, Map<String, String>> LRO_GET_PATH_EXTRACTOR = | ||
request -> { | ||
Map<String, String> fields = new HashMap<>(); | ||
ProtoRestSerializer<GetOperationRequest> serializer = ProtoRestSerializer.create(); | ||
serializer.putPathParam(fields, "name", request.getName()); | ||
return fields; | ||
}; | ||
|
||
private final FieldsExtractor<DeleteOperationRequest, Map<String, String>> | ||
LRO_DELETE_PATH_EXTRACTOR = | ||
request -> { | ||
Map<String, String> fields = new HashMap<>(); | ||
ProtoRestSerializer<DeleteOperationRequest> serializer = ProtoRestSerializer.create(); | ||
serializer.putPathParam(fields, "name", request.getName()); | ||
return fields; | ||
}; | ||
|
||
private final FieldsExtractor<CancelOperationRequest, Map<String, String>> | ||
LRO_CANCEL_PATH_EXTRACTOR = | ||
request -> { | ||
Map<String, String> fields = new HashMap<>(); | ||
ProtoRestSerializer<CancelOperationRequest> serializer = ProtoRestSerializer.create(); | ||
serializer.putPathParam(fields, "name", request.getName()); | ||
return fields; | ||
}; |
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.
OperationsStub has a default FieldsExtractor for each RPC (difference being that the request type for each FieldsExtractor is different). Each request type in the proto file has the name
field, so we should be able to the default FieldsExtractor even for custom paths: https://github.com/googleapis/googleapis/blob/d5a51f6baba66f5dde236211d41d66efa1e4e7ca/google/longrunning/operations.proto#L171
.setAdditionalPathsExtractorMap( | ||
ImmutableMap | ||
.<PathTemplate, FieldsExtractor<Field, Map<String, String>>>builder() | ||
.put( | ||
PathTemplate.create("/fake/v1/name/{name=john/*}"), | ||
request -> { | ||
Map<String, String> fields = new HashMap<>(); | ||
ProtoRestSerializer<Field> serializer = | ||
ProtoRestSerializer.create(); | ||
serializer.putPathParam(fields, "name", request.getName()); | ||
return fields; | ||
}) | ||
.build()) |
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.
The test cases use john/imTheBestField
so they match against the additionalPathExtractor()
[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed! |
[java_showcase_integration_tests] SonarCloud Quality Gate failed. |
[java_showcase_unit_tests] SonarCloud Quality Gate failed. |
.setAdditionalBindings( | ||
httpRule.getAdditionalBindingsList().stream() | ||
.map(x -> parseHttpRuleHelper(x, inputMessageOpt, messageTypes)) | ||
.collect(Collectors.toList())) |
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.
setAdditionalPatterns
above just gets the HttpVerb associated with the additional_bindings
list. setAdditionalBindings
recursively calls this function to get the nested additional_bindings
.
Error:
Seems to be due to the breaking changes from this PR (updating |
[gapic-generator-java-root] SonarCloud Quality Gate failed. |
[java_showcase_integration_tests] SonarCloud Quality Gate failed. |
[java_showcase_unit_tests] SonarCloud Quality Gate failed. |
Closing this issue for now. Will re-open if there is a need for this fix. |
Thank you for opening a Pull Request! For general contributing guidelines, please refer to contributing guide
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #1440 ☕️
This Part 2 of the fix. Part 1 was resolved here: #1440