use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class JavaSurfaceTransformer method addRpcStubImports.
private void addRpcStubImports(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.core.BackgroundResourceAggregation");
typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientContext");
typeTable.saveNicknameFor("com.google.api.gax.rpc.UnaryCallable");
typeTable.saveNicknameFor("java.io.IOException");
typeTable.saveNicknameFor("java.util.ArrayList");
typeTable.saveNicknameFor("java.util.List");
typeTable.saveNicknameFor("java.util.Map");
typeTable.saveNicknameFor("java.util.concurrent.TimeUnit");
typeTable.saveNicknameFor("javax.annotation.Generated");
typeTable.saveNicknameFor("com.google.api.gax.rpc.RequestParamsExtractor");
typeTable.saveNicknameFor("com.google.common.collect.ImmutableMap");
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
if (interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingConfig.GrpcStreamingType.BidiStreaming)) {
typeTable.saveNicknameFor("com.google.api.gax.rpc.BidiStreamingCallable");
}
if (interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingConfig.GrpcStreamingType.ServerStreaming)) {
typeTable.saveNicknameFor("com.google.api.gax.rpc.ServerStreamingCallable");
}
if (interfaceConfig.hasGrpcStreamingMethods(GrpcStreamingConfig.GrpcStreamingType.ClientStreaming)) {
typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientStreamingCallable");
}
if (interfaceConfig.hasLongRunningOperations()) {
typeTable.saveNicknameFor("com.google.api.gax.longrunning.OperationSnapshot");
}
switch(context.getProductConfig().getTransportProtocol()) {
case GRPC:
typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcStubCallableFactory");
typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcCallableFactory");
typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcCallSettings");
typeTable.saveNicknameFor("io.grpc.MethodDescriptor");
typeTable.saveNicknameFor("io.grpc.protobuf.ProtoUtils");
if (interfaceConfig.hasLongRunningOperations()) {
typeTable.saveNicknameFor("com.google.longrunning.Operation");
typeTable.saveNicknameFor("com.google.longrunning.stub.GrpcOperationsStub");
}
break;
case HTTP:
typeTable.saveNicknameFor("com.google.api.client.http.HttpMethods");
typeTable.saveNicknameFor("com.google.api.core.InternalApi");
typeTable.saveNicknameFor("com.google.api.pathtemplate.PathTemplate");
typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMessageHttpRequestFormatter");
typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMessageHttpResponseParser");
typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMethodDescriptor");
typeTable.saveNicknameFor("com.google.api.gax.httpjson.HttpJsonCallSettings");
typeTable.saveNicknameFor("com.google.api.gax.httpjson.HttpJsonStubCallableFactory");
typeTable.saveNicknameFor("com.google.common.collect.Sets");
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 = 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(packageMetadataConfig.releaseLevel(TargetLanguage.JAVA)));
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, productConfig, packageMetadataConfig.releaseLevel(TargetLanguage.JAVA)));
return xapiClass.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();
}
Aggregations