Search in sources :

Example 1 with PythonEndpointDefinition

use of com.palantir.conjure.python.poet.PythonEndpointDefinition 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();
}
Also used : ImportTypeVisitor(com.palantir.conjure.python.types.ImportTypeVisitor) PythonPackage(com.palantir.conjure.python.poet.PythonPackage) ImmutableSet(com.google.common.collect.ImmutableSet) TypeVisitor(com.palantir.conjure.visitor.TypeVisitor) PythonSnippet(com.palantir.conjure.python.poet.PythonSnippet) Type(com.palantir.conjure.spec.Type) ImportTypeVisitor(com.palantir.conjure.python.types.ImportTypeVisitor) PythonEndpointDefinition(com.palantir.conjure.python.poet.PythonEndpointDefinition) PythonEndpointParam(com.palantir.conjure.python.poet.PythonEndpointDefinition.PythonEndpointParam) ServiceDefinition(com.palantir.conjure.spec.ServiceDefinition) Collectors(java.util.stream.Collectors) ParameterTypeVisitor(com.palantir.conjure.visitor.ParameterTypeVisitor) PythonService(com.palantir.conjure.python.poet.PythonService) List(java.util.List) PythonTypeNameVisitor(com.palantir.conjure.python.types.PythonTypeNameVisitor) MyPyTypeNameVisitor(com.palantir.conjure.python.types.MyPyTypeNameVisitor) PythonImport(com.palantir.conjure.python.poet.PythonImport) PackageNameProcessor(com.palantir.conjure.python.processors.packagename.PackageNameProcessor) CaseConverter(com.palantir.conjure.CaseConverter) DealiasingTypeVisitor(com.palantir.conjure.visitor.DealiasingTypeVisitor) TypeNameProcessor(com.palantir.conjure.python.processors.typename.TypeNameProcessor) PrimitiveType(com.palantir.conjure.spec.PrimitiveType) EndpointDefinition(com.palantir.conjure.spec.EndpointDefinition) Type(com.palantir.conjure.spec.Type) PrimitiveType(com.palantir.conjure.spec.PrimitiveType) ImmutableSet(com.google.common.collect.ImmutableSet) PythonImport(com.palantir.conjure.python.poet.PythonImport) PythonEndpointDefinition(com.palantir.conjure.python.poet.PythonEndpointDefinition)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 CaseConverter (com.palantir.conjure.CaseConverter)1 PythonEndpointDefinition (com.palantir.conjure.python.poet.PythonEndpointDefinition)1 PythonEndpointParam (com.palantir.conjure.python.poet.PythonEndpointDefinition.PythonEndpointParam)1 PythonImport (com.palantir.conjure.python.poet.PythonImport)1 PythonPackage (com.palantir.conjure.python.poet.PythonPackage)1 PythonService (com.palantir.conjure.python.poet.PythonService)1 PythonSnippet (com.palantir.conjure.python.poet.PythonSnippet)1 PackageNameProcessor (com.palantir.conjure.python.processors.packagename.PackageNameProcessor)1 TypeNameProcessor (com.palantir.conjure.python.processors.typename.TypeNameProcessor)1 ImportTypeVisitor (com.palantir.conjure.python.types.ImportTypeVisitor)1 MyPyTypeNameVisitor (com.palantir.conjure.python.types.MyPyTypeNameVisitor)1 PythonTypeNameVisitor (com.palantir.conjure.python.types.PythonTypeNameVisitor)1 EndpointDefinition (com.palantir.conjure.spec.EndpointDefinition)1 PrimitiveType (com.palantir.conjure.spec.PrimitiveType)1 ServiceDefinition (com.palantir.conjure.spec.ServiceDefinition)1 Type (com.palantir.conjure.spec.Type)1 DealiasingTypeVisitor (com.palantir.conjure.visitor.DealiasingTypeVisitor)1 ParameterTypeVisitor (com.palantir.conjure.visitor.ParameterTypeVisitor)1 TypeVisitor (com.palantir.conjure.visitor.TypeVisitor)1