Search in sources :

Example 1 with ClientGenerator

use of com.palantir.conjure.python.client.ClientGenerator in project conjure-python by palantir.

the class ConjurePythonGenerator method getImplPythonFile.

private PythonFile getImplPythonFile(ConjureDefinition conjureDefinition, DealiasingTypeVisitor dealiasingTypeVisitor, PackageNameProcessor implPackageNameProcessor, TypeNameProcessor implTypeNameProcessor, PackageNameProcessor definitionPackageNameProcessor, TypeNameProcessor definitionTypeNameProcessor) {
    PythonTypeGenerator beanGenerator = new PythonTypeGenerator(implPackageNameProcessor, implTypeNameProcessor, definitionPackageNameProcessor, definitionTypeNameProcessor, dealiasingTypeVisitor);
    ClientGenerator clientGenerator = new ClientGenerator(implPackageNameProcessor, implTypeNameProcessor, definitionPackageNameProcessor, definitionTypeNameProcessor, dealiasingTypeVisitor);
    List<PythonSnippet> snippets = new ArrayList<>();
    snippets.addAll(conjureDefinition.getTypes().stream().map(beanGenerator::generateType).collect(Collectors.toList()));
    snippets.addAll(conjureDefinition.getServices().stream().map(clientGenerator::generateClient).collect(Collectors.toList()));
    Map<PythonPackage, List<PythonSnippet>> snippetsByPackage = snippets.stream().collect(Collectors.groupingBy(PythonSnippet::pythonPackage));
    PythonPackage rootPackage = PythonPackage.of(implPackageNameProcessor.process(""));
    List<PythonFile> pythonFiles = KeyedStream.stream(snippetsByPackage).map((_pythonPackage, pythonSnippets) -> PythonFile.builder().pythonPackage(rootPackage).fileName(IMPL_PY).contents(pythonSnippets).build()).values().collect(Collectors.toList());
    return Iterables.getOnlyElement(pythonFiles);
}
Also used : PythonPackage(com.palantir.conjure.python.poet.PythonPackage) ClientGenerator(com.palantir.conjure.python.client.ClientGenerator) PythonSnippet(com.palantir.conjure.python.poet.PythonSnippet) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) PythonTypeGenerator(com.palantir.conjure.python.types.PythonTypeGenerator) PythonFile(com.palantir.conjure.python.poet.PythonFile)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ClientGenerator (com.palantir.conjure.python.client.ClientGenerator)1 PythonFile (com.palantir.conjure.python.poet.PythonFile)1 PythonPackage (com.palantir.conjure.python.poet.PythonPackage)1 PythonSnippet (com.palantir.conjure.python.poet.PythonSnippet)1 PythonTypeGenerator (com.palantir.conjure.python.types.PythonTypeGenerator)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1