use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class NodeJSGapicSurfaceTestTransformer method createSmokeTestViews.
private List<ViewModel> createSmokeTestViews(ApiModel model, GapicProductConfig productConfig) {
ImmutableList.Builder<ViewModel> views = ImmutableList.builder();
for (InterfaceModel apiInterface : model.getInterfaces(productConfig)) {
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface);
if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) {
continue;
}
GapicInterfaceContext context = createContext(apiInterface, productConfig);
views.add(createSmokeTestClassView(context, model.hasMultipleServices()));
}
return views.build();
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class RubyGapicSurfaceDocTransformer method generateTocModuleView.
private TocModuleView generateTocModuleView(ApiModel model, ProtoFile file, ProductConfig productConfig, SurfaceNamer namer, String moduleName) {
RubyPackageMetadataTransformer metadataTransformer = new RubyPackageMetadataTransformer(packageConfig);
RubyPackageMetadataNamer packageNamer = new RubyPackageMetadataNamer(productConfig.getPackageName());
String packageFilePath = file.getFullName().replace(".", File.separator);
ImmutableList.Builder<TocContentView> tocContents = ImmutableList.builder();
for (Interface apiInterface : file.getReachableInterfaces()) {
String description = RubyUtil.getSentence(namer.getDocLines(GapicParser.getDocString(apiInterface)));
InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(new ProtoInterfaceModel(apiInterface));
tocContents.add(metadataTransformer.generateTocContent(description, packageNamer, packageFilePath, namer.getApiWrapperClassName(interfaceConfig)));
}
tocContents.add(metadataTransformer.generateTocContent("Data types for " + productConfig.getPackageName(), packageNamer, packageFilePath, "Data Types"));
return TocModuleView.newBuilder().moduleName(moduleName).fullName(model.getTitle()).contents(tocContents.build()).build();
}
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 generateApiClass.
private StaticLangApiView generateApiClass(InterfaceContext context, GapicProductConfig productConfig) {
SurfaceNamer namer = context.getNamer();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
addApiImports(context);
List<StaticLangApiMethodView> methods = javaApiMethodTransformer.generateApiMethods(context);
StaticLangApiView.Builder xapiClass = StaticLangApiView.newBuilder();
ApiMethodView exampleApiMethod = getExampleApiMethod(methods);
xapiClass.doc(serviceTransformer.generateServiceDoc(context, exampleApiMethod, productConfig));
String name = context.getNamer().getApiWrapperClassName(context.getInterfaceConfig());
xapiClass.releaseLevelAnnotation(namer.getReleaseAnnotation(productConfig.getReleaseLevel()));
xapiClass.name(name);
xapiClass.settingsClassName(namer.getApiSettingsClassName(interfaceConfig));
xapiClass.stubInterfaceName(getAndSaveNicknameForStubType(context, namer.getApiStubInterfaceName(interfaceConfig)));
xapiClass.stubSettingsClassName(getAndSaveNicknameForStubType(context, namer.getApiStubSettingsClassName(interfaceConfig)));
xapiClass.apiCallableMembers(apiCallableTransformer.generateStaticLangApiCallables(context));
xapiClass.pathTemplates(pathTemplateTransformer.generatePathTemplates(context));
xapiClass.formatResourceFunctions(pathTemplateTransformer.generateFormatResourceFunctions(context));
xapiClass.parseResourceFunctions(pathTemplateTransformer.generateParseResourceFunctions(context));
xapiClass.apiMethods(methods);
xapiClass.hasDefaultInstance(interfaceConfig.hasDefaultInstance());
xapiClass.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations());
xapiClass.pagedResponseViews(generatePagedResponseWrappers(context));
return xapiClass.build();
}
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 = javaApiMethodTransformer.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(productConfig.getReleaseLevel()));
stubInterface.name(name);
stubInterface.callableMethods(filterIncludeCallableMethods(methods));
stubInterface.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations());
return stubInterface.build();
}
Aggregations