Search in sources :

Example 1 with DiscoGapicMethodContext

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

the class JavaDiscoGapicRequestToViewTransformer method getRequestObjectParams.

private RequestObjectParamView getRequestObjectParams(DiscoGapicInterfaceContext context, MethodModel method) {
    MethodConfig methodConfig = context.getMethodConfig(method);
    // Generate the ResourceName methods.
    if (methodConfig.isFlattening()) {
        for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
            DiscoGapicMethodContext defaultMethodContext = context.asRequestMethodContext(method);
            MethodContext flattenedMethodContext = context.asFlattenedMethodContext(defaultMethodContext, flatteningGroup);
            if (FlatteningConfig.hasAnyRepeatedResourceNameParameter(flatteningGroup)) {
                flattenedMethodContext = flattenedMethodContext.withResourceNamesInSamplesOnly();
            }
            Iterable<FieldConfig> fieldConfigs = flattenedMethodContext.getFlatteningConfig().getFlattenedFieldConfigs().values();
            for (FieldConfig fieldConfig : fieldConfigs) {
                if (context.getFeatureConfig().useResourceNameFormatOption(fieldConfig)) {
                    return resourceObjectTransformer.generateRequestObjectParam(flattenedMethodContext, fieldConfig);
                }
            }
        }
    }
    return null;
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) FieldConfig(com.google.api.codegen.config.FieldConfig) DiscoGapicMethodContext(com.google.api.codegen.config.DiscoGapicMethodContext) MethodContext(com.google.api.codegen.config.MethodContext) DiscoGapicMethodContext(com.google.api.codegen.config.DiscoGapicMethodContext) FlatteningConfig(com.google.api.codegen.config.FlatteningConfig)

Aggregations

DiscoGapicMethodContext (com.google.api.codegen.config.DiscoGapicMethodContext)1 FieldConfig (com.google.api.codegen.config.FieldConfig)1 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)1 MethodConfig (com.google.api.codegen.config.MethodConfig)1 MethodContext (com.google.api.codegen.config.MethodContext)1