use of com.palantir.conjure.python.poet.PythonImport in project conjure-python by palantir.
the class ClientGenerator method generateClient.
public PythonSnippet generateClient(ServiceDefinition serviceDef) {
ImportTypeVisitor importTypeVisitor = new ImportTypeVisitor(serviceDef.getServiceName(), implTypeNameProcessor, implPackageNameProcessor);
ImmutableSet.Builder<Type> referencedTypesBuilder = ImmutableSet.builder();
List<PythonEndpointDefinition> endpoints = serviceDef.getEndpoints().stream().map(endpointDef -> generateEndpoint(endpointDef, referencedTypesBuilder)).collect(Collectors.toList());
List<PythonImport> imports = referencedTypesBuilder.build().stream().flatMap(entry -> entry.accept(importTypeVisitor).stream()).collect(Collectors.toList());
return PythonService.builder().pythonPackage(PythonPackage.of(implPackageNameProcessor.process(serviceDef.getServiceName().getPackage()))).className(implTypeNameProcessor.process(serviceDef.getServiceName())).definitionPackage(PythonPackage.of(definitionPackageNameProcessor.process(serviceDef.getServiceName().getPackage()))).definitionName(definitionTypeNameProcessor.process(serviceDef.getServiceName())).addAllImports(PythonService.CONJURE_IMPORTS).addAllImports(imports).docs(serviceDef.getDocs()).addAllEndpointDefinitions(endpoints).build();
}
Aggregations