You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 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
* Added a `isInternalApi` attribute to the internal representation of
methods to track their intended visibility (e.g., public, internal).
#### 2. Parser Logic
* Introduced the `getMethodSelectiveGapicType()` method responsible for
parsing the selective generation configuration for each method.
* Modified service filtering logic: Service classes will not be
generated if the service definition contains no methods or includes only
methods marked as **`HIDDEN`**.
* Enhanced `parseService()` to determine and assign the appropriate
`SelectiveGapicType` to each service method and its corresponding
generated variants (e.g., overloaded methods).
#### 3. Composer (Code Generation) Updates
* **Method Annotations:** For all method variants designated as
`INTERNAL`, generate an `@InternalApi` annotation accompanied by a
warning message discouraging external use.
* **Method Header Comments:** For methods marked as `INTERNAL`, generate
a specific comment in the method's header indicating its intended
internal-only usage.
* **Sample Generation:** Adjusted the logic for generating
`package-info.java` samples to prevent the usage of any methods marked
as `INTERNAL`.
#### 4. Tests
* Added **unit tests** covering the new parser logic and comment
generation changes related to selective generation types.
* Added/updated **golden unit/integration tests** to verify the correct
code output for various selective generation scenarios, including
services with:
* All public methods.
* A mix of public, `INTERNAL`, and/or `HIDDEN` methods.
* No public methods (verifying that the service class is not generated).
Copy file name to clipboardExpand all lines: gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/ServiceClientCommentComposer.java
+8
Original file line number
Diff line number
Diff line change
@@ -202,6 +202,10 @@ public static List<CommentStatement> createRpcMethodHeaderComment(
Copy file name to clipboardExpand all lines: gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/SettingsCommentComposer.java
+35-30
Original file line number
Diff line number
Diff line change
@@ -59,31 +59,31 @@ public class SettingsCommentComposer {
59
59
"Retries are configured for idempotent methods but not for non-idempotent methods.";
Copy file name to clipboardExpand all lines: gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceClientClassComposer.java
Copy file name to clipboardExpand all lines: gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceClientTestClassComposer.java
0 commit comments