Skip to content

feat(generator): add model flag and allowlist parser for resumable upload RPCs - #14317

Draft
whowes wants to merge 5 commits into
whowes/resumable-upload-settingsfrom
whowes/generator-allowlist-parser
Draft

feat(generator): add model flag and allowlist parser for resumable upload RPCs#14317
whowes wants to merge 5 commits into
whowes/resumable-upload-settingsfrom
whowes/generator-allowlist-parser

Conversation

@whowes

@whowes whowes commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Adds the isResumableUpload() property to the generator's Method model and wires pattern matching in Parser.java against an initially empty allowlist. The showcase test proto is also added with a hermetic test adapter to enable isolated unit testing across subsequent composers.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for identifying resumable upload methods in the GAPIC generator by adding an isResumableUpload property to the Method model and updating the Parser to match RPC names against an allowlist. The review feedback suggests populating the RESUMABLE_UPLOAD_ALLOWLIST_PATTERNS with the showcase service's pattern to make the parser logic functional and testable, which would also allow the removal of a manual workaround in TestProtoLoader and enable a proper assertion in ParserTest.

Comment on lines +139 to +140
private static final ImmutableList<Pattern> RESUMABLE_UPLOAD_ALLOWLIST_PATTERNS =
ImmutableList.of();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The RESUMABLE_UPLOAD_ALLOWLIST_PATTERNS list is currently empty, which means no RPCs will ever be identified as resumable uploads by the parser. To make this functional and testable, we should add the showcase service's pattern to this list. This also allows us to write a proper assertion in ParserTest and avoid the manual workaround in TestProtoLoader.

Suggested change
private static final ImmutableList<Pattern> RESUMABLE_UPLOAD_ALLOWLIST_PATTERNS =
ImmutableList.of();
private static final ImmutableList<Pattern> RESUMABLE_UPLOAD_ALLOWLIST_PATTERNS =
ImmutableList.of(
Pattern.compile("google\\.showcase\\.v1beta1\\.ResumableUploadService\\.UploadMedia"));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This omission is intentional - allowlist will be populated when all composers are complete, unit tests use a different mechanism to enable for now.

Comment on lines +229 to +231
Method uploadMethod = methods.get(0);
assertEquals("UploadMedia", uploadMethod.name());
assertFalse(uploadMethod.isResumableUpload());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since we added the showcase pattern to the allowlist, we can now assert that isResumableUpload() is indeed true for the UploadMedia method, which properly tests the parser's allowlist matching logic.

Suggested change
Method uploadMethod = methods.get(0);
assertEquals("UploadMedia", uploadMethod.name());
assertFalse(uploadMethod.isResumableUpload());
Method uploadMethod = methods.get(0);
assertEquals("UploadMedia", uploadMethod.name());
assertTrue(uploadMethod.isResumableUpload());

Comment on lines +294 to +319
return GapicContext.builder()
.setMessages(messageTypes)
.setResourceNames(resourceNames)
.setServices(adaptShowcaseResumableUploadForTest(services))
.setHelperResourceNames(outputResourceNames)
.setTransport(transport)
.setServiceConfig(GapicServiceConfig.create(Optional.empty()))
.build();
}

private static List<Service> adaptShowcaseResumableUploadForTest(List<Service> services) {
return services.stream()
.map(
s ->
s.toBuilder()
.setMethods(
s.methods().stream()
.map(
m ->
m.name().equals("UploadMedia")
? m.toBuilder().setIsResumableUpload(true).build()
: m)
.collect(Collectors.toList()))
.build())
.collect(Collectors.toList());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

With the showcase pattern added to the parser's allowlist, the parser will automatically identify UploadMedia as a resumable upload. Therefore, the manual workaround adaptShowcaseResumableUploadForTest is no longer needed and can be removed entirely.

Suggested change
return GapicContext.builder()
.setMessages(messageTypes)
.setResourceNames(resourceNames)
.setServices(adaptShowcaseResumableUploadForTest(services))
.setHelperResourceNames(outputResourceNames)
.setTransport(transport)
.setServiceConfig(GapicServiceConfig.create(Optional.empty()))
.build();
}
private static List<Service> adaptShowcaseResumableUploadForTest(List<Service> services) {
return services.stream()
.map(
s ->
s.toBuilder()
.setMethods(
s.methods().stream()
.map(
m ->
m.name().equals("UploadMedia")
? m.toBuilder().setIsResumableUpload(true).build()
: m)
.collect(Collectors.toList()))
.build())
.collect(Collectors.toList());
}
return GapicContext.builder()
.setMessages(messageTypes)
.setResourceNames(resourceNames)
.setServices(services)
.setHelperResourceNames(outputResourceNames)
.setTransport(transport)
.setServiceConfig(GapicServiceConfig.create(Optional.empty()))
.build();
}

@whowes
whowes added this pull request to stack #14327 September 9, 2026 06:35
@whowes
whowes force-pushed the whowes/generator-allowlist-parser branch from e7acfcd to aa32171 Compare September 9, 2026 15:50
@whowes
whowes force-pushed the whowes/generator-allowlist-parser branch from aa32171 to 681c369 Compare September 9, 2026 20:16
@whowes
whowes removed this pull request from stack #14327 September 9, 2026 23:45
@whowes
whowes added this pull request to stack #14343 September 9, 2026 23:47
… ResumableUploadCallable

Add 2-, 3-, and 4-argument overloads to ResumableUploadCallable for
futureCall and resumeCall, supporting:
1. Default context and settings (used by generated ServiceClient convenience methods).
2. Per-request ApiCallContext overrides for transport metadata (extra headers, credentials).
3. Per-request ResumableUploadCallSettings overrides for state-machine knobs.
4. Full method accepting both call context and settings overrides.

ResumableUploadCallableImpl performs a 3-tier precedence merge on settings
and merges ApiCallContext.
…tings

Add globalTimeout configuration to ResumableUploadCallSettings, defaulting to 1 hour,
with java.time.Duration and obsolete ThreeTenBp setters, and precedence merge support.
@whowes
whowes force-pushed the whowes/generator-allowlist-parser branch from 681c369 to dbc1403 Compare September 10, 2026 01:15
@whowes
whowes force-pushed the whowes/generator-allowlist-parser branch from dbc1403 to c7dc7e4 Compare September 10, 2026 06:04
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant