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);
}
Aggregations