diff --git a/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java b/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java index f30208b7f710a..58c13783380b8 100644 --- a/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java +++ b/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java @@ -73,10 +73,16 @@ public List routes() { .replaces(GET, "/{index}" + URI_BASE + "/graph/_explore", RestApiVersion.V_7).build(), Route.builder(POST, "/{index}/_graph/explore") .replaces(POST, "/{index}" + URI_BASE + "/graph/_explore", RestApiVersion.V_7).build(), + + Route.builder(GET, "/{index}/{type}" + URI_BASE + "/graph/_explore") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7).build(), + Route.builder(POST, "/{index}/{type}" + URI_BASE + "/graph/_explore") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7).build(), + Route.builder(GET, "/{index}/{type}/_graph/explore") - .replaces(GET, "/{index}/{type}" + URI_BASE + "/graph/_explore", RestApiVersion.V_7).build(), - Route.builder(POST, "/{index}/{type}_graph/explore") - .replaces(POST, "/{index}/{type}" + URI_BASE + "/graph/_explore", RestApiVersion.V_7).build() + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7).build(), + Route.builder(POST, "/{index}/{type}/_graph/explore") + .deprecated(TYPES_DEPRECATION_MESSAGE, RestApiVersion.V_7).build() )); } diff --git a/x-pack/plugin/graph/src/test/java/org/elasticsearch/xpack/graph/rest/action/RestGraphActionTests.java b/x-pack/plugin/graph/src/test/java/org/elasticsearch/xpack/graph/rest/action/RestGraphActionTests.java index ea15ec6776fd0..19f1fedda01f0 100644 --- a/x-pack/plugin/graph/src/test/java/org/elasticsearch/xpack/graph/rest/action/RestGraphActionTests.java +++ b/x-pack/plugin/graph/src/test/java/org/elasticsearch/xpack/graph/rest/action/RestGraphActionTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.ShardOperationFailedException; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.core.Tuple; import org.elasticsearch.protocol.xpack.graph.GraphExploreResponse; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.test.rest.FakeRestRequest; @@ -26,25 +27,34 @@ public void setUpAction() { } public void testTypeInPath() { - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(RestRequest.Method.GET) - .withPath("/some_index/some_type/_graph/explore") - .withContent(new BytesArray("{}"), XContentType.JSON) - .build(); - // We're not actually testing anything to do with the client, but need to set this so it doesn't fail the test for being unset. - verifyingClient.setExecuteVerifier( - (arg1, arg2) -> new GraphExploreResponse( - 0, - false, - new ShardOperationFailedException[0], - new HashMap<>(), - new HashMap<>(), - false - ) - ); - - dispatchRequest(request); - assertWarnings(RestGraphAction.TYPES_DEPRECATION_MESSAGE); + for (Tuple methodAndPath : + org.elasticsearch.core.List.of( + Tuple.tuple(RestRequest.Method.GET, "/some_index/some_type/_graph/explore"), + Tuple.tuple(RestRequest.Method.POST, "/some_index/some_type/_graph/explore"), + Tuple.tuple(RestRequest.Method.GET, "/some_index/some_type/_xpack/graph/_explore"), + Tuple.tuple(RestRequest.Method.POST, "/some_index/some_type/_xpack/graph/_explore") + )) { + + RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) + .withMethod(methodAndPath.v1()) + .withPath(methodAndPath.v2()) + .withContent(new BytesArray("{}"), XContentType.JSON) + .build(); + // We're not actually testing anything to do with the client, + // but need to set this so it doesn't fail the test for being unset. + verifyingClient.setExecuteVerifier( + (arg1, arg2) -> new GraphExploreResponse( + 0, + false, + new ShardOperationFailedException[0], + new HashMap<>(), + new HashMap<>(), + false + ) + ); + + dispatchRequest(request); + assertWarnings(RestGraphAction.TYPES_DEPRECATION_MESSAGE); + } } - }