Search in sources :

Example 1 with MethodDescriptorView

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

the class ApiCallableTransformer method generateMethodDescriptors.

public List<MethodDescriptorView> generateMethodDescriptors(InterfaceContext context) {
    List<MethodDescriptorView> callables = new ArrayList<>();
    boolean excludeMixins = !context.getFeatureConfig().enableMixins();
    for (MethodModel method : context.getSupportedMethods()) {
        if (excludeMixins && context.getMethodConfig(method).getRerouteToGrpcInterface() != null) {
            continue;
        }
        callables.add(generateMethodDescriptor(context.asRequestMethodContext(method)));
    }
    return callables;
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) DiscoveryMethodModel(com.google.api.codegen.config.DiscoveryMethodModel) MethodDescriptorView(com.google.api.codegen.viewmodel.MethodDescriptorView) ArrayList(java.util.ArrayList)

Example 2 with MethodDescriptorView

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

the class ApiCallableTransformer method generateMethodDescriptor.

private MethodDescriptorView generateMethodDescriptor(MethodContext context) {
    ImportTypeTable typeTable = context.getTypeTable();
    MethodModel method = context.getMethodModel();
    MethodConfig methodConfig = context.getMethodConfig();
    SurfaceNamer namer = context.getNamer();
    MethodDescriptorView.Builder methodDescriptorBuilder = MethodDescriptorView.newBuilder();
    if (methodConfig.isGrpcStreaming()) {
        methodDescriptorBuilder.grpcStreamingType(methodConfig.getGrpcStreaming().getType());
    }
    methodDescriptorBuilder.requestTypeName(method.getAndSaveRequestTypeName(typeTable, namer));
    methodDescriptorBuilder.responseTypeName(method.getAndSaveResponseTypeName(typeTable, namer));
    methodDescriptorBuilder.hasResponse(!method.isOutputTypeEmpty());
    methodDescriptorBuilder.name(namer.getMethodDescriptorName(method));
    methodDescriptorBuilder.protoMethodName(method.getSimpleName());
    methodDescriptorBuilder.fullServiceName(context.getTargetInterface().getFullName());
    methodDescriptorBuilder.transportSettingsVar(namer.getTransportSettingsVar(method));
    methodDescriptorBuilder.headerRequestParams(headerRequestParamTransformer.generateHeaderRequestParams(context));
    methodDescriptorBuilder.httpMethod(generateHttpFields(context));
    return methodDescriptorBuilder.build();
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) DiscoveryMethodModel(com.google.api.codegen.config.DiscoveryMethodModel) MethodDescriptorView(com.google.api.codegen.viewmodel.MethodDescriptorView)

Aggregations

DiscoveryMethodModel (com.google.api.codegen.config.DiscoveryMethodModel)2 MethodModel (com.google.api.codegen.config.MethodModel)2 MethodDescriptorView (com.google.api.codegen.viewmodel.MethodDescriptorView)2 MethodConfig (com.google.api.codegen.config.MethodConfig)1 ArrayList (java.util.ArrayList)1