-
Notifications
You must be signed in to change notification settings - Fork 68
feat: Selective gapic generation phase II #3730
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
Conversation
test/integration/goldens/iam/src/com/google/iam/v1/IAMPolicyClient.java
Outdated
Show resolved
Hide resolved
/gcbrun |
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.
Looks good to me so far. Left a few small comments and I will take another pass.
gapic-generator-java/src/test/resources/selective_api_generation_generate_omitted_v1beta1.yaml
Outdated
Show resolved
Hide resolved
.../goldens/samples/echoserviceselectivegapicclient/AsyncChatAgainShouldGenerateAsPublic.golden
Show resolved
Hide resolved
...va/com/google/api/generator/gapic/composer/samplecode/ServiceClientHeaderSampleComposer.java
Show resolved
Hide resolved
gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java
Outdated
Show resolved
Hide resolved
gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/ComposerTest.java
Outdated
Show resolved
Hide resolved
.../com/google/api/generator/gapic/composer/grpc/goldens/EchoServiceSelectiveGapicClient.golden
Outdated
Show resolved
Hide resolved
Service service = context.services().get(1); | ||
GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, service); | ||
|
||
Assert.assertGoldenClass(this.getClass(), clazz, "SelectiveGapicStub.golden"); |
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.
I don't see any @InternalApi
in the golden file for this test. Is this test necessary?
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.
Yeah this should not impact the stubclass. I have removed the test and the golden file.
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.
Am I missing it or there is only test setup to verify -Client changes, but not -Stub, -StubSettings or -ClientSettings ?
For example, in below snippet of golden file, I expect chatShouldGenerateAsInternalCallable()
also be marked as internal, and I believe changes in AbstractServiceStubClassComposer.java should do it. Do you have any test coverages for it?
Lines 568 to 571 in a87d3b0
@InternalApi("Internal API. This API is not intended for public consumption.") | |
public final UnaryCallable<EchoRequest, EchoResponse> chatShouldGenerateAsInternalCallable() { | |
return stub.chatShouldGenerateAsInternalCallable(); | |
} |
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.
No I didn't add those tests earlier. I just updated the test files to include coverage for service settings, stub and stub settings. Please take a look:)
gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java
Outdated
Show resolved
Hide resolved
...a/src/main/java/com/google/api/generator/gapic/composer/comment/SettingsCommentComposer.java
Outdated
Show resolved
Hide resolved
@@ -140,6 +141,8 @@ public abstract class AbstractServiceStubSettingsClassComposer implements ClassC | |||
private static final String SETTINGS_LITERAL = "Settings"; | |||
|
|||
private static final String DOT = "."; | |||
private static final String INTERNAL_API_WARNING = |
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.
nit: perhaps extract INTERNAL_API_WARNING to a somewhere to be accessible for each of these composes.
Implement Selective GAPIC Generation (Phase II)
This PR implements Phase II of selective GAPIC generation within the
gapic-generator-java
project. This allows for finer control over the intended usage of generated client methods (public, internal, or hidden) by providing selective gapic generation configuration in service yaml.Key Changes:
1. Model Updates
isInternalApi
attribute to the internal representation of methods to track their intended visibility (e.g., public, internal).2. Parser Logic
getMethodSelectiveGapicType()
method responsible for parsing the selective generation configuration for each method.HIDDEN
.parseService()
to determine and assign the appropriateSelectiveGapicType
to each service method and its corresponding generated variants (e.g., overloaded methods).3. Composer (Code Generation) Updates
INTERNAL
, generate an@InternalApi
annotation accompanied by a warning message discouraging external use.INTERNAL
, generate a specific comment in the method's header indicating its intended internal-only usage.package-info.java
samples to prevent the usage of any methods marked asINTERNAL
.4. Tests
INTERNAL
, and/orHIDDEN
methods.