Search in sources :

Example 36 with MethodConfig

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

the class ApiCallableTransformer method setCommonApiCallableFields.

private void setCommonApiCallableFields(MethodContext context, ApiCallableView.Builder apiCallableBuilder) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    MethodConfig methodConfig = context.getMethodConfig();
    apiCallableBuilder.methodName(namer.getApiMethodName(method, context.getMethodConfig().getVisibility()));
    apiCallableBuilder.asyncMethodName(namer.getAsyncApiMethodName(method, VisibilityConfig.PUBLIC));
    apiCallableBuilder.memberName(namer.getSettingsMemberName(method));
    apiCallableBuilder.settingsFunctionName(namer.getSettingsFunctionName(method));
    apiCallableBuilder.grpcClientVarName(namer.getReroutedGrpcClientVarName(methodConfig));
    apiCallableBuilder.methodDescriptorName(namer.getMethodDescriptorName(method));
    apiCallableBuilder.transportSettingsVar(namer.getTransportSettingsVar(method));
    apiCallableBuilder.httpMethod(generateHttpFields(context));
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) DiscoveryMethodModel(com.google.api.codegen.config.DiscoveryMethodModel)

Example 37 with MethodConfig

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

the class BatchingTransformer method generateDescriptorClasses.

public List<BatchingDescriptorClassView> generateDescriptorClasses(InterfaceContext context) {
    List<BatchingDescriptorClassView> descriptors = new ArrayList<>();
    for (MethodModel method : context.getInterfaceConfigMethods()) {
        MethodConfig methodConfig = context.getMethodConfig(method);
        if (methodConfig == null) {
            continue;
        }
        if (!methodConfig.isBatching()) {
            continue;
        }
        descriptors.add(generateDescriptorClass(context.asRequestMethodContext(method)));
    }
    return descriptors;
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) BatchingDescriptorClassView(com.google.api.codegen.viewmodel.BatchingDescriptorClassView) ArrayList(java.util.ArrayList)

Example 38 with MethodConfig

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

the class DiscoGapicInterfaceContext method getInterfaceConfigMethods.

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

Example 39 with MethodConfig

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

the class DynamicLangApiMethodTransformer method removePageTokenFieldConfig.

private Iterable<FieldConfig> removePageTokenFieldConfig(GapicMethodContext context, Iterable<FieldConfig> fieldConfigs) {
    MethodConfig methodConfig = context.getMethodConfig();
    if (methodConfig == null || !methodConfig.isPageStreaming()) {
        return fieldConfigs;
    }
    final FieldModel requestTokenField = methodConfig.getPageStreaming().getRequestTokenField();
    return Iterables.filter(fieldConfigs, new Predicate<FieldConfig>() {

        @Override
        public boolean apply(FieldConfig fieldConfig) {
            return !fieldConfig.getField().equals(requestTokenField);
        }
    });
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) FieldConfig(com.google.api.codegen.config.FieldConfig) FieldModel(com.google.api.codegen.config.FieldModel)

Example 40 with MethodConfig

use of com.google.api.codegen.config.MethodConfig 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)

Aggregations

MethodConfig (com.google.api.codegen.config.MethodConfig)51 MethodModel (com.google.api.codegen.config.MethodModel)29 ArrayList (java.util.ArrayList)20 ImmutableList (com.google.common.collect.ImmutableList)14 FieldModel (com.google.api.codegen.config.FieldModel)13 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)9 DiscoveryMethodModel (com.google.api.codegen.config.DiscoveryMethodModel)8 MethodContext (com.google.api.codegen.transformer.MethodContext)8 FieldConfig (com.google.api.codegen.config.FieldConfig)7 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)6 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)6 SimpleParamDocView (com.google.api.codegen.viewmodel.SimpleParamDocView)6 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)6 ParamDocView (com.google.api.codegen.viewmodel.ParamDocView)5 GapicMethodConfig (com.google.api.codegen.config.GapicMethodConfig)4 GapicInterfaceConfig (com.google.api.codegen.config.GapicInterfaceConfig)3 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)3 PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)3 ParamWithSimpleDoc (com.google.api.codegen.transformer.ParamWithSimpleDoc)3 SymbolTable (com.google.api.codegen.util.SymbolTable)3