Introduce an `include_type_name` constant (#37155)
I started referring to this parameter name from various places in #37149 so I think it's a good idea to simplify things by referring to a common constant.
This commit is contained in:
parent
12a105e5ef
commit
d18c3d651d
|
@ -58,6 +58,12 @@ public abstract class BaseRestHandler extends AbstractComponent implements RestH
|
|||
|
||||
private final LongAdder usageCount = new LongAdder();
|
||||
|
||||
/**
|
||||
* Parameter that controls whether certain REST apis should include type names in their requests or responses.
|
||||
* Note: Support for this parameter will be removed after the transition perido to typeless APIs.
|
||||
*/
|
||||
protected static final String INCLUDE_TYPE_NAME_PARAMETER = "include_type_name";
|
||||
|
||||
protected BaseRestHandler(Settings settings) {
|
||||
// TODO drop settings from ctor
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class RestCreateIndexAction extends BaseRestHandler {
|
|||
|
||||
@Override
|
||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
final boolean includeTypeName = request.paramAsBoolean("include_type_name", true);
|
||||
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, true);
|
||||
CreateIndexRequest createIndexRequest = new CreateIndexRequest(request.param("index"));
|
||||
if (request.hasContent()) {
|
||||
Map<String, Object> sourceAsMap = XContentHelper.convertToMap(request.content(), false, request.getXContentType()).v2();
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
package org.elasticsearch.rest.action.admin.indices;
|
||||
|
||||
import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
|
||||
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
|
@ -85,7 +86,7 @@ public class RestGetMappingAction extends BaseRestHandler {
|
|||
deprecationLogger.deprecated("Type exists requests are deprecated, as types have been deprecated.");
|
||||
}
|
||||
|
||||
final boolean includeTypeName = request.paramAsBoolean("include_type_name", true);
|
||||
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, true);
|
||||
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
|
||||
final String[] types = request.paramAsStringArrayOrEmptyIfAll("type");
|
||||
final GetMappingsRequest getMappingsRequest = new GetMappingsRequest();
|
||||
|
|
|
@ -68,7 +68,7 @@ public class RestPutMappingAction extends BaseRestHandler {
|
|||
|
||||
@Override
|
||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
final boolean includeTypeName = request.paramAsBoolean("include_type_name", true);
|
||||
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, true);
|
||||
PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index")));
|
||||
final String type = request.param("type");
|
||||
if (type != null && includeTypeName == false) {
|
||||
|
|
Loading…
Reference in New Issue