use of com.google.api.codegen.configgen.nodes.metadata.FixmeComment in project toolkit by googleapis.
the class MethodMerger method generateField.
private ConfigNode generateField(ConfigNode prevNode, MethodModel method) {
List<String> parameterList = new ArrayList<>();
for (FieldModel field : method.getInputFields()) {
String fieldName = field.getSimpleName();
if (field.getOneof() == null && !methodTransformer.isIgnoredParameter(fieldName)) {
parameterList.add(fieldName);
}
}
if (parameterList.size() > 0 && parameterList.size() <= FLATTENING_THRESHOLD) {
prevNode = generateFlatteningNode(prevNode, parameterList);
}
FieldConfigNode requiredFieldsNode = new FieldConfigNode(NodeFinder.getNextLine(prevNode), "required_fields");
requiredFieldsNode.setComment(new FixmeComment("Configure which fields are required."));
ConfigNode requiredFieldsValueNode = ListTransformer.generateStringList(parameterList, requiredFieldsNode);
if (requiredFieldsValueNode.isPresent()) {
prevNode.insertNext(requiredFieldsNode);
prevNode = requiredFieldsNode;
}
// use all fields for the following check; if there are ignored fields for flattening
// purposes, the caller still needs a way to set them (by using the request object method).
int fieldCount = Iterables.size(method.getInputFields());
boolean requestObjectMethod = (fieldCount > REQUEST_OBJECT_METHOD_THRESHOLD || fieldCount != parameterList.size()) && !method.getRequestStreaming();
ConfigNode requestObjectMethodNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(prevNode), "request_object_method", String.valueOf(requestObjectMethod));
prevNode.insertNext(requestObjectMethodNode);
return requestObjectMethodNode;
}
use of com.google.api.codegen.configgen.nodes.metadata.FixmeComment in project toolkit by googleapis.
the class MethodMerger method generateTimeout.
private void generateTimeout(ConfigNode prevNode, MethodModel method) {
ConfigNode timeoutMillisNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(prevNode), "timeout_millis", methodTransformer.getTimeoutMillis(method)).setComment(new FixmeComment("Configure the default timeout for a non-retrying call."));
prevNode.insertNext(timeoutMillisNode);
}
use of com.google.api.codegen.configgen.nodes.metadata.FixmeComment in project toolkit by googleapis.
the class RetryMerger method generateRetryNamesNode.
public ConfigNode generateRetryNamesNode(ConfigNode prevNode, MethodModel method) {
String retryCodesName = method.isIdempotent() ? RETRY_CODES_IDEMPOTENT_NAME : RETRY_CODES_NON_IDEMPOTENT_NAME;
ConfigNode retryCodesNameNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(prevNode), "retry_codes_name", retryCodesName).setComment(new FixmeComment("Configure the retryable codes for this method."));
prevNode.insertNext(retryCodesNameNode);
ConfigNode retryParamsNameNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(retryCodesNameNode), "retry_params_name", RETRY_PARAMS_DEFAULT_NAME).setComment(new FixmeComment("Configure the retryable params for this method."));
retryCodesNameNode.insertNext(retryParamsNameNode);
return retryParamsNameNode;
}
use of com.google.api.codegen.configgen.nodes.metadata.FixmeComment 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;
}
Aggregations