From 6d8c099b2be3460674cb94c764c073e9a4b0b84a Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Mon, 29 Apr 2019 13:11:25 +0100 Subject: [PATCH 1/2] Removes typed URLs --- .../noop/action/bulk/RestNoopBulkAction.java | 2 - .../action/search/RestNoopSearchAction.java | 2 - .../RestMultiSearchTemplateAction.java | 4 -- .../mustache/RestSearchTemplateAction.java | 4 -- .../reindex/RestDeleteByQueryAction.java | 1 - .../reindex/RestUpdateByQueryAction.java | 1 - .../resources/rest-api-spec/api/bulk.json | 2 +- .../resources/rest-api-spec/api/count.json | 7 --- .../resources/rest-api-spec/api/create.json | 7 --- .../resources/rest-api-spec/api/delete.json | 7 --- .../rest-api-spec/api/delete_by_query.json | 7 --- .../resources/rest-api-spec/api/exists.json | 7 --- .../rest-api-spec/api/exists_source.json | 7 --- .../resources/rest-api-spec/api/explain.json | 7 --- .../main/resources/rest-api-spec/api/get.json | 7 --- .../rest-api-spec/api/get_source.json | 7 --- .../resources/rest-api-spec/api/index.json | 12 ----- .../api/indices.exists_type.json | 47 ------------------- .../api/indices.get_field_mapping.json | 12 ----- .../api/indices.get_mapping.json | 12 ----- .../api/indices.put_mapping.json | 30 ------------ .../api/indices.validate_query.json | 7 --- .../resources/rest-api-spec/api/mget.json | 7 --- .../resources/rest-api-spec/api/msearch.json | 7 --- .../rest-api-spec/api/msearch_template.json | 7 --- .../rest-api-spec/api/mtermvectors.json | 7 --- .../resources/rest-api-spec/api/search.json | 7 --- .../rest-api-spec/api/search_template.json | 7 --- .../rest-api-spec/api/termvectors.json | 12 ----- .../resources/rest-api-spec/api/update.json | 7 --- .../rest-api-spec/api/update_by_query.json | 7 --- .../indices/RestGetFieldMappingAction.java | 3 -- .../admin/indices/RestGetMappingAction.java | 6 +-- .../admin/indices/RestPutMappingAction.java | 12 ----- .../indices/RestValidateQueryAction.java | 2 - .../rest/action/document/RestBulkAction.java | 4 -- .../action/document/RestDeleteAction.java | 3 -- .../rest/action/document/RestGetAction.java | 4 -- .../action/document/RestGetSourceAction.java | 2 - .../rest/action/document/RestIndexAction.java | 7 --- .../action/document/RestMultiGetAction.java | 4 -- .../document/RestMultiTermVectorsAction.java | 4 -- .../document/RestTermVectorsAction.java | 6 --- .../action/document/RestUpdateAction.java | 3 -- .../rest/action/search/RestCountAction.java | 4 -- .../rest/action/search/RestExplainAction.java | 4 -- .../action/search/RestMultiSearchAction.java | 4 -- .../rest/action/search/RestSearchAction.java | 4 -- .../graph/rest/action/RestGraphAction.java | 8 ---- .../rest-api-spec/api/graph.explore.json | 7 --- .../rest-api-spec/api/monitoring.bulk.json | 7 --- .../api/rollup.rollup_search.json | 7 --- 52 files changed, 2 insertions(+), 370 deletions(-) delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists_type.json diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java index 8805af367a80e..57357d71c4338 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java @@ -52,8 +52,6 @@ public RestNoopBulkAction(Settings settings, RestController controller) { controller.registerHandler(PUT, "/_noop_bulk", this); controller.registerHandler(POST, "/{index}/_noop_bulk", this); controller.registerHandler(PUT, "/{index}/_noop_bulk", this); - controller.registerHandler(POST, "/{index}/{type}/_noop_bulk", this); - controller.registerHandler(PUT, "/{index}/{type}/_noop_bulk", this); } @Override diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/RestNoopSearchAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/RestNoopSearchAction.java index 39c9510b8a231..e2e12f0761263 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/RestNoopSearchAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/search/RestNoopSearchAction.java @@ -38,8 +38,6 @@ public RestNoopSearchAction(Settings settings, RestController controller) { controller.registerHandler(POST, "/_noop_search", this); controller.registerHandler(GET, "/{index}/_noop_search", this); controller.registerHandler(POST, "/{index}/_noop_search", this); - controller.registerHandler(GET, "/{index}/{type}/_noop_search", this); - controller.registerHandler(POST, "/{index}/{type}/_noop_search", this); } @Override diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java index 2c46b6f694add..4d3593de09031 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java @@ -65,10 +65,6 @@ public RestMultiSearchTemplateAction(Settings settings, RestController controlle controller.registerHandler(POST, "/_msearch/template", this); controller.registerHandler(GET, "/{index}/_msearch/template", this); controller.registerHandler(POST, "/{index}/_msearch/template", this); - - // Deprecated typed endpoints. - controller.registerHandler(GET, "/{index}/{type}/_msearch/template", this); - controller.registerHandler(POST, "/{index}/{type}/_msearch/template", this); } @Override diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java index 70a12f0c8bf56..f80d6ef43d05e 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestSearchTemplateAction.java @@ -54,10 +54,6 @@ public RestSearchTemplateAction(Settings settings, RestController controller) { controller.registerHandler(POST, "/_search/template", this); controller.registerHandler(GET, "/{index}/_search/template", this); controller.registerHandler(POST, "/{index}/_search/template", this); - - // Deprecated typed endpoints. - controller.registerHandler(GET, "/{index}/{type}/_search/template", this); - controller.registerHandler(POST, "/{index}/{type}/_search/template", this); } @Override diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java index be232ca7c402f..5d4d140131a14 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/RestDeleteByQueryAction.java @@ -35,7 +35,6 @@ public class RestDeleteByQueryAction extends AbstractBulkByQueryRestHandler Date: Mon, 29 Apr 2019 13:27:13 +0100 Subject: [PATCH 2/2] Fixes Tests --- .../RestMultiSearchTemplateActionTests.java | 66 ------------------- .../RestSearchTemplateActionTests.java | 61 ----------------- 2 files changed, 127 deletions(-) delete mode 100644 modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateActionTests.java delete mode 100644 modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/RestSearchTemplateActionTests.java diff --git a/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateActionTests.java b/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateActionTests.java deleted file mode 100644 index eacb1e3c4e803..0000000000000 --- a/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateActionTests.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.script.mustache; - -import org.elasticsearch.common.bytes.BytesArray; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.test.rest.FakeRestRequest; -import org.elasticsearch.test.rest.RestActionTestCase; -import org.junit.Before; - -import java.nio.charset.StandardCharsets; - -public class RestMultiSearchTemplateActionTests extends RestActionTestCase { - - @Before - public void setUpAction() { - new RestMultiSearchTemplateAction(Settings.EMPTY, controller()); - } - - public void testTypeInPath() { - String content = "{ \"index\": \"some_index\" } \n" + - "{\"source\": {\"query\" : {\"match_all\" :{}}}} \n"; - BytesArray bytesContent = new BytesArray(content.getBytes(StandardCharsets.UTF_8)); - - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(RestRequest.Method.GET) - .withPath("/some_index/some_type/_msearch/template") - .withContent(bytesContent, XContentType.JSON) - .build(); - - dispatchRequest(request); - assertWarnings(RestMultiSearchTemplateAction.TYPES_DEPRECATION_MESSAGE); - } - - public void testTypeInBody() { - String content = "{ \"index\": \"some_index\", \"type\": \"some_type\" } \n" + - "{\"source\": {\"query\" : {\"match_all\" :{}}}} \n"; - BytesArray bytesContent = new BytesArray(content.getBytes(StandardCharsets.UTF_8)); - - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) - .withPath("/some_index/_msearch/template") - .withContent(bytesContent, XContentType.JSON) - .build(); - - dispatchRequest(request); - assertWarnings(RestMultiSearchTemplateAction.TYPES_DEPRECATION_MESSAGE); - } -} diff --git a/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/RestSearchTemplateActionTests.java b/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/RestSearchTemplateActionTests.java deleted file mode 100644 index 0da8afbae0402..0000000000000 --- a/modules/lang-mustache/src/test/java/org/elasticsearch/script/mustache/RestSearchTemplateActionTests.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.script.mustache; - -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.action.search.RestSearchAction; -import org.elasticsearch.test.rest.FakeRestRequest; -import org.elasticsearch.test.rest.RestActionTestCase; -import org.junit.Before; - -import java.util.HashMap; -import java.util.Map; - -public class RestSearchTemplateActionTests extends RestActionTestCase { - - @Before - public void setUpAction() { - new RestSearchTemplateAction(Settings.EMPTY, controller()); - } - - public void testTypeInPath() { - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(RestRequest.Method.GET) - .withPath("/some_index/some_type/_search/template") - .build(); - - dispatchRequest(request); - assertWarnings(RestSearchAction.TYPES_DEPRECATION_MESSAGE); - } - - public void testTypeParameter() { - Map params = new HashMap<>(); - params.put("type", "some_type"); - - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(RestRequest.Method.GET) - .withPath("/some_index/_search/template") - .withParams(params) - .build(); - - dispatchRequest(request); - assertWarnings(RestSearchAction.TYPES_DEPRECATION_MESSAGE); - } -}