Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate xpack and typed endpoints for graph explore api #74230

Merged
merged 4 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}

}