diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java index a114774cb72c8..ac0e5988a2472 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java @@ -205,6 +205,8 @@ public class RestHighLevelClient implements Closeable { private final SnapshotClient snapshotClient = new SnapshotClient(this); private final TasksClient tasksClient = new TasksClient(this); private final XPackClient xPackClient = new XPackClient(this); + private final WatcherClient watcherClient = new WatcherClient(this); + private final LicenseClient licenseClient = new LicenseClient(this); /** * Creates a {@link RestHighLevelClient} given the low level {@link RestClientBuilder} that allows to build the @@ -296,18 +298,38 @@ public final TasksClient tasks() { } /** - * A wrapper for the {@link RestHighLevelClient} that provides methods for - * accessing the Elastic Licensed X-Pack APIs that are shipped with the - * default distribution of Elasticsearch. All of these APIs will 404 if run - * against the OSS distribution of Elasticsearch. + * Provides methods for accessing the Elastic Licensed X-Pack Info + * and Usage APIs that are shipped with the default distribution of + * Elasticsearch. All of these APIs will 404 if run against the OSS + * distribution of Elasticsearch. *

- * See the - * X-Pack APIs on elastic.co for more information. + * See the + * Info APIs on elastic.co for more information. */ public final XPackClient xpack() { return xPackClient; } + /** + * Provides methods for accessing the Elastic Licensed Watcher APIs that + * are shipped with the default distribution of Elasticsearch. All of + * these APIs will 404 if run against the OSS distribution of Elasticsearch. + *

+ * See the + * Watcher APIs on elastic.co for more information. + */ + public WatcherClient watcher() { return watcherClient; } + + /** + * Provides methods for accessing the Elastic Licensed Licensing APIs that + * are shipped with the default distribution of Elasticsearch. All of + * these APIs will 404 if run against the OSS distribution of Elasticsearch. + *

+ * See the + * Licensing APIs on elastic.co for more information. + */ + public LicenseClient license() { return licenseClient; } + /** * Executes a bulk request using the Bulk API. * See Bulk API on elastic.co diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/XPackClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/XPackClient.java index 1401376527df2..2af49ba1a1b73 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/XPackClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/XPackClient.java @@ -41,17 +41,9 @@ public final class XPackClient { private final RestHighLevelClient restHighLevelClient; - private final WatcherClient watcherClient; - private final LicenseClient licenseClient; XPackClient(RestHighLevelClient restHighLevelClient) { this.restHighLevelClient = restHighLevelClient; - this.watcherClient = new WatcherClient(restHighLevelClient); - this.licenseClient = new LicenseClient(restHighLevelClient); - } - - public WatcherClient watcher() { - return watcherClient; } /** @@ -102,15 +94,4 @@ public void usageAsync(XPackUsageRequest request, RequestOptions options, Action restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::xpackUsage, options, XPackUsageResponse::fromXContent, listener, emptySet()); } - - /** - * A wrapper for the {@link RestHighLevelClient} that provides methods for - * accessing the Elastic Licensing APIs. - *

- * See the - * X-Pack APIs on elastic.co for more information. - */ - public LicenseClient license() { - return licenseClient; - } } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java index 9591b5815ec74..a75e89dc6cbbb 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java @@ -774,7 +774,9 @@ public void testApiNamingConventions() throws Exception { method.isAnnotationPresent(Deprecated.class)); } else { //TODO xpack api are currently ignored, we need to load xpack yaml spec too - if (apiName.startsWith("xpack.") == false) { + if (apiName.startsWith("xpack.") == false && + apiName.startsWith("license.") == false && + apiName.startsWith("watcher.") == false) { apiNotFound.add(apiName); } } diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherIT.java index 67d1def323a13..491992735afbf 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherIT.java @@ -46,7 +46,7 @@ private PutWatchResponse createWatch(String watchId) throws Exception { "}"; BytesReference bytesReference = new BytesArray(json); PutWatchRequest putWatchRequest = new PutWatchRequest(watchId, bytesReference, XContentType.JSON); - return highLevelClient().xpack().watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT); + return highLevelClient().watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT); } public void testDeleteWatch() throws Exception { @@ -54,7 +54,7 @@ public void testDeleteWatch() throws Exception { { String watchId = randomAlphaOfLength(10); createWatch(watchId); - DeleteWatchResponse deleteWatchResponse = highLevelClient().xpack().watcher().deleteWatch(new DeleteWatchRequest(watchId), + DeleteWatchResponse deleteWatchResponse = highLevelClient().watcher().deleteWatch(new DeleteWatchRequest(watchId), RequestOptions.DEFAULT); assertThat(deleteWatchResponse.getId(), is(watchId)); assertThat(deleteWatchResponse.getVersion(), is(2L)); @@ -64,7 +64,7 @@ public void testDeleteWatch() throws Exception { // delete watch that does not exist { String watchId = randomAlphaOfLength(10); - DeleteWatchResponse deleteWatchResponse = highLevelClient().xpack().watcher().deleteWatch(new DeleteWatchRequest(watchId), + DeleteWatchResponse deleteWatchResponse = highLevelClient().watcher().deleteWatch(new DeleteWatchRequest(watchId), RequestOptions.DEFAULT); assertThat(deleteWatchResponse.getId(), is(watchId)); assertThat(deleteWatchResponse.getVersion(), is(1L)); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/LicensingDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/LicensingDocumentationIT.java index 776c990610d18..0f516d5d37dc4 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/LicensingDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/LicensingDocumentationIT.java @@ -62,7 +62,7 @@ public void testPutLicense() throws Exception { request.setLicenseDefinition(license); // <1> request.setAcknowledge(false); // <2> - PutLicenseResponse response = client.xpack().license().putLicense(request, RequestOptions.DEFAULT); + PutLicenseResponse response = client.license().putLicense(request, RequestOptions.DEFAULT); //end::put-license-execute //tag::put-license-response @@ -98,7 +98,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::put-license-execute-async - client.xpack().license().putLicenseAsync( + client.license().putLicenseAsync( request, RequestOptions.DEFAULT, listener); // <1> // end::put-license-execute-async diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/WatcherDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/WatcherDocumentationIT.java index 47f8510b74640..707997d1f3103 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/WatcherDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/WatcherDocumentationIT.java @@ -49,7 +49,7 @@ public void testWatcher() throws Exception { "}"); PutWatchRequest request = new PutWatchRequest("my_watch_id", watch, XContentType.JSON); request.setActive(false); // <1> - PutWatchResponse response = client.xpack().watcher().putWatch(request, RequestOptions.DEFAULT); + PutWatchResponse response = client.watcher().putWatch(request, RequestOptions.DEFAULT); //end::x-pack-put-watch-execute //tag::x-pack-put-watch-response @@ -85,7 +85,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::x-pack-put-watch-execute-async - client.xpack().watcher().putWatchAsync(request, RequestOptions.DEFAULT, listener); // <1> + client.watcher().putWatchAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::x-pack-put-watch-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); @@ -94,7 +94,7 @@ public void onFailure(Exception e) { { //tag::x-pack-delete-watch-execute DeleteWatchRequest request = new DeleteWatchRequest("my_watch_id"); - DeleteWatchResponse response = client.xpack().watcher().deleteWatch(request, RequestOptions.DEFAULT); + DeleteWatchResponse response = client.watcher().deleteWatch(request, RequestOptions.DEFAULT); //end::x-pack-delete-watch-execute //tag::x-pack-delete-watch-response @@ -125,7 +125,7 @@ public void onFailure(Exception e) { listener = new LatchedActionListener<>(listener, latch); // tag::x-pack-delete-watch-execute-async - client.xpack().watcher().deleteWatchAsync(request, RequestOptions.DEFAULT, listener); // <1> + client.watcher().deleteWatchAsync(request, RequestOptions.DEFAULT, listener); // <1> // end::x-pack-delete-watch-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS));