Search in sources :

Example 1 with SampleParameterConfig

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

the class SampleTransformer method sampleParamConfigMapFromRequestConfigs.

private ImmutableMap<String, SampleParameterConfig> sampleParamConfigMapFromRequestConfigs(List<RequestFieldProto> requests) {
    ImmutableMap.Builder<String, SampleParameterConfig> builder = ImmutableMap.builder();
    for (RequestFieldProto request : requests) {
        String field = request.getField();
        SampleParameterConfig config = SampleParameterConfig.newBuilder().field(field).isFile(request.getValueIsFile()).inputParameter(request.getInputParameter()).comment(request.getComment()).build();
        builder.put(field, config);
    }
    return builder.build();
}
Also used : RequestFieldProto(com.google.api.codegen.samplegen.v1p2.RequestFieldProto) ImmutableMap(com.google.common.collect.ImmutableMap) SampleParameterConfig(com.google.api.codegen.config.SampleParameterConfig)

Example 2 with SampleParameterConfig

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

the class SampleTransformer method sampleParamConfigMapFromValueSet.

private ImmutableMap<String, SampleParameterConfig> sampleParamConfigMapFromValueSet(SampleValueSet valueSet) {
    ImmutableMap.Builder<String, SampleParameterConfig> builder = ImmutableMap.builder();
    for (SampleInitAttribute attr : valueSet.getParameters().getAttributesList()) {
        String field = attr.getParameter();
        SampleParameterConfig config = SampleParameterConfig.newBuilder().field(field).isFile(attr.getReadFile()).inputParameter(attr.getSampleArgumentName()).comment(attr.getDescription()).build();
        builder.put(field, config);
    }
    return builder.build();
}
Also used : SampleInitAttribute(com.google.api.codegen.SampleInitAttribute) ImmutableMap(com.google.common.collect.ImmutableMap) SampleParameterConfig(com.google.api.codegen.config.SampleParameterConfig)

Example 3 with SampleParameterConfig

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

the class InitCodeNode method resolveSampleParamConfigs.

private void resolveSampleParamConfigs(InitCodeContext context, Map<String, SampleParameterConfig> configs) {
    for (Map.Entry<String, SampleParameterConfig> entry : configs.entrySet()) {
        Scanner scanner = new Scanner(entry.getKey());
        InitCodeNode parent = FieldStructureParser.parsePath(this, scanner);
        int token = scanner.lastToken();
        if (token == Scanner.EOF) {
            parent.resolveSampleParamConfig(context, entry.getValue());
        } else if (token == '%') {
            Preconditions.checkArgument(scanner.scan() == Scanner.IDENT, "expected IDENT after '%': %s", entry.getKey());
            String entityName = scanner.tokenStr();
            Preconditions.checkArgument(scanner.scan() == Scanner.EOF, "expected EOF after entity name: %s", entityName);
            parent.resolveSampleParamConfig(context, entityName, entry.getValue());
        }
    }
}
Also used : Scanner(com.google.api.codegen.util.Scanner) ImmutableMap(com.google.common.collect.ImmutableMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SampleParameterConfig(com.google.api.codegen.config.SampleParameterConfig)

Aggregations

SampleParameterConfig (com.google.api.codegen.config.SampleParameterConfig)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 SampleInitAttribute (com.google.api.codegen.SampleInitAttribute)1 RequestFieldProto (com.google.api.codegen.samplegen.v1p2.RequestFieldProto)1 Scanner (com.google.api.codegen.util.Scanner)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1