Skip to content

Commit

Permalink
Deprecate xpack and typed endpoints for graph explore api (elastic#74230
Browse files Browse the repository at this point in the history
)

Previously the /{index}/{type}/_xpack/graph/_explore api was indicating to use /{index}/{type}/_graph/explore which is also deprecated.
This commit deprecates all typed endpoints
  • Loading branch information
pgomulka authored Jun 29, 2021
1 parent 012cc4b commit 5d71612
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,16 @@ public List<Route> 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()
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<RestRequest.Method, String> 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);
}
}

}

0 comments on commit 5d71612

Please sign in to comment.