Search in sources :

Example 1 with FixmeComment

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;
}
Also used : FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) FixmeComment(com.google.api.codegen.configgen.nodes.metadata.FixmeComment) ArrayList(java.util.ArrayList) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode) ListItemConfigNode(com.google.api.codegen.configgen.nodes.ListItemConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) FieldModel(com.google.api.codegen.config.FieldModel)

Example 2 with FixmeComment

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);
}
Also used : FixmeComment(com.google.api.codegen.configgen.nodes.metadata.FixmeComment) 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 3 with FixmeComment

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;
}
Also used : FixmeComment(com.google.api.codegen.configgen.nodes.metadata.FixmeComment) ListItemConfigNode(com.google.api.codegen.configgen.nodes.ListItemConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode)

Example 4 with FixmeComment

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;
}
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)

Aggregations

ConfigNode (com.google.api.codegen.configgen.nodes.ConfigNode)4 FieldConfigNode (com.google.api.codegen.configgen.nodes.FieldConfigNode)4 ListItemConfigNode (com.google.api.codegen.configgen.nodes.ListItemConfigNode)4 FixmeComment (com.google.api.codegen.configgen.nodes.metadata.FixmeComment)4 FieldModel (com.google.api.codegen.config.FieldModel)1 ArrayList (java.util.ArrayList)1