use of com.google.api.codegen.viewmodel.metadata.VersionIndexRequireView in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateTopLevelIndexView.
private ViewModel generateTopLevelIndexView(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
ImmutableList.Builder<VersionIndexRequireView> requireViews = ImmutableList.builder();
List<String> modules = namer.getTopLevelApiModules();
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = createContext(apiInterface, productConfig);
String clientName = namer.getPackageName();
String serviceName = namer.getPackageServiceName(context.getInterfaceConfig());
if (model.hasMultipleServices()) {
clientName += "::" + serviceName;
}
String topLevelNamespace = namer.getTopLevelNamespace();
requireViews.add(VersionIndexRequireView.newBuilder().clientName(clientName).serviceName(serviceName).fileName(versionPackagePath(namer)).topLevelNamespace(topLevelNamespace).doc(serviceTransformer.generateServiceDoc(context, generateApiMethods(context).get(0), productConfig)).build());
}
String versionFileBasePath = namer.packageFilePathPiece(Name.upperCamel(modules.get(modules.size() - 1)));
return VersionIndexView.newBuilder().apiVersion(packageConfig.apiVersion()).requireViews(requireViews.build()).templateFileName(VERSION_INDEX_TEMPLATE_FILE).packageVersion(packageConfig.generatedPackageVersionBound(TargetLanguage.RUBY).lower()).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer)).outputPath("lib" + File.separator + topLevelPackagePath(namer) + ".rb").modules(generateModuleViews(model, productConfig, false)).type(VersionIndexType.TopLevelIndex).versionFileBasePath(versionFileBasePath).toolkitVersion(GeneratorVersionProvider.getGeneratorVersion()).build();
}
Aggregations