Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ public static CommentStatement createCallSettingsGetterComment(
isMethodInternal);
}

private static final String RESUMABLE_UPLOAD_CALL_SETTINGS_DOC_NOTE =
"Note that custom retry settings and headers configured via ApiCallContext"
+ " apply strictly to the initial session initiation request.";

public static CommentStatement createResumableUploadCallSettingsGetterComment(
String javaMethodName, boolean isMethodDeprecated, boolean isMethodInternal) {
return createResumableUploadCallSettingsComment(
CALL_SETTINGS_METHOD_DOC_PATTERN, javaMethodName, isMethodDeprecated, isMethodInternal);
}

public static CommentStatement createBuilderClassComment(String outerClassName) {
return toCommentStatement(String.format(BUILDER_CLASS_DOC_PATTERN, outerClassName));
}
Expand All @@ -140,6 +150,30 @@ public static CommentStatement createCallSettingsBuilderGetterComment(
return toCommentStatement(methodComment, isMethodDeprecated, isMethodInternal);
}

public static CommentStatement createResumableUploadCallSettingsBuilderGetterComment(
String javaMethodName, boolean isMethodDeprecated, boolean isMethodInternal) {
return createResumableUploadCallSettingsComment(
CALL_SETTINGS_BUILDER_METHOD_DOC_PATTERN,
javaMethodName,
isMethodDeprecated,
isMethodInternal);
}

private static CommentStatement createResumableUploadCallSettingsComment(
String pattern, String javaMethodName, boolean isMethodDeprecated, boolean isMethodInternal) {
JavaDocComment.Builder docBuilder =
JavaDocComment.builder()
.addComment(String.format(pattern, javaMethodName))
.addParagraph(RESUMABLE_UPLOAD_CALL_SETTINGS_DOC_NOTE);
if (isMethodDeprecated) {
docBuilder.setDeprecated(CommentComposer.DEPRECATED_METHOD_STRING);
}
if (isMethodInternal) {
docBuilder.setInternalOnly(CommentComposer.INTERNAL_ONLY_METHOD_STRING);
}
return CommentStatement.withComment(docBuilder.build());
}

public static List<CommentStatement> createClassHeaderComments(
String configuredClassName,
String defaultHost,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.OperationCallSettings;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.ResumableUploadCallSettings;
import com.google.api.gax.rpc.ServerStreamingCallSettings;
import com.google.api.gax.rpc.StreamingCallSettings;
import com.google.api.gax.rpc.StubSettings;
Expand Down Expand Up @@ -153,7 +154,7 @@ private static List<CommentStatement> createClassHeaderComments(
// list.
List<Method> publicMethods =
service.methods().stream()
.filter(m -> m.isInternalApi() == false)
.filter(m -> !m.isInternalApi() && !m.isResumableUpload())
.collect(Collectors.toList());
Optional<Method> methodOpt =
publicMethods.isEmpty()
Expand Down Expand Up @@ -311,12 +312,18 @@ private static List<MethodDefinition> createSettingsGetterMethods(
// Add method header comment statements and annotations.
private static MethodDefinition methodBuilderHelper(
Method protoMethod, MethodDefinition.Builder methodBuilder, String javaMethodName) {
return methodBuilder
.setHeaderCommentStatements(
SettingsCommentComposer.createCallSettingsGetterComment(
CommentStatement commentStatement =
protoMethod.isResumableUpload()
? SettingsCommentComposer.createResumableUploadCallSettingsGetterComment(
getMethodNameFromSettingsVarName(javaMethodName),
protoMethod.isDeprecated(),
protoMethod.isInternalApi())
: SettingsCommentComposer.createCallSettingsGetterComment(
getMethodNameFromSettingsVarName(javaMethodName),
protoMethod.isDeprecated(),
protoMethod.isInternalApi()))
protoMethod.isInternalApi());
return methodBuilder
.setHeaderCommentStatements(commentStatement)
.setAnnotations(createMethodAnnotations(protoMethod))
.build();
}
Expand Down Expand Up @@ -794,13 +801,19 @@ private static List<MethodDefinition> createNestedBuilderSettingsGetterMethods(
String javaMethodName = String.format("%sSettings", javaStyleName);
MethodDefinition.Builder methodBuilder =
methodMakerFn.apply(getCallSettingsBuilderType(protoMethod, typeStore), javaMethodName);
CommentStatement commentStatement =
protoMethod.isResumableUpload()
? SettingsCommentComposer.createResumableUploadCallSettingsBuilderGetterComment(
getMethodNameFromSettingsVarName(javaMethodName),
protoMethod.isDeprecated(),
protoMethod.isInternalApi())
: SettingsCommentComposer.createCallSettingsBuilderGetterComment(
getMethodNameFromSettingsVarName(javaMethodName),
protoMethod.isDeprecated(),
protoMethod.isInternalApi());
javaMethods.add(
methodBuilder
.setHeaderCommentStatements(
SettingsCommentComposer.createCallSettingsBuilderGetterComment(
getMethodNameFromSettingsVarName(javaMethodName),
protoMethod.isDeprecated(),
protoMethod.isInternalApi()))
.setHeaderCommentStatements(commentStatement)
.setAnnotations(createMethodAnnotations(protoMethod))
.build());

Expand Down Expand Up @@ -856,6 +869,7 @@ private static TypeStore createStaticTypes() {
Operation.class,
OperationCallSettings.class,
PagedCallSettings.class,
ResumableUploadCallSettings.class,
ServerStreamingCallSettings.class,
StreamingCallSettings.class,
StubSettings.class,
Expand Down Expand Up @@ -933,7 +947,13 @@ private static TypeNode getCallSettingsTypeHelper(
Method protoMethod, TypeStore typeStore, boolean isBuilder) {
Class<?> callSettingsClazz =
isBuilder ? UnaryCallSettings.Builder.class : UnaryCallSettings.class;
if (protoMethod.isPaged()) {
if (protoMethod.isResumableUpload()) {
return TypeNode.withReference(
ConcreteReference.withClazz(
isBuilder
? ResumableUploadCallSettings.Builder.class
: ResumableUploadCallSettings.class));
} else if (protoMethod.isPaged()) {
callSettingsClazz = isBuilder ? PagedCallSettings.Builder.class : PagedCallSettings.class;
} else if (protoMethod.isBatching()) {
callSettingsClazz =
Expand Down
Loading
Loading