use of com.google.api.codegen.transformer.ModelTypeTable in project toolkit by googleapis.
the class NodeJSGapicSurfaceTestTransformer method generateTestView.
private MockCombinedView generateTestView(ApiModel model, GapicProductConfig productConfig, SurfaceNamer namer) {
ModelTypeTable typeTable = createTypeTable(productConfig);
List<MockServiceImplView> impls = new ArrayList<>();
List<ClientTestClassView> testClasses = new ArrayList<>();
for (InterfaceModel apiInterface : mockServiceTransformer.getGrpcInterfacesToMock(model, productConfig)) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, typeTable, namer, featureConfig);
impls.add(MockServiceImplView.newBuilder().mockGrpcClassName(namer.getGrpcServerTypeName(context.getInterfaceModel())).name(namer.getMockGrpcServiceImplName(apiInterface)).grpcMethods(mockServiceTransformer.createMockGrpcMethodViews(context)).build());
}
for (InterfaceModel apiInterface : model.getInterfaces()) {
// We don't need any imports here.
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, createTypeTable(productConfig), namer, featureConfig);
testClasses.add(ClientTestClassView.newBuilder().apiSettingsClassName(namer.getNotImplementedString("NodeJSGapicSurfaceTestTransformer.generateTestView - apiSettingsClassName")).apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig())).name(namer.getNotImplementedString("NodeJSGapicSurfaceTestTransformer.generateTestView - name")).testCases(createTestCaseViews(context)).apiHasLongRunningMethods(context.getInterfaceConfig().hasLongRunningOperations()).packageServiceName(namer.getPackageServiceName(context.getInterfaceConfig())).missingDefaultServiceAddress(!context.getInterfaceConfig().hasDefaultServiceAddress()).missingDefaultServiceScopes(!context.getInterfaceConfig().hasDefaultServiceScopes()).mockServices(Collections.<MockServiceUsageView>emptyList()).build());
}
ImportSectionView importSection = importSectionTransformer.generateImportSection(typeTable.getImports(), null);
return MockCombinedView.newBuilder().outputPath(testCaseOutputFile(namer)).serviceImpls(impls).mockServices(new ArrayList<MockServiceUsageView>()).testClasses(testClasses).localPackageName(namer.getLocalPackageName()).templateFileName(TEST_TEMPLATE_FILE).packageHasMultipleServices(model.hasMultipleServices()).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, importSection, namer)).build();
}
use of com.google.api.codegen.transformer.ModelTypeTable in project toolkit by googleapis.
the class PythonGapicSurfaceTransformer method generateServiceSurfaces.
private Iterable<ViewModel> generateServiceSurfaces(Model model, GapicProductConfig productConfig) {
ModelTypeTable modelTypeTable = new ModelTypeTable(new PythonTypeTable(productConfig.getPackageName()), new PythonModelTypeNameConverter(productConfig.getPackageName()));
SurfaceNamer namer = new PythonSurfaceNamer(productConfig.getPackageName());
FeatureConfig featureConfig = new DefaultFeatureConfig();
ProtoApiModel apiModel = new ProtoApiModel(model);
ImmutableList.Builder<ViewModel> serviceSurfaces = ImmutableList.builder();
for (InterfaceModel apiInterface : apiModel.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, modelTypeTable, namer, featureConfig);
addApiImports(context);
serviceSurfaces.add(generateApiClass(context));
}
GrpcDocView enumFile = generateEnumView(productConfig, modelTypeTable, namer, model.getFiles());
if (!enumFile.elementDocs().isEmpty()) {
serviceSurfaces.add(enumFile);
}
return serviceSurfaces.build();
}
use of com.google.api.codegen.transformer.ModelTypeTable in project toolkit by googleapis.
the class PythonImportSectionTransformer method generateTypesProtoImports.
private List<ImportFileView> generateTypesProtoImports(Model model, GapicProductConfig productConfig) {
ModelTypeTable typeTable = emptyTypeTable(productConfig);
Set<ImportFileView> imports = new TreeSet<>(importFileViewComparator());
// Save proto file import names to the type table for disambiguation.
List<ProtoFile> protoFileDependencies = model.getFiles();
populateTypeTable(protoFileDependencies, typeTable);
// Get disambiguated imports.
for (Map.Entry<String, TypeAlias> entry : typeTable.getImports().entrySet()) {
imports.add(generateAppImport(entry.getKey(), entry.getValue().getNickname()));
}
return ImmutableList.<ImportFileView>builder().addAll(imports).build();
}
use of com.google.api.codegen.transformer.ModelTypeTable in project toolkit by googleapis.
the class RubyGapicSurfaceDocTransformer method generateDoc.
private ViewModel generateDoc(ProtoFile file, GapicProductConfig productConfig) {
ModelTypeTable typeTable = new ModelTypeTable(new RubyTypeTable(productConfig.getPackageName()), new RubyModelTypeNameConverter(productConfig.getPackageName()));
// Use file path for package name to get file-specific package instead of package for the API.
SurfaceNamer namer = new RubySurfaceNamer(typeTable.getFullNameFor(file));
String subPath = pathMapper.getOutputPath(file.getFullName(), productConfig);
String baseFilename = namer.getProtoFileName(file.getSimpleName());
GrpcDocView.Builder doc = GrpcDocView.newBuilder();
doc.templateFileName(DOC_TEMPLATE_FILENAME);
doc.outputPath(subPath + "/doc/" + baseFilename);
doc.fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, ImportSectionView.newBuilder().build(), namer));
doc.elementDocs(elementDocTransformer.generateElementDocs(typeTable, namer, file));
doc.modules(generateModuleViews(new ProtoApiModel(file.getModel()), productConfig, namer, isSourceApiInterfaceFile(file) ? file : null, false));
return doc.build();
}
use of com.google.api.codegen.transformer.ModelTypeTable in project toolkit by googleapis.
the class RubyGapicSurfaceTransformer method generateApiClasses.
private List<ViewModel> generateApiClasses(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
FeatureConfig featureConfig = new RubyFeatureConfig();
ImmutableList.Builder<ViewModel> serviceSurfaces = ImmutableList.builder();
for (InterfaceModel apiInterface : model.getInterfaces()) {
String packageName = productConfig.getPackageName();
ModelTypeTable modelTypeTable = new ModelTypeTable(new RubyTypeTable(productConfig.getPackageName()), new RubyModelTypeNameConverter(packageName));
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, modelTypeTable, namer, featureConfig);
serviceSurfaces.add(generateApiClass(context, packageName));
}
return serviceSurfaces.build();
}
Aggregations