use of com.google.api.codegen.viewmodel.ViewModel in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = surfaceTransformer.createSurfaceNamer(productConfig);
boolean enableStringFormatFunctions = productConfig.getResourceNameMessageConfigs().isEmpty();
List<ViewModel> views = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces()) {
ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable, enableStringFormatFunctions);
views.add(createUnitTestFileView(context));
if (context.getInterfaceConfig().getSmokeTestConfig() != null) {
context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable.cloneEmpty(), enableStringFormatFunctions);
views.add(createSmokeTestClassView(context));
}
}
for (InterfaceModel apiInterface : mockServiceTransformer.getGrpcInterfacesToMock(model, productConfig)) {
ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable, enableStringFormatFunctions);
views.add(createMockServiceImplFileView(context));
context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable.cloneEmpty(), enableStringFormatFunctions);
views.add(createMockServiceView(context));
}
return views;
}
use of com.google.api.codegen.viewmodel.ViewModel in project toolkit by googleapis.
the class NodeJSGapicSurfaceTransformer method generateApiClasses.
private List<ViewModel> generateApiClasses(ApiModel model, GapicProductConfig productConfig) {
ImmutableList.Builder<ViewModel> models = ImmutableList.builder();
Iterable<? extends InterfaceModel> interfaces = model.getInterfaces();
for (InterfaceModel apiInterface : interfaces) {
GapicInterfaceContext context = createContext(apiInterface, productConfig);
models.add(generateApiClass(context, model.hasMultipleServices()));
}
return models.build();
}
use of com.google.api.codegen.viewmodel.ViewModel in project toolkit by googleapis.
the class PhpGapicSurfaceTestTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> views = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = createContext(apiInterface, productConfig, PhpSurfaceNamer.TestKind.UNIT);
views.add(createUnitTestFileView(context));
if (context.getInterfaceConfig().getSmokeTestConfig() != null) {
context = createContext(apiInterface, productConfig, PhpSurfaceNamer.TestKind.SYSTEM);
views.add(createSmokeTestClassView(context));
}
}
return views;
}
use of com.google.api.codegen.viewmodel.ViewModel in project toolkit by googleapis.
the class DiscoConfigGeneratorApi method generateConfig.
private Map<String, Doc> generateConfig(String outputPath) {
Document document = setupDocument();
ViewModel viewModel = new DiscoConfigTransformer().generateConfig(new DiscoApiModel(document, ""), outputPath);
Doc generatedConfig = new CommonSnippetSetRunner(new CommonRenderingUtil()).generate(viewModel);
return ImmutableMap.of(outputPath, generatedConfig);
}
use of com.google.api.codegen.viewmodel.ViewModel in project toolkit by googleapis.
the class DiscoGapicProvider method generate.
public Map<String, Doc> generate(String snippetFileName) {
Map<String, Doc> docs = new LinkedTreeMap<>();
for (DocumentToViewTransformer transformer : transformers) {
List<ViewModel> surfaceDocs = transformer.transform(model, productConfig);
for (ViewModel surfaceDoc : surfaceDocs) {
if (snippetFileName != null && !surfaceDoc.templateFileName().equals(snippetFileName)) {
continue;
}
Doc doc = snippetSetRunner.generate(surfaceDoc);
if (doc == null) {
// generation failed; failures are captured in the model.
continue;
}
docs.put(surfaceDoc.outputPath(), doc);
}
}
return docs;
}
Aggregations