use of com.google.api.codegen.config.ProtoApiModel in project toolkit by googleapis.
the class PythonGrpcPackageGenerator method generate.
@Override
public Map<String, GeneratedResult<Doc>> generate() throws IOException {
ImmutableMap.Builder<String, GeneratedResult<Doc>> results = new ImmutableMap.Builder<>();
ArrayList<PackageMetadataView> metadataViews = new ArrayList<>();
PythonPackageCopier copier = new PythonPackageCopier();
PythonPackageCopierResult copierResult = copier.run(options, config);
results.putAll(copierResult.results());
PythonGrpcPackageTransformer pythonTransformer = new PythonGrpcPackageTransformer(copierResult);
ProtoApiModel apiModel = new ProtoApiModel(model);
metadataViews.addAll(pythonTransformer.transform(apiModel, config));
for (PackageMetadataView view : metadataViews) {
CommonSnippetSetRunner runner = new CommonSnippetSetRunner(view, false);
results.putAll(runner.generate(view));
}
return results.build();
}
use of com.google.api.codegen.config.ProtoApiModel in project toolkit by googleapis.
the class JavaGrpcPackageGenerator method generate.
@Override
public Map<String, GeneratedResult<Doc>> generate() {
ImmutableMap.Builder<String, GeneratedResult<Doc>> results = new ImmutableMap.Builder<>();
ProtoApiModel apiModel = new ProtoApiModel(model);
List<PackageMetadataView> metadataViews = transformer.transform(apiModel, config);
for (PackageMetadataView view : metadataViews) {
CommonSnippetSetRunner runner = new CommonSnippetSetRunner(view, false);
results.putAll(runner.generate(view));
}
return results.build();
}
use of com.google.api.codegen.config.ProtoApiModel in project toolkit by googleapis.
the class RubySamplePackageMetadataTransformer method transform.
@Override
public List<ViewModel> transform(ProtoApiModel model, GapicProductConfig productConfig) {
boolean shouldGenerateSamplePackages = productConfig.getInterfaceConfigMap().values().stream().flatMap(config -> config.getMethodConfigs().stream()).anyMatch(config -> config.getSampleSpec().isConfigured());
if (!shouldGenerateSamplePackages) {
return Collections.emptyList();
}
ViewModel rubySampleGemfileView = new RubySampleGemfileView() {
@Override
public String gapicGemName() {
return RubySamplePackageMetadataTransformer.gapicGemName(packageConfig.packageName());
}
};
return Collections.singletonList(rubySampleGemfileView);
}
use of com.google.api.codegen.config.ProtoApiModel in project toolkit by googleapis.
the class PythonGrpcMetadataProvider method generate.
@Override
public Map<String, Doc> generate(Model model, PackageMetadataConfig config) throws IOException {
ImmutableMap.Builder<String, Doc> docs = new ImmutableMap.Builder<String, Doc>();
ArrayList<PackageMetadataView> metadataViews = new ArrayList<>();
PythonPackageCopier copier = new PythonPackageCopier();
PythonPackageCopierResult copierResult = copier.run(options, config);
docs.putAll(copierResult.docs());
PythonGrpcMetadataTransformer pythonTransformer = new PythonGrpcMetadataTransformer(copierResult);
ProtoApiModel apiModel = new ProtoApiModel(model);
metadataViews.addAll(pythonTransformer.transform(apiModel, config));
for (PackageMetadataView view : metadataViews) {
CommonSnippetSetRunner runner = new CommonSnippetSetRunner(view);
Doc result = runner.generate(view);
if (!result.isWhitespace()) {
docs.put(view.outputPath(), result);
}
}
return docs.build();
}
use of com.google.api.codegen.config.ProtoApiModel 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();
}
Aggregations