Skip to content

Commit 1170ab9

Browse files
committed
HLRC: Move commercial clients from XPackClient (#32596)
The commercial clients were improperly placed into XPackClient, which is a wrapper for the miscellaneous usage and info APIs. This commit moves them into the HLRC.
1 parent d3d4b57 commit 1170ab9

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ public class RestHighLevelClient implements Closeable {
203203
private final SnapshotClient snapshotClient = new SnapshotClient(this);
204204
private final TasksClient tasksClient = new TasksClient(this);
205205
private final XPackClient xPackClient = new XPackClient(this);
206+
private final WatcherClient watcherClient = new WatcherClient(this);
206207

207208
/**
208209
* Creates a {@link RestHighLevelClient} given the low level {@link RestClientBuilder} that allows to build the
@@ -294,18 +295,28 @@ public final TasksClient tasks() {
294295
}
295296

296297
/**
297-
* A wrapper for the {@link RestHighLevelClient} that provides methods for
298-
* accessing the Elastic Licensed X-Pack APIs that are shipped with the
299-
* default distribution of Elasticsearch. All of these APIs will 404 if run
300-
* against the OSS distribution of Elasticsearch.
298+
* Provides methods for accessing the Elastic Licensed X-Pack Info
299+
* and Usage APIs that are shipped with the default distribution of
300+
* Elasticsearch. All of these APIs will 404 if run against the OSS
301+
* distribution of Elasticsearch.
301302
* <p>
302-
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/xpack-api.html">
303-
* X-Pack APIs on elastic.co</a> for more information.
303+
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html">
304+
* Info APIs on elastic.co</a> for more information.
304305
*/
305306
public final XPackClient xpack() {
306307
return xPackClient;
307308
}
308309

310+
/**
311+
* Provides methods for accessing the Elastic Licensed Watcher APIs that
312+
* are shipped with the default distribution of Elasticsearch. All of
313+
* these APIs will 404 if run against the OSS distribution of Elasticsearch.
314+
* <p>
315+
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api.html">
316+
* Watcher APIs on elastic.co</a> for more information.
317+
*/
318+
public WatcherClient watcher() { return watcherClient; }
319+
309320
/**
310321
* Executes a bulk request using the Bulk API.
311322
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html">Bulk API on elastic.co</a>

client/rest-high-level/src/main/java/org/elasticsearch/client/XPackClient.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,9 @@
4141
public final class XPackClient {
4242

4343
private final RestHighLevelClient restHighLevelClient;
44-
private final WatcherClient watcherClient;
4544

4645
XPackClient(RestHighLevelClient restHighLevelClient) {
4746
this.restHighLevelClient = restHighLevelClient;
48-
this.watcherClient = new WatcherClient(restHighLevelClient);
49-
}
50-
51-
public WatcherClient watcher() {
52-
return watcherClient;
5347
}
5448

5549
/**

client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,8 @@ public void testApiNamingConventions() throws Exception {
775775
method.isAnnotationPresent(Deprecated.class));
776776
} else {
777777
//TODO xpack api are currently ignored, we need to load xpack yaml spec too
778-
if (apiName.startsWith("xpack.") == false) {
778+
if (apiName.startsWith("xpack.") == false &&
779+
apiName.startsWith("watcher.") == false) {
779780
apiNotFound.add(apiName);
780781
}
781782
}

client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void testPutWatch() throws Exception {
3737
"}";
3838
BytesReference bytesReference = new BytesArray(json);
3939
PutWatchRequest putWatchRequest = new PutWatchRequest(watchId, bytesReference, XContentType.JSON);
40-
PutWatchResponse putWatchResponse = highLevelClient().xpack().watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT);
40+
PutWatchResponse putWatchResponse = highLevelClient().watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT);
4141
assertThat(putWatchResponse.isCreated(), is(true));
4242
assertThat(putWatchResponse.getId(), is(watchId));
4343
assertThat(putWatchResponse.getVersion(), is(1L));

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/WatcherDocumentationIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void testPutWatch() throws Exception {
4747
"}");
4848
PutWatchRequest request = new PutWatchRequest("my_watch_id", watch, XContentType.JSON);
4949
request.setActive(false); // <1>
50-
PutWatchResponse response = client.xpack().watcher().putWatch(request, RequestOptions.DEFAULT);
50+
PutWatchResponse response = client.watcher().putWatch(request, RequestOptions.DEFAULT);
5151
//end::x-pack-put-watch-execute
5252

5353
//tag::x-pack-put-watch-response
@@ -83,7 +83,7 @@ public void onFailure(Exception e) {
8383
listener = new LatchedActionListener<>(listener, latch);
8484

8585
// tag::x-pack-put-watch-execute-async
86-
client.xpack().watcher().putWatchAsync(request, RequestOptions.DEFAULT, listener); // <1>
86+
client.watcher().putWatchAsync(request, RequestOptions.DEFAULT, listener); // <1>
8787
// end::x-pack-put-watch-execute-async
8888

8989
assertTrue(latch.await(30L, TimeUnit.SECONDS));

0 commit comments

Comments
 (0)