Search in sources :

Example 6 with VersionIndexRequireView

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();
}
Also used : InterfaceModel(com.google.api.codegen.config.InterfaceModel) ImmutableList(com.google.common.collect.ImmutableList) GapicInterfaceContext(com.google.api.codegen.transformer.GapicInterfaceContext) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) VersionIndexRequireView(com.google.api.codegen.viewmodel.metadata.VersionIndexRequireView)

Aggregations

VersionIndexRequireView (com.google.api.codegen.viewmodel.metadata.VersionIndexRequireView)6 ImmutableList (com.google.common.collect.ImmutableList)4 InterfaceModel (com.google.api.codegen.config.InterfaceModel)3 GapicInterfaceContext (com.google.api.codegen.transformer.GapicInterfaceContext)3 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)3 InterfaceView (com.google.api.codegen.InterfaceView)2 Interface (com.google.api.tools.framework.model.Interface)2 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)1 ProtoTypeRef (com.google.api.codegen.config.ProtoTypeRef)1 TypeModel (com.google.api.codegen.config.TypeModel)1 Name (com.google.api.codegen.util.Name)1 ApiMethodView (com.google.api.codegen.viewmodel.ApiMethodView)1 ImportSectionView (com.google.api.codegen.viewmodel.ImportSectionView)1 ViewModel (com.google.api.codegen.viewmodel.ViewModel)1 VersionIndexView (com.google.api.codegen.viewmodel.metadata.VersionIndexView)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1