use of com.google.api.codegen.configgen.nodes.ListItemConfigNode in project toolkit by googleapis.
the class InterfaceMerger method generateInterfaceNode.
private ListItemConfigNode generateInterfaceNode(int startLine, InterfaceModel apiInterface) {
Map<String, String> collectionNameMap = interfaceTransformer.getResourceToEntityNameMap(apiInterface);
ListItemConfigNode interfaceNode = new ListItemConfigNode(startLine);
FieldConfigNode nameNode = FieldConfigNode.createStringPair(startLine, "name", apiInterface.getFullName()).setComment(new DefaultComment("The fully qualified name of the API interface."));
interfaceNode.setChild(nameNode);
ConfigNode collectionsNode = collectionMerger.generateCollectionsNode(nameNode, collectionNameMap);
ConfigNode retryParamsDefNode = retryMerger.generateRetryDefinitionsNode(collectionsNode);
methodMerger.generateMethodsNode(interfaceNode, apiInterface, collectionNameMap);
return interfaceNode;
}
use of com.google.api.codegen.configgen.nodes.ListItemConfigNode in project toolkit by googleapis.
the class RetryMerger method generateRetryCodeDefNode.
private ConfigNode generateRetryCodeDefNode(int startLine, String name, List<String> codes) {
ConfigNode retryCodeDefNode = new ListItemConfigNode(startLine);
ConfigNode nameNode = FieldConfigNode.createStringPair(startLine, "name", name);
retryCodeDefNode.setChild(nameNode);
ConfigNode retryCodesNode = new FieldConfigNode(NodeFinder.getNextLine(nameNode), "retry_codes");
nameNode.insertNext(retryCodesNode);
ListTransformer.generateStringList(codes, retryCodesNode);
return retryCodeDefNode;
}
use of com.google.api.codegen.configgen.nodes.ListItemConfigNode in project toolkit by googleapis.
the class RetryMerger method generateRetryParamDefNode.
private ConfigNode generateRetryParamDefNode(int startLine, String name) {
ConfigNode retryParamDefNode = new ListItemConfigNode(startLine);
ConfigNode nameNode = FieldConfigNode.createStringPair(startLine, "name", name);
retryParamDefNode.setChild(nameNode);
ConfigNode initialRetryDelayMillisNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(nameNode), "initial_retry_delay_millis", "100");
nameNode.insertNext(initialRetryDelayMillisNode);
ConfigNode retryDelayMultiplierNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(initialRetryDelayMillisNode), "retry_delay_multiplier", "1.3");
initialRetryDelayMillisNode.insertNext(retryDelayMultiplierNode);
ConfigNode maxRetryDelayMillisNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(retryDelayMultiplierNode), "max_retry_delay_millis", "60000");
retryDelayMultiplierNode.insertNext(maxRetryDelayMillisNode);
ConfigNode initialRpcTimeoutMillisNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(maxRetryDelayMillisNode), "initial_rpc_timeout_millis", "20000");
maxRetryDelayMillisNode.insertNext(initialRpcTimeoutMillisNode);
ConfigNode rpcTimeoutMultiplierNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(initialRpcTimeoutMillisNode), "rpc_timeout_multiplier", "1");
initialRpcTimeoutMillisNode.insertNext(rpcTimeoutMultiplierNode);
ConfigNode maxRpcTimeoutMillisNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(rpcTimeoutMultiplierNode), "max_rpc_timeout_millis", "20000");
rpcTimeoutMultiplierNode.insertNext(maxRpcTimeoutMillisNode);
ConfigNode totalTimeoutMillisNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(maxRpcTimeoutMillisNode), "total_timeout_millis", "600000");
maxRpcTimeoutMillisNode.insertNext(totalTimeoutMillisNode);
return retryParamDefNode;
}
use of com.google.api.codegen.configgen.nodes.ListItemConfigNode in project toolkit by googleapis.
the class ListTransformerTest method testGenerateList.
@Test
public void testGenerateList() throws Exception {
List<Integer> elements = Arrays.asList(1, 2);
ConfigNode parent = new FieldConfigNode(0, "parent");
ConfigNode listNode = ListTransformer.generateList(elements, parent, (startLine, element) -> new ListItemConfigNode(startLine).setChild(new ScalarConfigNode(startLine, String.valueOf(element))));
int index = 0;
for (ConfigNode node : NodeFinder.getChildren(parent)) {
Truth.assertThat(node.getChild().getText()).isEqualTo(String.valueOf(elements.get(index++)));
}
}
use of com.google.api.codegen.configgen.nodes.ListItemConfigNode in project toolkit by googleapis.
the class ConfigYamlNodeReader method readListNode.
private ConfigNode readListNode(int prevLine, Node node, final FieldDescriptor field) {
if (isEmpty(node)) {
return new NullConfigNode();
}
if (!(node instanceof SequenceNode)) {
return new ListItemConfigNode(helper.getStartLine(node)).setChild(readSingularField(prevLine, node, field));
}
ConfigNode configNode = new NullConfigNode();
ConfigNode prev = new NullConfigNode();
for (Node elem : ((SequenceNode) node).getValue()) {
ConfigNode elemNode = new ListItemConfigNode(helper.getStartLine(elem)).setChild(readSingularField(prevLine, elem, field));
ConfigNode commentNode = readCommentNode(prevLine, elem, elemNode);
prevLine = elem.getEndMark().getLine() + 1;
if (elemNode == null) {
continue;
}
prev.insertNext(commentNode);
prev = elemNode;
if (!configNode.isPresent()) {
configNode = commentNode;
}
}
return configNode;
}
Aggregations