use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.
the class PageStreamingMerger method generatePageStreamingRequestValueNode.
private ConfigNode generatePageStreamingRequestValueNode(ConfigNode parentNode, int startLine, MethodModel method) {
String pageTokenName = pageStreamingTransformer.getNameForPageToken();
String pageSizeName = pageStreamingTransformer.getNameForPageSize();
boolean hasTokenField = method.getInputField(pageTokenName) != null;
boolean hasPageSizeField = method.getInputField(pageSizeName) != null;
ConfigNode requestValueNode = null;
if (hasPageSizeField) {
requestValueNode = FieldConfigNode.createStringPair(startLine, "page_size_field", pageSizeName);
if (hasTokenField) {
ConfigNode tokenFieldNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(requestValueNode), "token_field", pageTokenName);
requestValueNode.insertNext(tokenFieldNode);
}
} else if (hasTokenField) {
requestValueNode = FieldConfigNode.createStringPair(startLine, "token_field", pageTokenName);
} else {
return new NullConfigNode();
}
parentNode.setChild(requestValueNode);
return requestValueNode;
}
use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.
the class RetryMerger method generateRetryCodesDefValueNode.
private void generateRetryCodesDefValueNode(ConfigNode parentNode) {
ConfigNode idempotentNode = generateRetryCodeDefNode(NodeFinder.getNextLine(parentNode), RETRY_CODES_IDEMPOTENT_NAME, ImmutableList.of(Status.Code.UNAVAILABLE.name(), Status.Code.DEADLINE_EXCEEDED.name()));
parentNode.setChild(idempotentNode);
ConfigNode nonIdempotentNode = generateRetryCodeDefNode(NodeFinder.getNextLine(idempotentNode), RETRY_CODES_NON_IDEMPOTENT_NAME, ImmutableList.<String>of());
idempotentNode.insertNext(nonIdempotentNode);
}
use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.
the class RetryMerger method generateRetryParamsDefValueNode.
private void generateRetryParamsDefValueNode(ConfigNode parentNode) {
ConfigNode defaultNode = generateRetryParamDefNode(NodeFinder.getNextLine(parentNode), RETRY_PARAMS_DEFAULT_NAME);
parentNode.setChild(defaultNode);
}
use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.
the class DiscoGapicGeneratorApi method loadConfigFromFiles.
private static ConfigProto loadConfigFromFiles(List<String> configFileNames) {
DiagCollector diagCollector = new SimpleDiagCollector();
ConfigYamlReader yamlReader = new ConfigYamlReader();
MessageGenerator messageGenerator = new MessageGenerator(ConfigProto.newBuilder());
for (File file : pathsToFiles(configFileNames)) {
ConfigHelper helper = new ConfigHelper(diagCollector, file.getName());
ConfigNode configNode = yamlReader.generateConfigNode(file, helper);
if (configNode == null) {
continue;
}
messageGenerator.visit(configNode.getChild());
}
ConfigProto configProto = (ConfigProto) messageGenerator.getValue();
if (configProto == null || configProto.equals(ConfigProto.getDefaultInstance())) {
return null;
}
return configProto;
}
Aggregations