Search in sources :

Example 1 with PackageMetadataView

use of com.google.api.codegen.viewmodel.metadata.PackageMetadataView in project toolkit by googleapis.

the class JavaGrpcMetadataProvider method generate.

@Override
public Map<String, Doc> generate(Model model, PackageMetadataConfig config) {
    ImmutableMap.Builder<String, Doc> docs = new ImmutableMap.Builder<>();
    ProtoApiModel apiModel = new ProtoApiModel(model);
    ArrayList<PackageMetadataView> metadataViews = new ArrayList<>();
    metadataViews.addAll(transformer.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();
}
Also used : CommonSnippetSetRunner(com.google.api.codegen.rendering.CommonSnippetSetRunner) ArrayList(java.util.ArrayList) Doc(com.google.api.tools.framework.snippet.Doc) ProtoApiModel(com.google.api.codegen.config.ProtoApiModel) PackageMetadataView(com.google.api.codegen.viewmodel.metadata.PackageMetadataView) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with PackageMetadataView

use of com.google.api.codegen.viewmodel.metadata.PackageMetadataView 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();
}
Also used : CommonSnippetSetRunner(com.google.api.codegen.rendering.CommonSnippetSetRunner) GeneratedResult(com.google.api.codegen.common.GeneratedResult) ArrayList(java.util.ArrayList) ImmutableMap(com.google.common.collect.ImmutableMap) ProtoApiModel(com.google.api.codegen.config.ProtoApiModel) PackageMetadataView(com.google.api.codegen.viewmodel.metadata.PackageMetadataView)

Example 3 with PackageMetadataView

use of com.google.api.codegen.viewmodel.metadata.PackageMetadataView 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();
}
Also used : CommonSnippetSetRunner(com.google.api.codegen.rendering.CommonSnippetSetRunner) GeneratedResult(com.google.api.codegen.common.GeneratedResult) ProtoApiModel(com.google.api.codegen.config.ProtoApiModel) PackageMetadataView(com.google.api.codegen.viewmodel.metadata.PackageMetadataView) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 4 with PackageMetadataView

use of com.google.api.codegen.viewmodel.metadata.PackageMetadataView 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();
}
Also used : CommonSnippetSetRunner(com.google.api.codegen.rendering.CommonSnippetSetRunner) ArrayList(java.util.ArrayList) ImmutableMap(com.google.common.collect.ImmutableMap) Doc(com.google.api.tools.framework.snippet.Doc) ProtoApiModel(com.google.api.codegen.config.ProtoApiModel) PackageMetadataView(com.google.api.codegen.viewmodel.metadata.PackageMetadataView)

Example 5 with PackageMetadataView

use of com.google.api.codegen.viewmodel.metadata.PackageMetadataView in project toolkit by googleapis.

the class PythonGrpcMetadataTransformer method transform.

public List<PackageMetadataView> transform(ApiModel model, PackageMetadataConfig config) {
    ArrayList<PackageMetadataView> views = new ArrayList<>();
    PythonSurfaceNamer surfaceNamer = new PythonSurfaceNamer(config.packageName(TargetLanguage.PYTHON));
    PackageMetadataTransformer transformer = new PackageMetadataTransformer();
    for (String snippetFilename : SNIPPETS) {
        PackageMetadataView view = transformer.generateMetadataView(new PackageMetadataNamer(), config, model, snippetFilename, outputPath(snippetFilename), TargetLanguage.PYTHON, PROTO_PACKAGE_DEPENDENCY_WHITELIST).namespacePackages(copierResult.namespacePackages()).developmentStatus(surfaceNamer.getReleaseAnnotation(config.releaseLevel(TargetLanguage.PYTHON))).build();
        views.add(view);
    }
    return views;
}
Also used : PythonSurfaceNamer(com.google.api.codegen.transformer.py.PythonSurfaceNamer) PackageMetadataTransformer(com.google.api.codegen.transformer.PackageMetadataTransformer) ArrayList(java.util.ArrayList) PackageMetadataView(com.google.api.codegen.viewmodel.metadata.PackageMetadataView) PackageMetadataNamer(com.google.api.codegen.transformer.PackageMetadataNamer)

Aggregations

PackageMetadataView (com.google.api.codegen.viewmodel.metadata.PackageMetadataView)6 ArrayList (java.util.ArrayList)5 ProtoApiModel (com.google.api.codegen.config.ProtoApiModel)4 CommonSnippetSetRunner (com.google.api.codegen.rendering.CommonSnippetSetRunner)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 GeneratedResult (com.google.api.codegen.common.GeneratedResult)2 PackageMetadataNamer (com.google.api.codegen.transformer.PackageMetadataNamer)2 PackageMetadataTransformer (com.google.api.codegen.transformer.PackageMetadataTransformer)2 PythonSurfaceNamer (com.google.api.codegen.transformer.py.PythonSurfaceNamer)2 Doc (com.google.api.tools.framework.snippet.Doc)2