Skip to content
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 callable getters for non-eligible or non-enabled REST methods #1211

Merged
merged 18 commits into from
Jan 10, 2023

Conversation

lqiu96
Copy link
Contributor

@lqiu96 lqiu96 commented Jan 4, 2023

This is a PR for Part 1 of #1117 (Override method with clearer exception messages for non-eligible and non-enabled Service RPCs). Opening this while I look at other possible approaches:

Other approaches looked at/ to revisit:

  • Override createCallableClassMembers to return Map<String, Expr> (Return either VariableExpr or ThrowExpr)
  • Create a duplicate createCallableClassMembers (i.e. createInvalidCallableClassMembers) that copies functionality of createCallableClassMembers but returns Map<String, ThrowExpr>

Both approaches above had an issue when setting the return type for the callableGetter. ThrowExpr's type is always set as UnsupportedOperationException but the MethodDefinition's return type is not (i.e. for Streams it would be ServerStreamCallable or ClientStreamCallable/ Unary is UnaryCallable vs. Operation, etc.). Would need potentially need another mapping between callableName and method return type for ThrowExprs.

This PR's implementation is copied from: https://github.com/googleapis/gapic-generator-java/blob/8c5e17ba325b7711f9ba9501992ab48e736ffc18/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubClassComposer.java#L284-L302

  • Use getCallableType(protoMethod) to get the correct return type for the RPC
  • ThrowExpr's return type is set to UnsupportedOperationException

@lqiu96 lqiu96 force-pushed the main-rest_method_generation branch from 00dedbd to 44e7580 Compare January 6, 2023 20:04
@lqiu96 lqiu96 added the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 6, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jan 6, 2023
@lqiu96 lqiu96 marked this pull request as ready for review January 6, 2023 20:21
@lqiu96 lqiu96 requested a review from a team as a code owner January 6, 2023 20:21
@lqiu96
Copy link
Contributor Author

lqiu96 commented Jan 6, 2023

@blakeli0 Can you take another look whenever you get a chance?

@lqiu96
Copy link
Contributor Author

lqiu96 commented Jan 10, 2023

PR comments resolved. Updated message to Not implemented: {callableName}(). REST transport is not implemented for this method yet.. Adding automerge for this PR

@lqiu96 lqiu96 added the automerge Merge the pull request once unit tests and other checks pass. label Jan 10, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jan 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@gcf-merge-on-green gcf-merge-on-green bot merged commit 84a1355 into main Jan 10, 2023
@gcf-merge-on-green gcf-merge-on-green bot deleted the main-rest_method_generation branch January 10, 2023 20:54
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants