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 @@ -29,10 +29,12 @@
import com.google.api.generator.gapic.composer.grpcrest.HttpJsonServiceClientTestClassComposer;
import com.google.api.generator.gapic.composer.resourcename.ResourceNameHelperClassComposer;
import com.google.api.generator.gapic.composer.rest.HttpJsonServiceCallableFactoryClassComposer;
import com.google.api.generator.gapic.composer.rest.HttpJsonServiceResumableUploadStubClassComposer;
import com.google.api.generator.gapic.composer.rest.HttpJsonServiceStubClassComposer;
import com.google.api.generator.gapic.model.GapicClass;
import com.google.api.generator.gapic.model.GapicContext;
import com.google.api.generator.gapic.model.GapicPackageInfo;
import com.google.api.generator.gapic.model.Method;
import com.google.api.generator.gapic.model.ReflectConfig;
import com.google.api.generator.gapic.model.Sample;
import com.google.api.generator.gapic.model.Service;
Expand Down Expand Up @@ -91,6 +93,11 @@ public static List<GapicClass> generateStubClasses(GapicContext context) {
.services()
.forEach(
s -> {
if (s.methods().stream().anyMatch(Method::isResumableUpload)) {
clazzes.add(
HttpJsonServiceResumableUploadStubClassComposer.instance()
.generate(context, s));
}
if (context.transport() == Transport.REST) {
clazzes.add(
com.google.api.generator.gapic.composer.rest.ServiceStubClassComposer.instance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.api.gax.rpc.ClientStreamingCallable;
import com.google.api.gax.rpc.LongRunningClient;
import com.google.api.gax.rpc.OperationCallable;
import com.google.api.gax.rpc.ResumableUploadCallable;
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.api.generator.engine.ast.AnnotationNode;
Expand Down Expand Up @@ -52,6 +53,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;

Check warning on line 56 in sdk-platform-java/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubClassComposer.java

View check run for this annotation

SonarQubeCloud / [gapic-generator-java-root] SonarCloud Code Analysis

Remove this unused import 'java.util.Optional'.

See more on https://sonarcloud.io/project/issues?id=googleapis_google-cloud-java_generator&issues=AaCnZ_KB28Z-8FkMEIHj&open=AaCnZ_KB28Z-8FkMEIHj&pullRequest=14322
import java.util.stream.Collectors;
import javax.annotation.Generated;
import org.jspecify.annotations.NullMarked;
Expand Down Expand Up @@ -162,22 +164,7 @@

private MethodDefinition createCallableGetterHelper(
Method method, TypeStore typeStore, boolean isLroCallable, boolean isPaged) {
TypeNode returnType;
switch (method.stream()) {
case CLIENT:
returnType = typeStore.get("ClientStreamingCallable");
break;
case SERVER:
returnType = typeStore.get("ServerStreamingCallable");
break;
case BIDI:
returnType = typeStore.get("BidiStreamingCallable");
break;
case NONE:
// Fall through.
default:
returnType = typeStore.get(isLroCallable ? "OperationCallable" : "UnaryCallable");
}
TypeNode returnType = getCallableType(method, typeStore, isLroCallable);

String methodName =
String.format(
Expand Down Expand Up @@ -270,6 +257,7 @@
Generated.class,
Operation.class,
OperationCallable.class,
ResumableUploadCallable.class,
ServerStreamingCallable.class,
UnaryCallable.class,
UnsupportedOperationException.class,
Expand Down Expand Up @@ -328,4 +316,22 @@
.build())))
.build();
}

private static TypeNode getCallableType(
Method method, TypeStore typeStore, boolean isLroCallable) {
if (method.isResumableUpload()) {
return typeStore.get("ResumableUploadCallable");
}
switch (method.stream()) {
case CLIENT:
return typeStore.get("ClientStreamingCallable");
case SERVER:
return typeStore.get("ServerStreamingCallable");
case BIDI:
return typeStore.get("BidiStreamingCallable");
case NONE:
default:
return typeStore.get(isLroCallable ? "OperationCallable" : "UnaryCallable");
}
}
}
Loading
Loading