Search in sources :

Example 6 with GapicMethodConfig

use of com.google.api.codegen.config.GapicMethodConfig in project toolkit by googleapis.

the class GapicInterfaceContext method getInterfaceConfigMethods.

/**
 * Returns a list of methods for this interface that have method configs. Memoize the result.
 */
@Override
public List<MethodModel> getInterfaceConfigMethods() {
    if (interfaceMethods != null) {
        return interfaceMethods;
    }
    ImmutableList.Builder<MethodModel> methodBuilder = ImmutableList.builder();
    for (MethodConfig methodConfig : getInterfaceConfig().getMethodConfigs()) {
        methodBuilder.add(new ProtoMethodModel(((GapicMethodConfig) methodConfig).getMethod()));
    }
    interfaceMethods = methodBuilder.build();
    return interfaceMethods;
}
Also used : GapicMethodConfig(com.google.api.codegen.config.GapicMethodConfig) MethodConfig(com.google.api.codegen.config.MethodConfig) ProtoMethodModel(com.google.api.codegen.config.ProtoMethodModel) MethodModel(com.google.api.codegen.config.MethodModel) ProtoMethodModel(com.google.api.codegen.config.ProtoMethodModel) GapicMethodConfig(com.google.api.codegen.config.GapicMethodConfig) ImmutableList(com.google.common.collect.ImmutableList)

Example 7 with GapicMethodConfig

use of com.google.api.codegen.config.GapicMethodConfig in project toolkit by googleapis.

the class HeaderRequestParamTransformer method generateHeaderRequestParams.

public List<HeaderRequestParamView> generateHeaderRequestParams(MethodContext context) {
    if (!context.getProductConfig().getTransportProtocol().equals(TransportProtocol.GRPC)) {
        return ImmutableList.of();
    }
    GapicMethodConfig methodConfig = (GapicMethodConfig) context.getMethodConfig();
    Method method = methodConfig.getMethod();
    SurfaceNamer namer = context.getNamer();
    if (method.getInputType() == null || !method.getInputType().isMessage()) {
        return ImmutableList.of();
    }
    ImmutableList.Builder<HeaderRequestParamView> headerRequestParams = ImmutableList.builder();
    MessageType inputMessageType = method.getInputType().getMessageType();
    for (String headerRequestParam : methodConfig.getHeaderRequestParams()) {
        headerRequestParams.add(generateHeaderRequestParam(headerRequestParam, inputMessageType, namer));
    }
    return headerRequestParams.build();
}
Also used : GapicMethodConfig(com.google.api.codegen.config.GapicMethodConfig) ImmutableList(com.google.common.collect.ImmutableList) Method(com.google.api.tools.framework.model.Method) HeaderRequestParamView(com.google.api.codegen.viewmodel.HeaderRequestParamView) MessageType(com.google.api.tools.framework.model.MessageType)

Aggregations

GapicMethodConfig (com.google.api.codegen.config.GapicMethodConfig)7 MethodConfig (com.google.api.codegen.config.MethodConfig)3 Method (com.google.api.tools.framework.model.Method)3 GapicInterfaceConfig (com.google.api.codegen.config.GapicInterfaceConfig)2 ImmutableList (com.google.common.collect.ImmutableList)2 FieldModel (com.google.api.codegen.config.FieldModel)1 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)1 MethodModel (com.google.api.codegen.config.MethodModel)1 ProtoMethodModel (com.google.api.codegen.config.ProtoMethodModel)1 ModelTypeTable (com.google.api.codegen.transformer.ModelTypeTable)1 HeaderRequestParamView (com.google.api.codegen.viewmodel.HeaderRequestParamView)1 Interface (com.google.api.tools.framework.model.Interface)1 MessageType (com.google.api.tools.framework.model.MessageType)1 TypeRef (com.google.api.tools.framework.model.TypeRef)1 ArrayList (java.util.ArrayList)1