Search in sources :

Example 31 with ConfigNode

use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.

the class MethodMerger method generateFlatteningNode.

private ConfigNode generateFlatteningNode(ConfigNode prevNode, List<String> parameterList) {
    ConfigNode flatteningNode = new FieldConfigNode(NodeFinder.getNextLine(prevNode), "flattening").setComment(new FixmeComment("Configure which groups of fields should be flattened into method params."));
    prevNode.insertNext(flatteningNode);
    ConfigNode flatteningGroupsNode = new FieldConfigNode(NodeFinder.getNextLine(flatteningNode), "groups");
    flatteningNode.setChild(flatteningGroupsNode);
    ConfigNode groupNode = new ListItemConfigNode(NodeFinder.getNextLine(flatteningGroupsNode));
    flatteningGroupsNode.setChild(groupNode);
    ConfigNode parametersNode = new FieldConfigNode(groupNode.getStartLine(), "parameters");
    groupNode.setChild(parametersNode);
    ListTransformer.generateStringList(parameterList, parametersNode);
    return flatteningNode;
}
Also used : FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) FixmeComment(com.google.api.codegen.configgen.nodes.metadata.FixmeComment) ListItemConfigNode(com.google.api.codegen.configgen.nodes.ListItemConfigNode) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode) ListItemConfigNode(com.google.api.codegen.configgen.nodes.ListItemConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode)

Example 32 with ConfigNode

use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.

the class MethodMerger method generateMethodNode.

private ListItemConfigNode generateMethodNode(int startLine, MethodModel method, Map<String, String> collectionNameMap) {
    ListItemConfigNode methodNode = new ListItemConfigNode(startLine);
    ConfigNode nameNode = FieldConfigNode.createStringPair(startLine, "name", method.getSimpleName());
    methodNode.setChild(nameNode);
    ConfigNode prevNode = generateField(nameNode, method);
    prevNode = pageStreamingMerger.generatePageStreamingNode(prevNode, method);
    prevNode = retryMerger.generateRetryNamesNode(prevNode, method);
    prevNode = generateFieldNamePatterns(prevNode, method, collectionNameMap);
    generateTimeout(prevNode, method);
    return methodNode;
}
Also used : ListItemConfigNode(com.google.api.codegen.configgen.nodes.ListItemConfigNode) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode) ListItemConfigNode(com.google.api.codegen.configgen.nodes.ListItemConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode)

Example 33 with ConfigNode

use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.

the class MethodMerger method generateFieldNamePatterns.

private ConfigNode generateFieldNamePatterns(ConfigNode prevNode, MethodModel method, final Map<String, String> nameMap) {
    ConfigNode fieldNamePatternsNode = new FieldConfigNode(NodeFinder.getNextLine(prevNode), "field_name_patterns");
    ConfigNode fieldNamePatternsValueNode = ListTransformer.generateList(method.getResourcePatternNameMap(nameMap).entrySet(), fieldNamePatternsNode, (startLine, entry) -> FieldConfigNode.createStringPair(startLine, entry.getKey(), entry.getValue()));
    if (!fieldNamePatternsValueNode.isPresent()) {
        return prevNode;
    }
    prevNode.insertNext(fieldNamePatternsNode);
    return fieldNamePatternsNode;
}
Also used : FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode) ListItemConfigNode(com.google.api.codegen.configgen.nodes.ListItemConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode)

Example 34 with ConfigNode

use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.

the class PageStreamingMerger method generatePageStreamingRequestNode.

private ConfigNode generatePageStreamingRequestNode(ConfigNode parentNode, MethodModel method) {
    ConfigNode requestNode = new FieldConfigNode(NodeFinder.getNextLine(parentNode), "request");
    parentNode.setChild(requestNode);
    ConfigNode requestValueNode = generatePageStreamingRequestValueNode(requestNode, NodeFinder.getNextLine(requestNode), method);
    return requestValueNode.isPresent() ? requestNode : null;
}
Also used : FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) NullConfigNode(com.google.api.codegen.configgen.nodes.NullConfigNode) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode)

Example 35 with ConfigNode

use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.

the class PageStreamingMerger method generatePageStreamingNode.

public ConfigNode generatePageStreamingNode(ConfigNode prevNode, MethodModel method) {
    ConfigNode pageStreamingNode = new FieldConfigNode(NodeFinder.getNextLine(prevNode), "page_streaming");
    ConfigNode requestNode = generatePageStreamingRequestNode(pageStreamingNode, method);
    if (requestNode == null) {
        return prevNode;
    }
    ConfigNode responseNode = generatePageStreamingResponseNode(requestNode, method);
    if (responseNode == null) {
        return prevNode;
    }
    prevNode.insertNext(pageStreamingNode);
    return pageStreamingNode;
}
Also used : FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) NullConfigNode(com.google.api.codegen.configgen.nodes.NullConfigNode) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode)

Aggregations

ConfigNode (com.google.api.codegen.configgen.nodes.ConfigNode)39 FieldConfigNode (com.google.api.codegen.configgen.nodes.FieldConfigNode)35 ListItemConfigNode (com.google.api.codegen.configgen.nodes.ListItemConfigNode)22 ScalarConfigNode (com.google.api.codegen.configgen.nodes.ScalarConfigNode)12 NullConfigNode (com.google.api.codegen.configgen.nodes.NullConfigNode)11 Test (org.junit.Test)5 MappingNode (org.yaml.snakeyaml.nodes.MappingNode)5 DefaultComment (com.google.api.codegen.configgen.nodes.metadata.DefaultComment)4 FixmeComment (com.google.api.codegen.configgen.nodes.metadata.FixmeComment)4 Node (org.yaml.snakeyaml.nodes.Node)4 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)3 ScalarNode (org.yaml.snakeyaml.nodes.ScalarNode)3 SequenceNode (org.yaml.snakeyaml.nodes.SequenceNode)3 ConfigHelper (com.google.api.codegen.configgen.ConfigHelper)2 ConfigYamlReader (com.google.api.codegen.configgen.ConfigYamlReader)2 MessageGenerator (com.google.api.codegen.configgen.MessageGenerator)2 File (java.io.File)2 NodeTuple (org.yaml.snakeyaml.nodes.NodeTuple)2 FieldModel (com.google.api.codegen.config.FieldModel)1 ProtoConfigMerger (com.google.api.codegen.configgen.mergers.ProtoConfigMerger)1