use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class PathTemplateTransformer method generatePathTemplateGetterFunctions.
public List<PathTemplateGetterFunctionView> generatePathTemplateGetterFunctions(GapicInterfaceContext context) {
List<PathTemplateGetterFunctionView> functions = new ArrayList<>();
SurfaceNamer namer = context.getNamer();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
for (SingleResourceNameConfig resourceNameConfig : getSingleResourceNameConfigsUsedByInterface(context)) {
PathTemplateGetterFunctionView.Builder function = PathTemplateGetterFunctionView.newBuilder().name(namer.getPathTemplateNameGetter(interfaceConfig, resourceNameConfig)).resourceName(namer.getPathTemplateResourcePhraseName(resourceNameConfig)).entityName(namer.getEntityName(resourceNameConfig)).pathTemplateName(namer.getPathTemplateName(interfaceConfig, resourceNameConfig)).pattern(resourceNameConfig.getNamePattern());
functions.add(function.build());
}
return functions;
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class ServiceTransformer method generateServiceDoc.
public ServiceDocView generateServiceDoc(InterfaceContext context, ApiMethodView exampleApiMethod, GapicProductConfig productConfig) {
SurfaceNamer namer = context.getNamer();
ServiceDocView.Builder serviceDoc = ServiceDocView.newBuilder();
ImmutableList.Builder<String> docLines = ImmutableList.builder();
docLines.addAll(namer.getDocLines(context.getInterfaceDescription()));
InterfaceConfig conf = context.getInterfaceConfig();
if (!conf.getManualDoc().isEmpty()) {
docLines.add("");
docLines.addAll(namer.getDocLines(conf.getManualDoc()));
}
List<String> lines = docLines.build();
serviceDoc.lines(lines);
if (lines.isEmpty()) {
serviceDoc.firstLine("");
serviceDoc.remainingLines(ImmutableList.<String>of());
} else {
serviceDoc.firstLine(lines.get(0));
serviceDoc.remainingLines(lines.subList(1, lines.size()));
}
serviceDoc.exampleApiMethod(exampleApiMethod);
serviceDoc.apiVarName(namer.getApiWrapperVariableName(context.getInterfaceConfig()));
serviceDoc.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
serviceDoc.settingsVarName(namer.getApiSettingsVariableName(context.getInterfaceConfig()));
serviceDoc.settingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
serviceDoc.hasDefaultInstance(context.getInterfaceConfig().hasDefaultInstance());
serviceDoc.serviceTitle(context.serviceTitle());
serviceDoc.defaultTransportProviderBuilder(namer.getDefaultTransportProviderBuilder(productConfig.getTransportProtocol()));
serviceDoc.defaultChannelProviderBuilder(namer.getDefaultChannelProviderBuilder(productConfig.getTransportProtocol()));
return serviceDoc.build();
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class JavaSurfaceTransformer method addStubInterfaceImports.
private void addStubInterfaceImports(InterfaceContext context) {
ImportTypeTable typeTable = context.getImportTypeTable();
typeTable.saveNicknameFor("com.google.api.core.BetaApi");
typeTable.saveNicknameFor("com.google.api.gax.core.BackgroundResource");
typeTable.saveNicknameFor("com.google.api.gax.rpc.UnaryCallable");
typeTable.saveNicknameFor("javax.annotation.Generated");
typeTable.saveNicknameFor("java.lang.Void");
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
if (interfaceConfig.hasLongRunningOperations()) {
typeTable.saveNicknameFor("com.google.longrunning.Operation");
typeTable.saveNicknameFor("com.google.longrunning.stub.OperationsStub");
}
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class JavaSurfaceTransformer method addSettingsImports.
private void addSettingsImports(InterfaceContext context) {
ImportTypeTable typeTable = context.getImportTypeTable();
typeTable.saveNicknameFor("com.google.api.core.ApiFunction");
typeTable.saveNicknameFor("com.google.api.core.BetaApi");
typeTable.saveNicknameFor("com.google.api.gax.core.CredentialsProvider");
typeTable.saveNicknameFor("com.google.api.gax.core.ExecutorProvider");
typeTable.saveNicknameFor("com.google.api.gax.core.GaxProperties");
typeTable.saveNicknameFor("com.google.api.gax.core.GoogleCredentialsProvider");
typeTable.saveNicknameFor("com.google.api.gax.core.InstantiatingExecutorProvider");
typeTable.saveNicknameFor("com.google.api.gax.retrying.RetrySettings");
typeTable.saveNicknameFor("com.google.api.gax.rpc.ApiClientHeaderProvider");
typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientContext");
typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientSettings");
typeTable.saveNicknameFor("com.google.api.gax.rpc.StubSettings");
typeTable.saveNicknameFor("com.google.api.gax.rpc.HeaderProvider");
typeTable.saveNicknameFor("com.google.api.gax.rpc.StatusCode");
typeTable.saveNicknameFor("com.google.api.gax.rpc.TransportChannelProvider");
typeTable.saveNicknameFor("com.google.api.gax.rpc.UnaryCallSettings");
typeTable.saveNicknameFor("com.google.auth.Credentials");
typeTable.saveNicknameFor("com.google.common.collect.ImmutableList");
typeTable.saveNicknameFor("com.google.common.collect.ImmutableMap");
typeTable.saveNicknameFor("com.google.common.collect.ImmutableSet");
typeTable.saveNicknameFor("com.google.common.collect.Lists");
typeTable.saveNicknameFor("com.google.common.collect.Sets");
typeTable.saveNicknameFor("java.io.IOException");
typeTable.saveNicknameFor("java.util.List");
typeTable.saveNicknameFor("java.util.concurrent.ScheduledExecutorService");
typeTable.saveNicknameFor("javax.annotation.Generated");
typeTable.saveNicknameFor("org.threeten.bp.Duration");
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
if (interfaceConfig.hasPageStreamingMethods()) {
typeTable.saveNicknameFor("com.google.api.core.ApiFuture");
typeTable.saveNicknameFor("com.google.api.gax.rpc.ApiCallContext");
typeTable.saveNicknameFor("com.google.api.gax.rpc.PageContext");
typeTable.saveNicknameFor("com.google.api.gax.rpc.PagedCallSettings");
typeTable.saveNicknameFor("com.google.api.gax.rpc.PagedListDescriptor");
typeTable.saveNicknameFor("com.google.api.gax.rpc.PagedListResponseFactory");
typeTable.saveNicknameFor("com.google.api.gax.rpc.UnaryCallable");
}
if (interfaceConfig.hasBatchingMethods()) {
typeTable.saveNicknameFor("com.google.api.gax.batching.BatchingSettings");
typeTable.saveNicknameFor("com.google.api.gax.batching.FlowController");
typeTable.saveNicknameFor("com.google.api.gax.batching.FlowController.LimitExceededBehavior");
typeTable.saveNicknameFor("com.google.api.gax.batching.FlowControlSettings");
typeTable.saveNicknameFor("com.google.api.gax.batching.PartitionKey");
typeTable.saveNicknameFor("com.google.api.gax.batching.RequestBuilder");
typeTable.saveNicknameFor("com.google.api.gax.rpc.BatchedRequestIssuer");
typeTable.saveNicknameFor("com.google.api.gax.rpc.BatchingCallSettings");
typeTable.saveNicknameFor("com.google.api.gax.rpc.BatchingDescriptor");
typeTable.saveNicknameFor("java.util.ArrayList");
typeTable.saveNicknameFor("java.util.Collection");
}
if (interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingType.ServerStreaming)) {
typeTable.saveNicknameFor("com.google.api.gax.rpc.ServerStreamingCallSettings");
}
if (interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingType.ClientStreaming) || interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingType.BidiStreaming)) {
typeTable.saveNicknameFor("com.google.api.gax.rpc.StreamingCallSettings");
}
if (interfaceConfig.hasLongRunningOperations()) {
typeTable.saveNicknameFor("com.google.api.gax.longrunning.OperationSnapshot");
typeTable.saveNicknameFor("com.google.api.gax.rpc.OperationCallSettings");
typeTable.saveNicknameFor("com.google.longrunning.Operation");
typeTable.saveNicknameFor("com.google.api.gax.longrunning.OperationTimedPollAlgorithm");
}
switch(context.getProductConfig().getTransportProtocol()) {
case GRPC:
typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcTransportChannel");
typeTable.saveNicknameFor("com.google.api.gax.grpc.InstantiatingGrpcChannelProvider");
if (interfaceConfig.hasLongRunningOperations()) {
typeTable.saveNicknameFor("com.google.api.gax.grpc.ProtoOperationTransformers");
}
typeTable.saveNicknameFor("com.google.api.gax.grpc.GaxGrpcProperties");
break;
case HTTP:
typeTable.saveNicknameFor("com.google.api.gax.httpjson.HttpJsonTransportChannel");
typeTable.saveNicknameFor("com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider");
typeTable.saveNicknameFor("com.google.api.gax.httpjson.GaxHttpJsonProperties");
typeTable.saveNicknameFor("java.lang.Void");
break;
}
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class JavaSurfaceTransformer method generateStubInterface.
private StaticLangStubInterfaceView generateStubInterface(InterfaceContext context, GapicProductConfig productConfig) {
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
addStubInterfaceImports(context);
// Stub class has different default package name from methods classes.
InterfaceContext apiMethodsContext = context.withNewTypeTable(context.getNamer().getRootPackageName());
List<StaticLangApiMethodView> methods = generateApiMethods(apiMethodsContext);
for (TypeAlias alias : apiMethodsContext.getImportTypeTable().getTypeTable().getAllImports().values()) {
context.getImportTypeTable().getAndSaveNicknameFor(alias);
}
StaticLangStubInterfaceView.Builder stubInterface = StaticLangStubInterfaceView.newBuilder();
stubInterface.doc(serviceTransformer.generateServiceDoc(context, null, productConfig));
String name = context.getNamer().getApiStubInterfaceName(context.getInterfaceConfig());
stubInterface.releaseLevelAnnotation(context.getNamer().getReleaseAnnotation(packageMetadataConfig.releaseLevel(TargetLanguage.JAVA)));
stubInterface.name(name);
stubInterface.callableMethods(filterIncludeCallableMethods(methods));
stubInterface.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations());
return stubInterface.build();
}
Aggregations