forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Get Snapshottable Features endpoint to
_features
(elastic#69755
) The endpoint `_snapshottable_features` is long and implies incorrect things about this API - it is used not just for snapshots, but also for the upcoming reset API. Following discussions on the team, this commit changes the endpoint to `_features` and removes the connection between this API and snapshots, as snapshots are not the only use for the output of this API.
- Loading branch information
Showing
20 changed files
with
184 additions
and
100 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
client/rest-high-level/src/main/java/org/elasticsearch/client/FeaturesClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.client.snapshots.GetFeaturesRequest; | ||
import org.elasticsearch.client.snapshots.GetFeaturesResponse; | ||
|
||
import java.io.IOException; | ||
|
||
import static java.util.Collections.emptySet; | ||
|
||
/** | ||
* A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Snapshot API. | ||
* <p> | ||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/features-apis.html">Snapshot API on elastic.co</a> | ||
*/ | ||
public class FeaturesClient { | ||
private final RestHighLevelClient restHighLevelClient; | ||
|
||
FeaturesClient(RestHighLevelClient restHighLevelClient) { | ||
this.restHighLevelClient = restHighLevelClient; | ||
} | ||
|
||
/** | ||
* Get a list of features which can be included in a snapshot as feature states. | ||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-features-api.html"> Get Snapshottable | ||
* Features API on elastic.co</a> | ||
* | ||
* @param getFeaturesRequest the request | ||
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized | ||
* @return the response | ||
* @throws IOException in case there is a problem sending the request or parsing back the response | ||
*/ | ||
public GetFeaturesResponse getFeatures(GetFeaturesRequest getFeaturesRequest, RequestOptions options) | ||
throws IOException { | ||
return restHighLevelClient.performRequestAndParseEntity( | ||
getFeaturesRequest, | ||
FeaturesRequestConverters::getFeatures, | ||
options, | ||
GetFeaturesResponse::parse, | ||
emptySet() | ||
); | ||
} | ||
|
||
/** | ||
* Asynchronously get a list of features which can be included in a snapshot as feature states. | ||
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-features-api.html"> Get Snapshottable | ||
* Features API on elastic.co</a> | ||
* | ||
* @param getFeaturesRequest the request | ||
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized | ||
* @param listener the listener to be notified upon request completion | ||
* @return cancellable that may be used to cancel the request | ||
*/ | ||
public Cancellable getFeaturesAsync( | ||
GetFeaturesRequest getFeaturesRequest, RequestOptions options, | ||
ActionListener<GetFeaturesResponse> listener) { | ||
return restHighLevelClient.performRequestAsyncAndParseEntity( | ||
getFeaturesRequest, | ||
FeaturesRequestConverters::getFeatures, | ||
options, | ||
GetFeaturesResponse::parse, | ||
listener, | ||
emptySet() | ||
); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
client/rest-high-level/src/main/java/org/elasticsearch/client/FeaturesRequestConverters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.apache.http.client.methods.HttpGet; | ||
import org.elasticsearch.client.snapshots.GetFeaturesRequest; | ||
|
||
public class FeaturesRequestConverters { | ||
|
||
private FeaturesRequestConverters() {} | ||
|
||
static Request getFeatures(GetFeaturesRequest getFeaturesRequest) { | ||
String endpoint = "/_features"; | ||
Request request = new Request(HttpGet.METHOD_NAME, endpoint); | ||
RequestConverters.Params parameters = new RequestConverters.Params(); | ||
parameters.withMasterTimeout(getFeaturesRequest.masterNodeTimeout()); | ||
request.addParameters(parameters.asMap()); | ||
return request; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
client/rest-high-level/src/test/java/org/elasticsearch/client/FeaturesIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.client; | ||
|
||
import org.elasticsearch.client.snapshots.GetFeaturesRequest; | ||
import org.elasticsearch.client.snapshots.GetFeaturesResponse; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.hamcrest.Matchers.greaterThan; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
public class FeaturesIT extends ESRestHighLevelClientTestCase { | ||
public void testGetFeatures() throws IOException { | ||
GetFeaturesRequest request = new GetFeaturesRequest(); | ||
|
||
GetFeaturesResponse response = execute(request, | ||
highLevelClient().features()::getFeatures, highLevelClient().features()::getFeaturesAsync); | ||
|
||
assertThat(response, notNullValue()); | ||
assertThat(response.getFeatures(), notNullValue()); | ||
assertThat(response.getFeatures().size(), greaterThan(1)); | ||
assertTrue(response.getFeatures().stream().anyMatch(feature -> "tasks".equals(feature.getFeatureName()))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[[features-apis]] | ||
== Features APIs | ||
|
||
You can use the following APIs to introspect and manage Features provided | ||
by Elasticsearch and Elasticsearch plugins. | ||
|
||
[discrete] | ||
=== Features APIs | ||
* <<get-features-api,Get Features API>> | ||
|
||
include::get-features-api.asciidoc[] |
Oops, something went wrong.