From 1c8b3b04fd1717be98a96a61959477a9e2a337be Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Tue, 4 Dec 2018 09:28:23 -0600 Subject: [PATCH 1/7] Deprecate X-Pack centric watcher endpoints --- .../client/WatcherRequestConverters.java | 15 +++--- .../org/elasticsearch/client/WatcherIT.java | 2 +- .../client/WatcherRequestConvertersTests.java | 18 +++---- .../documentation/WatcherDocumentationIT.java | 2 +- .../en/rest-api/watcher/ack-watch.asciidoc | 20 ++++---- .../rest-api/watcher/activate-watch.asciidoc | 6 +-- .../watcher/deactivate-watch.asciidoc | 6 +-- .../en/rest-api/watcher/delete-watch.asciidoc | 4 +- .../rest-api/watcher/execute-watch.asciidoc | 16 +++--- .../en/rest-api/watcher/get-watch.asciidoc | 4 +- .../en/rest-api/watcher/put-watch.asciidoc | 6 +-- .../docs/en/rest-api/watcher/start.asciidoc | 4 +- .../docs/en/rest-api/watcher/stats.asciidoc | 12 ++--- x-pack/docs/en/rest-api/watcher/stop.asciidoc | 4 +- x-pack/docs/en/watcher/actions.asciidoc | 8 +-- .../example-watch-clusterstatus.asciidoc | 12 ++--- .../example-watch-meetupdata.asciidoc | 4 +- .../watching-time-series-data.asciidoc | 4 +- .../docs/en/watcher/getting-started.asciidoc | 8 +-- .../en/watcher/how-watcher-works.asciidoc | 2 +- .../authz/privilege/ClusterPrivilege.java | 4 +- .../authz/store/ReservedRolesStore.java | 6 +-- .../transport/actions/ack/AckWatchAction.java | 2 +- .../actions/activate/ActivateWatchAction.java | 2 +- .../actions/delete/DeleteWatchAction.java | 2 +- .../actions/execute/ExecuteWatchAction.java | 2 +- .../transport/actions/get/GetWatchAction.java | 2 +- .../transport/actions/put/PutWatchAction.java | 2 +- .../actions/service/WatcherServiceAction.java | 2 +- .../actions/stats/WatcherStatsAction.java | 2 +- .../http/ClusterAlertHttpResource.java | 6 +-- .../http/ClusterAlertHttpResourceTests.java | 22 ++++---- .../exporter/http/HttpExporterIT.java | 6 +-- .../http/HttpExporterResourceTests.java | 26 +++++----- .../xpack/test/rest/XPackRestIT.java | 2 +- .../api/xpack.watcher.ack_watch.json | 4 +- .../api/xpack.watcher.activate_watch.json | 4 +- .../api/xpack.watcher.deactivate_watch.json | 4 +- .../api/xpack.watcher.delete_watch.json | 4 +- .../api/xpack.watcher.execute_watch.json | 4 +- .../api/xpack.watcher.get_watch.json | 4 +- .../api/xpack.watcher.put_watch.json | 4 +- .../api/xpack.watcher.start.json | 4 +- .../api/xpack.watcher.stats.json | 4 +- .../rest-api-spec/api/xpack.watcher.stop.json | 4 +- .../watcher/rest/WatcherRestHandler.java | 2 +- .../xpack/restart/FullClusterRestartIT.java | 50 +++++++++---------- .../upgrades/WatcherRestartIT.java | 8 +-- .../MonitoringWithWatcherRestIT.java | 4 +- .../SmokeTestWatcherWithSecurityIT.java | 10 ++-- .../SmokeTestWatcherTestSuiteIT.java | 14 +++--- 51 files changed, 185 insertions(+), 188 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java index 1da7ef4c617ff..d7c895feaec43 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java @@ -42,7 +42,6 @@ private WatcherRequestConverters() {} static Request startWatchService(StartWatchServiceRequest startWatchServiceRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack") .addPathPartAsIs("watcher") .addPathPartAsIs("_start") .build(); @@ -52,7 +51,6 @@ static Request startWatchService(StartWatchServiceRequest startWatchServiceReque static Request stopWatchService(StopWatchServiceRequest stopWatchServiceRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack") .addPathPartAsIs("watcher") .addPathPartAsIs("_stop") .build(); @@ -62,7 +60,7 @@ static Request stopWatchService(StopWatchServiceRequest stopWatchServiceRequest) static Request putWatch(PutWatchRequest putWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack", "watcher", "watch") + .addPathPartAsIs("watcher", "watch") .addPathPart(putWatchRequest.getId()) .build(); @@ -80,7 +78,7 @@ static Request putWatch(PutWatchRequest putWatchRequest) { static Request getWatch(GetWatchRequest getWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack", "watcher", "watch") + .addPathPartAsIs("watcher", "watch") .addPathPart(getWatchRequest.getId()) .build(); @@ -89,7 +87,6 @@ static Request getWatch(GetWatchRequest getWatchRequest) { static Request deactivateWatch(DeactivateWatchRequest deactivateWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack") .addPathPartAsIs("watcher") .addPathPartAsIs("watch") .addPathPart(deactivateWatchRequest.getWatchId()) @@ -100,7 +97,7 @@ static Request deactivateWatch(DeactivateWatchRequest deactivateWatchRequest) { static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack", "watcher", "watch") + .addPathPartAsIs("watcher", "watch") .addPathPart(deleteWatchRequest.getId()) .build(); @@ -110,7 +107,7 @@ static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) { public static Request ackWatch(AckWatchRequest ackWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack", "watcher", "watch") + .addPathPartAsIs("watcher", "watch") .addPathPart(ackWatchRequest.getWatchId()) .addPathPartAsIs("_ack") .addCommaSeparatedPathParts(ackWatchRequest.getActionIds()) @@ -121,7 +118,7 @@ public static Request ackWatch(AckWatchRequest ackWatchRequest) { static Request activateWatch(ActivateWatchRequest activateWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack", "watcher", "watch") + .addPathPartAsIs("watcher", "watch") .addPathPart(activateWatchRequest.getWatchId()) .addPathPartAsIs("_activate") .build(); @@ -130,7 +127,7 @@ static Request activateWatch(ActivateWatchRequest activateWatchRequest) { } static Request watcherStats(WatcherStatsRequest watcherStatsRequest) { - RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder().addPathPartAsIs("_xpack", "watcher", "stats"); + RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder().addPathPartAsIs("watcher", "stats"); String endpoint = builder.build(); Request request = new Request(HttpGet.METHOD_NAME, endpoint); RequestConverters.Params parameters = new RequestConverters.Params(request); 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 8d1429d319bb5..3c514917c0a1e 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 @@ -146,7 +146,7 @@ public void testAckWatch() throws Exception { assertEquals(AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION, actionStatus.ackStatus().state()); // TODO: use the high-level REST client here once it supports 'execute watch'. - Request executeWatchRequest = new Request("POST", "_xpack/watcher/watch/" + watchId + "/_execute"); + Request executeWatchRequest = new Request("POST", "watcher/watch/" + watchId + "/_execute"); executeWatchRequest.setJsonEntity("{ \"record_execution\": true }"); Response executeResponse = client().performRequest(executeWatchRequest); assertEquals(RestStatus.OK.getStatus(), executeResponse.getStatusLine().getStatusCode()); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java index ff7050fd67ce7..c888ef7e2314a 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java @@ -56,13 +56,13 @@ public class WatcherRequestConvertersTests extends ESTestCase { public void testStartWatchService() { Request request = WatcherRequestConverters.startWatchService(new StartWatchServiceRequest()); assertEquals(HttpPost.METHOD_NAME, request.getMethod()); - assertEquals("/_xpack/watcher/_start", request.getEndpoint()); + assertEquals("/watcher/_start", request.getEndpoint()); } public void testStopWatchService() { Request request = WatcherRequestConverters.stopWatchService(new StopWatchServiceRequest()); assertEquals(HttpPost.METHOD_NAME, request.getMethod()); - assertEquals("/_xpack/watcher/_stop", request.getEndpoint()); + assertEquals("/watcher/_stop", request.getEndpoint()); } public void testPutWatch() throws Exception { @@ -84,7 +84,7 @@ public void testPutWatch() throws Exception { Request request = WatcherRequestConverters.putWatch(putWatchRequest); assertEquals(HttpPut.METHOD_NAME, request.getMethod()); - assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint()); + assertEquals("/watcher/watch/" + watchId, request.getEndpoint()); assertEquals(expectedParams, request.getParameters()); assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters())); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -98,7 +98,7 @@ public void testGetWatch() throws Exception { Request request = WatcherRequestConverters.getWatch(getWatchRequest); assertEquals(HttpGet.METHOD_NAME, request.getMethod()); - assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint()); + assertEquals("/watcher/watch/" + watchId, request.getEndpoint()); assertThat(request.getEntity(), nullValue()); } @@ -108,7 +108,7 @@ public void testDeactivateWatch() { Request request = WatcherRequestConverters.deactivateWatch(deactivateWatchRequest); assertEquals(HttpPut.METHOD_NAME, request.getMethod()); - assertEquals("/_xpack/watcher/watch/" + watchId + "/_deactivate", request.getEndpoint()); + assertEquals("/watcher/watch/" + watchId + "/_deactivate", request.getEndpoint()); } public void testDeleteWatch() { @@ -117,7 +117,7 @@ public void testDeleteWatch() { Request request = WatcherRequestConverters.deleteWatch(deleteWatchRequest); assertEquals(HttpDelete.METHOD_NAME, request.getMethod()); - assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint()); + assertEquals("/watcher/watch/" + watchId, request.getEndpoint()); assertThat(request.getEntity(), nullValue()); } @@ -131,7 +131,7 @@ public void testAckWatch() { assertEquals(HttpPut.METHOD_NAME, request.getMethod()); StringJoiner expectedEndpoint = new StringJoiner("/", "/", "") - .add("_xpack").add("watcher").add("watch").add(watchId).add("_ack"); + .add("watcher").add("watch").add(watchId).add("_ack"); if (ackWatchRequest.getActionIds().length > 0) { String actionsParam = String.join(",", ackWatchRequest.getActionIds()); expectedEndpoint.add(actionsParam); @@ -147,7 +147,7 @@ public void testActivateWatchRequestConversion() { Request request = WatcherRequestConverters.activateWatch(activateWatchRequest); assertEquals(HttpPut.METHOD_NAME, request.getMethod()); - assertEquals("/_xpack/watcher/watch/" + watchId + "/_activate", request.getEndpoint()); + assertEquals("/watcher/watch/" + watchId + "/_activate", request.getEndpoint()); assertThat(request.getEntity(), nullValue()); } @@ -158,7 +158,7 @@ public void testWatcherStatsRequest() { WatcherStatsRequest watcherStatsRequest = new WatcherStatsRequest(includeCurrent, includeQueued); Request request = WatcherRequestConverters.watcherStats(watcherStatsRequest); - assertThat(request.getEndpoint(), equalTo("/_xpack/watcher/stats")); + assertThat(request.getEndpoint(), equalTo("/watcher/stats")); assertThat(request.getMethod(), equalTo(HttpGet.METHOD_NAME)); if (includeCurrent || includeQueued) { assertThat(request.getParameters(), hasKey("metric")); 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 fc6dba9c8fc61..651b495769e84 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 @@ -298,7 +298,7 @@ public void testAckWatch() throws Exception { client.watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT); // TODO: use the high-level REST client here once it supports 'execute watch'. - Request executeWatchRequest = new Request("POST", "_xpack/watcher/watch/my_watch_id/_execute"); + Request executeWatchRequest = new Request("POST", "watcher/watch/my_watch_id/_execute"); executeWatchRequest.setJsonEntity("{ \"record_execution\": true }"); Response executeResponse = client().performRequest(executeWatchRequest); assertEquals(RestStatus.OK.getStatus(), executeResponse.getStatusLine().getStatusCode()); diff --git a/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc index f599f9f14459d..3ff4cf9635579 100644 --- a/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc @@ -14,9 +14,9 @@ execution. [float] ==== Request -`PUT _xpack/watcher/watch//_ack` + +`PUT watcher/watch//_ack` + -`PUT _xpack/watcher/watch//_ack/` +`PUT watcher/watch//_ack/` [float] ==== Path Parameters @@ -42,7 +42,7 @@ To demonstrate let's create a new watch: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/my_watch +PUT watcher/watch/my_watch { "trigger": { "schedule": { @@ -80,7 +80,7 @@ watch definition when you call the <>: [source,js] -------------------------------------------------- -GET _xpack/watcher/watch/my_watch +GET watcher/watch/my_watch -------------------------------------------------- // CONSOLE @@ -117,12 +117,12 @@ check the status: [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/my_watch/_execute +POST watcher/watch/my_watch/_execute { "record_execution" : true } -GET _xpack/watcher/watch/my_watch +GET watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[continued] @@ -172,8 +172,8 @@ Now we can acknowledge it: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/my_watch/_ack/test_index -GET _xpack/watcher/watch/my_watch +PUT watcher/watch/my_watch/_ack/test_index +GET watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[continued] @@ -226,7 +226,7 @@ comma-separated list of action ids: [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/my_watch/_ack/action1,action2 +POST watcher/watch/my_watch/_ack/action1,action2 -------------------------------------------------- // CONSOLE @@ -235,7 +235,7 @@ parameter: [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/my_watch/_ack +POST watcher/watch/my_watch/_ack -------------------------------------------------- // TEST[s/^/POST _xpack\/watcher\/watch\/my_watch\/_execute\n{ "record_execution" : true }\n/] // CONSOLE diff --git a/x-pack/docs/en/rest-api/watcher/activate-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/activate-watch.asciidoc index e853998415e96..fd14888a36774 100644 --- a/x-pack/docs/en/rest-api/watcher/activate-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/activate-watch.asciidoc @@ -9,7 +9,7 @@ API enables you to activate a currently inactive watch. [float] ==== Request -`PUT _xpack/watcher/watch//_activate` +`PUT watcher/watch//_activate` [float] ==== Path Parameters @@ -31,7 +31,7 @@ call the <>: [source,js] -------------------------------------------------- -GET _xpack/watcher/watch/my_watch +GET watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[setup:my_inactive_watch] @@ -62,7 +62,7 @@ You can activate the watch by executing the following API call: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/my_watch/_activate +PUT watcher/watch/my_watch/_activate -------------------------------------------------- // CONSOLE // TEST[setup:my_inactive_watch] diff --git a/x-pack/docs/en/rest-api/watcher/deactivate-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/deactivate-watch.asciidoc index ab5a7200907e1..9cfccaec59c9a 100644 --- a/x-pack/docs/en/rest-api/watcher/deactivate-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/deactivate-watch.asciidoc @@ -9,7 +9,7 @@ API enables you to deactivate a currently active watch. [float] ==== Request -`PUT _xpack/watcher/watch//_deactivate` +`PUT watcher/watch//_deactivate` [float] ==== Path Parameters @@ -30,7 +30,7 @@ call the <>: [source,js] -------------------------------------------------- -GET _xpack/watcher/watch/my_watch +GET watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[setup:my_active_watch] @@ -61,7 +61,7 @@ You can deactivate the watch by executing the following API call: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/my_watch/_deactivate +PUT watcher/watch/my_watch/_deactivate -------------------------------------------------- // CONSOLE // TEST[setup:my_active_watch] diff --git a/x-pack/docs/en/rest-api/watcher/delete-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/delete-watch.asciidoc index bedc60897e723..9daf58bc216bf 100644 --- a/x-pack/docs/en/rest-api/watcher/delete-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/delete-watch.asciidoc @@ -7,7 +7,7 @@ The DELETE watch API removes a watch from {watcher}. [float] ==== Request -`DELETE _xpack/watcher/watch/` +`DELETE watcher/watch/` [float] ==== Description @@ -42,7 +42,7 @@ The following example deletes a watch with the `my-watch` id: [source,js] -------------------------------------------------- -DELETE _xpack/watcher/watch/my_watch +DELETE watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[setup:my_active_watch] diff --git a/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc index 9b8505e089656..cd67658decc32 100644 --- a/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc @@ -9,9 +9,9 @@ watch execution for debugging purposes. [float] ==== Request -`POST _xpack/watcher/watch//_execute` + +`POST watcher/watch//_execute` + -`POST _xpack/watcher/watch/_execute` +`POST watcher/watch/_execute` [float] ==== Description @@ -137,7 +137,7 @@ The following example executes the `my_watch` watch: [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/my_watch/_execute +POST watcher/watch/my_watch/_execute -------------------------------------------------- // CONSOLE // TEST[setup:my_active_watch] @@ -146,7 +146,7 @@ The following example shows a comprehensive example of executing the `my-watch` [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/my_watch/_execute +POST watcher/watch/my_watch/_execute { "trigger_data" : { <1> "triggered_time" : "now", @@ -289,7 +289,7 @@ name with the action id: [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/my_watch/_execute +POST watcher/watch/my_watch/_execute { "action_modes" : { "action1" : "force_simulate", @@ -305,7 +305,7 @@ using `_all` as the action id: [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/my_watch/_execute +POST watcher/watch/my_watch/_execute { "action_modes" : { "_all" : "force_execute" @@ -319,7 +319,7 @@ The following example shows how to execute a watch inline: [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/_execute +POST watcher/watch/_execute { "watch" : { "trigger" : { "schedule" : { "interval" : "10s" } }, @@ -356,7 +356,7 @@ during the execution this condition will be ignored: [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/_execute +POST watcher/watch/_execute { "ignore_condition" : true, "watch" : { diff --git a/x-pack/docs/en/rest-api/watcher/get-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/get-watch.asciidoc index ee224f648634d..7359aa5908f8a 100644 --- a/x-pack/docs/en/rest-api/watcher/get-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/get-watch.asciidoc @@ -7,7 +7,7 @@ This API retrieves a watch by its ID. [float] ==== Request -`GET _xpack/watcher/watch/` +`GET watcher/watch/` [float] ==== Path Parameters @@ -29,7 +29,7 @@ The following example gets a watch with `my-watch` id: [source,js] -------------------------------------------------- -GET _xpack/watcher/watch/my_watch +GET watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[setup:my_active_watch] diff --git a/x-pack/docs/en/rest-api/watcher/put-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/put-watch.asciidoc index 41c078a9c9e1a..17ddb9b825820 100644 --- a/x-pack/docs/en/rest-api/watcher/put-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/put-watch.asciidoc @@ -8,7 +8,7 @@ existing one. [float] ==== Request -`PUT _xpack/watcher/watch/` +`PUT watcher/watch/` [float] ==== Description @@ -96,7 +96,7 @@ characteristics: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/my-watch +PUT watcher/watch/my-watch { "trigger" : { "schedule" : { "cron" : "0 0/1 * * * ?" } @@ -151,7 +151,7 @@ it to be inactive by default: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/my-watch?active=false +PUT watcher/watch/my-watch?active=false -------------------------------------------------- NOTE: If you omit the `active` parameter, the watch is active by default. diff --git a/x-pack/docs/en/rest-api/watcher/start.asciidoc b/x-pack/docs/en/rest-api/watcher/start.asciidoc index ffdec3326d5e0..81a1aaaaea199 100644 --- a/x-pack/docs/en/rest-api/watcher/start.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/start.asciidoc @@ -8,7 +8,7 @@ running. [float] ==== Request -`POST _xpack/watcher/_start` +`POST watcher/_start` ==== Authorization @@ -20,7 +20,7 @@ information, see {xpack-ref}/security-privileges.html[Security Privileges]. [source,js] -------------------------------------------------- -POST _xpack/watcher/_start +POST watcher/_start -------------------------------------------------- // CONSOLE diff --git a/x-pack/docs/en/rest-api/watcher/stats.asciidoc b/x-pack/docs/en/rest-api/watcher/stats.asciidoc index 3f875485ba006..d9b9f8e790c11 100644 --- a/x-pack/docs/en/rest-api/watcher/stats.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/stats.asciidoc @@ -7,9 +7,9 @@ The `stats` API returns the current {watcher} metrics. [float] ==== Request -`GET _xpack/watcher/stats` + +`GET watcher/stats` + -`GET _xpack/watcher/stats/` +`GET watcher/stats/` [float] ==== Description @@ -69,7 +69,7 @@ The following example calls the `stats` API to retrieve basic metrics: [source,js] -------------------------------------------------- -GET _xpack/watcher/stats +GET watcher/stats -------------------------------------------------- // CONSOLE @@ -98,7 +98,7 @@ and will include the basic metrics and metrics about the current executing watch [source,js] -------------------------------------------------- -GET _xpack/watcher/stats?metric=current_watches +GET watcher/stats?metric=current_watches -------------------------------------------------- // CONSOLE @@ -106,7 +106,7 @@ The following example specifies the `metric` option as part of the url path: [source,js] -------------------------------------------------- -GET _xpack/watcher/stats/current_watches +GET watcher/stats/current_watches -------------------------------------------------- // CONSOLE @@ -151,7 +151,7 @@ both the basic metrics and the queued watches: [source,js] -------------------------------------------------- -GET _xpack/watcher/stats/queued_watches +GET watcher/stats/queued_watches -------------------------------------------------- // CONSOLE diff --git a/x-pack/docs/en/rest-api/watcher/stop.asciidoc b/x-pack/docs/en/rest-api/watcher/stop.asciidoc index 11345c89cefbb..4a983cfc5f299 100644 --- a/x-pack/docs/en/rest-api/watcher/stop.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/stop.asciidoc @@ -7,7 +7,7 @@ The `stop` API stops the {watcher} service if the service is running. [float] ==== Request -`POST _xpack/watcher/_stop` +`POST watcher/_stop` [float] ==== Authorization @@ -20,7 +20,7 @@ information, see {xpack-ref}/security-privileges.html[Security Privileges]. [source,js] -------------------------------------------------- -POST _xpack/watcher/_stop +POST watcher/_stop -------------------------------------------------- // CONSOLE diff --git a/x-pack/docs/en/watcher/actions.asciidoc b/x-pack/docs/en/watcher/actions.asciidoc index de2516b0589cc..f6701ae65583a 100644 --- a/x-pack/docs/en/watcher/actions.asciidoc +++ b/x-pack/docs/en/watcher/actions.asciidoc @@ -46,7 +46,7 @@ a throttle period with the `email_administrator` action: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/error_logs_alert +PUT watcher/watch/error_logs_alert { "metadata" : { "color" : "red" @@ -101,7 +101,7 @@ defined in the watch: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/log_event_watch +PUT watcher/watch/log_event_watch { "trigger" : { "schedule" : { "interval" : "5m" } @@ -177,7 +177,7 @@ To acknowledge an action, you use the [source,js] ---------------------------------------------------------------------- -POST _xpack/watcher/watch//_ack/ +POST watcher/watch//_ack/ ---------------------------------------------------------------------- // CONSOLE // TEST[skip:https://github.com/elastic/x-plugins/issues/2513] @@ -204,7 +204,7 @@ there are more than 5 hits in the search result. [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/log_event_watch +PUT watcher/watch/log_event_watch { "trigger" : { "schedule" : { "interval" : "5m" } diff --git a/x-pack/docs/en/watcher/example-watches/example-watch-clusterstatus.asciidoc b/x-pack/docs/en/watcher/example-watches/example-watch-clusterstatus.asciidoc index b2c687c5eab9f..19f305d3c70f9 100644 --- a/x-pack/docs/en/watcher/example-watches/example-watch-clusterstatus.asciidoc +++ b/x-pack/docs/en/watcher/example-watches/example-watch-clusterstatus.asciidoc @@ -24,7 +24,7 @@ the following schedule runs every 10 seconds: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/cluster_health_watch +PUT watcher/watch/cluster_health_watch { "trigger" : { "schedule" : { "interval" : "10s" } <1> @@ -52,7 +52,7 @@ To load the health status into your watch, you simply add an [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/cluster_health_watch +PUT watcher/watch/cluster_health_watch { "trigger" : { "schedule" : { "interval" : "10s" } @@ -74,7 +74,7 @@ If you're using Security, then you'll also need to supply some authentication cr [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/cluster_health_watch +PUT watcher/watch/cluster_health_watch { "trigger" : { "schedule" : { "interval" : "10s" } @@ -134,7 +134,7 @@ For example, you could add a condition to check to see if the status is RED. [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/cluster_health_watch +PUT watcher/watch/cluster_health_watch { "trigger" : { "schedule" : { "interval" : "10s" } <1> @@ -191,7 +191,7 @@ when the status is RED. [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/cluster_health_watch +PUT watcher/watch/cluster_health_watch { "trigger" : { "schedule" : { "interval" : "10s" } @@ -280,7 +280,7 @@ To remove the watch, use the {ref}/watcher-api-delete-watch.html[DELETE watch AP [source,js] ------------------------------------------------------- -DELETE _xpack/watcher/watch/cluster_health_watch +DELETE watcher/watch/cluster_health_watch ------------------------------------------------------- // CONSOLE // TEST[continued] diff --git a/x-pack/docs/en/watcher/example-watches/example-watch-meetupdata.asciidoc b/x-pack/docs/en/watcher/example-watches/example-watch-meetupdata.asciidoc index 72eac229ece92..4f53c14727229 100644 --- a/x-pack/docs/en/watcher/example-watches/example-watch-meetupdata.asciidoc +++ b/x-pack/docs/en/watcher/example-watches/example-watch-meetupdata.asciidoc @@ -194,7 +194,7 @@ NOTE: To enable Watcher to send emails, you must configure an email account in ` The complete watch looks like this: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/meetup +PUT watcher/watch/meetup { "trigger": { "schedule": { @@ -300,7 +300,7 @@ Now that you've created your watch, you can use the [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/meetup/_execute +POST watcher/watch/meetup/_execute -------------------------------------------------- // CONSOLE // TEST[continued] diff --git a/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc b/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc index 5daeccce76f53..f307e247d1d40 100644 --- a/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc +++ b/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc @@ -157,7 +157,7 @@ The complete watch looks like this: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/rss_watch +PUT watcher/watch/rss_watch { "trigger" : { "schedule" : { @@ -215,7 +215,7 @@ use the {ref}/watcher-api-execute-watch.html[`_execute` API]: [source,js] -------------------------------------------------- -POST _xpack/watcher/watch/rss_watch/_execute +POST watcher/watch/rss_watch/_execute { "ignore_condition" : true, "action_modes" : { diff --git a/x-pack/docs/en/watcher/getting-started.asciidoc b/x-pack/docs/en/watcher/getting-started.asciidoc index 41eb654bab30c..fb3ec7f8c57f3 100644 --- a/x-pack/docs/en/watcher/getting-started.asciidoc +++ b/x-pack/docs/en/watcher/getting-started.asciidoc @@ -28,7 +28,7 @@ the `logs` index for errors every 10 seconds: [source,js] ------------------------------------------------------------ -PUT _xpack/watcher/watch/log_error_watch +PUT watcher/watch/log_error_watch { "trigger" : { "schedule" : { "interval" : "10s" } <1> @@ -86,7 +86,7 @@ search input returned any hits. [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/log_error_watch +PUT watcher/watch/log_error_watch { "trigger" : { "schedule" : { "interval" : "10s" }}, "input" : { @@ -165,7 +165,7 @@ log when an error is detected. [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/log_error_watch +PUT watcher/watch/log_error_watch { "trigger" : { "schedule" : { "interval" : "10s" }}, "input" : { @@ -207,7 +207,7 @@ To remove the watch, use the {ref}/watcher-api-delete-watch.html[DELETE watch AP [source,js] -------------------------------------------------- -DELETE _xpack/watcher/watch/log_error_watch +DELETE watcher/watch/log_error_watch -------------------------------------------------- // CONSOLE // TEST[continued] diff --git a/x-pack/docs/en/watcher/how-watcher-works.asciidoc b/x-pack/docs/en/watcher/how-watcher-works.asciidoc index 2bd19c1a41e02..0ea85fd14ef00 100644 --- a/x-pack/docs/en/watcher/how-watcher-works.asciidoc +++ b/x-pack/docs/en/watcher/how-watcher-works.asciidoc @@ -48,7 +48,7 @@ looks for log error events: [source,js] -------------------------------------------------- -PUT _xpack/watcher/watch/log_errors +PUT watcher/watch/log_errors { "metadata" : { <1> "color" : "red" diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilege.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilege.java index 9c03941b0313a..1147109767673 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilege.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilege.java @@ -34,12 +34,12 @@ public final class ClusterPrivilege extends Privilege { private static final Automaton MANAGE_TOKEN_AUTOMATON = patterns("cluster:admin/xpack/security/token/*"); private static final Automaton MONITOR_AUTOMATON = patterns("cluster:monitor/*"); private static final Automaton MONITOR_ML_AUTOMATON = patterns("cluster:monitor/xpack/ml/*"); - private static final Automaton MONITOR_WATCHER_AUTOMATON = patterns("cluster:monitor/xpack/watcher/*"); + private static final Automaton MONITOR_WATCHER_AUTOMATON = patterns("cluster:monitor/watcher/*"); private static final Automaton MONITOR_ROLLUP_AUTOMATON = patterns("cluster:monitor/xpack/rollup/*"); private static final Automaton ALL_CLUSTER_AUTOMATON = patterns("cluster:*", "indices:admin/template/*"); private static final Automaton MANAGE_AUTOMATON = minusAndMinimize(ALL_CLUSTER_AUTOMATON, MANAGE_SECURITY_AUTOMATON); private static final Automaton MANAGE_ML_AUTOMATON = patterns("cluster:admin/xpack/ml/*", "cluster:monitor/xpack/ml/*"); - private static final Automaton MANAGE_WATCHER_AUTOMATON = patterns("cluster:admin/xpack/watcher/*", "cluster:monitor/xpack/watcher/*"); + private static final Automaton MANAGE_WATCHER_AUTOMATON = patterns("cluster:admin/watcher/*", "cluster:monitor/watcher/*"); private static final Automaton TRANSPORT_CLIENT_AUTOMATON = patterns("cluster:monitor/nodes/liveness", "cluster:monitor/state"); private static final Automaton MANAGE_IDX_TEMPLATE_AUTOMATON = patterns("indices:admin/template/*"); private static final Automaton MANAGE_INGEST_PIPELINE_AUTOMATON = patterns("cluster:admin/ingest/pipeline/*"); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java index 046cf59254957..a414dcaa087e3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java @@ -67,9 +67,9 @@ private static Map initializeReservedRoles() { .put("remote_monitoring_agent", new RoleDescriptor("remote_monitoring_agent", new String[] { "manage_index_templates", "manage_ingest_pipelines", "monitor", - "cluster:monitor/xpack/watcher/watch/get", - "cluster:admin/xpack/watcher/watch/put", - "cluster:admin/xpack/watcher/watch/delete", + "cluster:monitor/watcher/watch/get", + "cluster:admin/watcher/watch/put", + "cluster:admin/watcher/watch/delete", }, new RoleDescriptor.IndicesPrivileges[] { RoleDescriptor.IndicesPrivileges.builder().indices(".monitoring-*").privileges("all").build(), diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/ack/AckWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/ack/AckWatchAction.java index 04ec95a369af2..d0ce3559f06e6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/ack/AckWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/ack/AckWatchAction.java @@ -13,7 +13,7 @@ public class AckWatchAction extends Action { public static final AckWatchAction INSTANCE = new AckWatchAction(); - public static final String NAME = "cluster:admin/xpack/watcher/watch/ack"; + public static final String NAME = "cluster:admin/watcher/watch/ack"; private AckWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/activate/ActivateWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/activate/ActivateWatchAction.java index 936a21711547e..35e9868b88765 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/activate/ActivateWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/activate/ActivateWatchAction.java @@ -13,7 +13,7 @@ public class ActivateWatchAction extends Action { public static final ActivateWatchAction INSTANCE = new ActivateWatchAction(); - public static final String NAME = "cluster:admin/xpack/watcher/watch/activate"; + public static final String NAME = "cluster:admin/watcher/watch/activate"; private ActivateWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/delete/DeleteWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/delete/DeleteWatchAction.java index eb440ddc2510e..1fc2ef1280616 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/delete/DeleteWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/delete/DeleteWatchAction.java @@ -14,7 +14,7 @@ public class DeleteWatchAction extends Action { public static final DeleteWatchAction INSTANCE = new DeleteWatchAction(); - public static final String NAME = "cluster:admin/xpack/watcher/watch/delete"; + public static final String NAME = "cluster:admin/watcher/watch/delete"; private DeleteWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/execute/ExecuteWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/execute/ExecuteWatchAction.java index 924f170959426..b207525e36531 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/execute/ExecuteWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/execute/ExecuteWatchAction.java @@ -14,7 +14,7 @@ public class ExecuteWatchAction extends Action { public static final ExecuteWatchAction INSTANCE = new ExecuteWatchAction(); - public static final String NAME = "cluster:admin/xpack/watcher/watch/execute"; + public static final String NAME = "cluster:admin/watcher/watch/execute"; private ExecuteWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/get/GetWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/get/GetWatchAction.java index 4df72a964b65f..abe6327434dae 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/get/GetWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/get/GetWatchAction.java @@ -11,7 +11,7 @@ public class GetWatchAction extends org.elasticsearch.action.Action { public static final GetWatchAction INSTANCE = new GetWatchAction(); - public static final String NAME = "cluster:monitor/xpack/watcher/watch/get"; + public static final String NAME = "cluster:monitor/watcher/watch/get"; private GetWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/put/PutWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/put/PutWatchAction.java index 509116b018e2b..07ead7fa4c211 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/put/PutWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/put/PutWatchAction.java @@ -14,7 +14,7 @@ public class PutWatchAction extends Action { public static final PutWatchAction INSTANCE = new PutWatchAction(); - public static final String NAME = "cluster:admin/xpack/watcher/watch/put"; + public static final String NAME = "cluster:admin/watcher/watch/put"; private PutWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java index 30b0b54725b5f..f692d8e0d5893 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java @@ -12,7 +12,7 @@ public class WatcherServiceAction extends Action { public static final WatcherServiceAction INSTANCE = new WatcherServiceAction(); - public static final String NAME = "cluster:admin/xpack/watcher/service"; + public static final String NAME = "cluster:admin/watcher/service"; private WatcherServiceAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsAction.java index 59fcff090f59e..26610d5533f57 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsAction.java @@ -13,7 +13,7 @@ public class WatcherStatsAction extends Action { public static final WatcherStatsAction INSTANCE = new WatcherStatsAction(); - public static final String NAME = "cluster:monitor/xpack/watcher/stats/dist"; + public static final String NAME = "cluster:monitor/watcher/stats/dist"; private WatcherStatsAction() { super(NAME); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java index d944c0d549c0b..a6f445f97b9f9 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java @@ -87,13 +87,13 @@ protected void doCheck(final RestClient client, final ActionListener li (response) -> shouldReplaceClusterAlert(response, XContentType.JSON.xContent(), LAST_UPDATED_VERSION); checkForResource(client, listener, logger, - "/_xpack/watcher/watch", watchId.get(), "monitoring cluster alert", + "/watcher/watch", watchId.get(), "monitoring cluster alert", resourceOwnerName, "monitoring cluster", GET_EXISTS, GET_DOES_NOT_EXIST, watchChecker, this::alwaysReplaceResource); } else { // if we should be deleting, then just try to delete it (same level of effort as checking) - deleteResource(client, listener, logger, "/_xpack/watcher/watch", watchId.get(), + deleteResource(client, listener, logger, "/watcher/watch", watchId.get(), "monitoring cluster alert", resourceOwnerName, "monitoring cluster"); } @@ -105,7 +105,7 @@ protected void doCheck(final RestClient client, final ActionListener li @Override protected void doPublish(final RestClient client, final ActionListener listener) { putResource(client, listener, logger, - "/_xpack/watcher/watch", watchId.get(), this::watchToHttpEntity, "monitoring cluster alert", + "/watcher/watch", watchId.get(), this::watchToHttpEntity, "monitoring cluster alert", resourceOwnerName, "monitoring cluster"); } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResourceTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResourceTests.java index d86e901e38a3f..efcd8b875ac95 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResourceTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResourceTests.java @@ -63,7 +63,7 @@ public void testDoCheckGetWatchExists() throws IOException { final HttpEntity entity = entityForClusterAlert(true, minimumVersion); - doCheckWithStatusCode(resource, "/_xpack/watcher/watch", watchId, successfulCheckStatus(), true, entity); + doCheckWithStatusCode(resource, "/watcher/watch", watchId, successfulCheckStatus(), true, entity); } public void testDoCheckGetWatchDoesNotExist() throws IOException { @@ -71,12 +71,12 @@ public void testDoCheckGetWatchDoesNotExist() throws IOException { if (randomBoolean()) { // it does not exist because it's literally not there - assertCheckDoesNotExist(resource, "/_xpack/watcher/watch", watchId); + assertCheckDoesNotExist(resource, "/watcher/watch", watchId); } else { // it does not exist because we need to replace it final HttpEntity entity = entityForClusterAlert(false, minimumVersion); - doCheckWithStatusCode(resource, "/_xpack/watcher/watch", watchId, successfulCheckStatus(), false, entity); + doCheckWithStatusCode(resource, "/watcher/watch", watchId, successfulCheckStatus(), false, entity); } } @@ -85,12 +85,12 @@ public void testDoCheckWithExceptionGetWatchError() throws IOException { if (randomBoolean()) { // error because of a server error - assertCheckWithException(resource, "/_xpack/watcher/watch", watchId); + assertCheckWithException(resource, "/watcher/watch", watchId); } else { // error because of a malformed response final HttpEntity entity = entityForClusterAlert(null, minimumVersion); - doCheckWithStatusCode(resource, "/_xpack/watcher/watch", watchId, successfulCheckStatus(), null, entity); + doCheckWithStatusCode(resource, "/watcher/watch", watchId, successfulCheckStatus(), null, entity); } } @@ -101,7 +101,7 @@ public void testDoCheckAsDeleteWatchExistsWhenNoWatchIsSpecified() throws IOExce // should not matter when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(clusterAlertsAllowed); - assertCheckAsDeleteExists(noWatchResource, "/_xpack/watcher/watch", watchId); + assertCheckAsDeleteExists(noWatchResource, "/watcher/watch", watchId); } public void testDoCheckWithExceptionAsDeleteWatchErrorWhenNoWatchIsSpecified() throws IOException { @@ -111,27 +111,27 @@ public void testDoCheckWithExceptionAsDeleteWatchErrorWhenNoWatchIsSpecified() t // should not matter when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(clusterAlertsAllowed); - assertCheckAsDeleteWithException(noWatchResource, "/_xpack/watcher/watch", watchId); + assertCheckAsDeleteWithException(noWatchResource, "/watcher/watch", watchId); } public void testDoCheckAsDeleteWatchExists() throws IOException { when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(false); - assertCheckAsDeleteExists(resource, "/_xpack/watcher/watch", watchId); + assertCheckAsDeleteExists(resource, "/watcher/watch", watchId); } public void testDoCheckWithExceptionAsDeleteWatchError() throws IOException { when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(false); - assertCheckAsDeleteWithException(resource, "/_xpack/watcher/watch", watchId); + assertCheckAsDeleteWithException(resource, "/watcher/watch", watchId); } public void testDoPublishTrue() throws IOException { - assertPublishSucceeds(resource, "/_xpack/watcher/watch", watchId, StringEntity.class); + assertPublishSucceeds(resource, "/watcher/watch", watchId, StringEntity.class); } public void testDoPublishFalseWithException() throws IOException { - assertPublishWithException(resource, "/_xpack/watcher/watch", watchId, StringEntity.class); + assertPublishWithException(resource, "/watcher/watch", watchId, StringEntity.class); } public void testShouldReplaceClusterAlertRethrowsIOException() throws IOException { diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java index 46a0a353d093b..2012f44896f4a 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java @@ -497,7 +497,7 @@ private void assertMonitorWatches(final MockWebServer webServer, // GET / PUT if we are allowed to use it if (currentLicenseAllowsWatcher && clusterAlertBlacklist.contains(watch.v1()) == false) { assertThat(request.getMethod(), equalTo("GET")); - assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/_xpack/watcher/watch/" + uniqueWatchId)); + assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/watcher/watch/" + uniqueWatchId)); assertThat(request.getUri().getQuery(), equalTo(resourceClusterAlertQueryString())); assertHeaders(request, customHeaders); @@ -505,7 +505,7 @@ private void assertMonitorWatches(final MockWebServer webServer, request = webServer.takeRequest(); assertThat(request.getMethod(), equalTo("PUT")); - assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/_xpack/watcher/watch/" + uniqueWatchId)); + assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/watcher/watch/" + uniqueWatchId)); assertThat(request.getUri().getQuery(), equalTo(resourceClusterAlertQueryString())); assertThat(request.getBody(), equalTo(watch.v2())); assertHeaders(request, customHeaders); @@ -513,7 +513,7 @@ private void assertMonitorWatches(final MockWebServer webServer, // DELETE if we're not allowed to use it } else { assertThat(request.getMethod(), equalTo("DELETE")); - assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/_xpack/watcher/watch/" + uniqueWatchId)); + assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/watcher/watch/" + uniqueWatchId)); assertThat(request.getUri().getQuery(), equalTo(resourceClusterAlertQueryString())); assertHeaders(request, customHeaders); } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java index bcb4181f65125..da95c778d0bec 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java @@ -376,7 +376,7 @@ public void testWatchCheckBlocksAfterSuccessfulWatcherCheck() { final List otherResponses = getWatcherResponses(1, successful, unsuccessful); // last check fails implies that N - 2 publishes succeeded! - whenPerformRequestAsyncWith(client, new RequestMatcher(is("GET"), startsWith("/_xpack/watcher/watch/")), + whenPerformRequestAsyncWith(client, new RequestMatcher(is("GET"), startsWith("/watcher/watch/")), first, otherResponses, exception); whenSuccessfulPutWatches(otherResponses.size() + 1); @@ -391,7 +391,7 @@ public void testWatchCheckBlocksAfterSuccessfulWatcherCheck() { // there is no form of an unsuccessful delete; only success or error final List responses = successfulDeleteResponses(successful); - whenPerformRequestAsyncWith(client, new RequestMatcher(is("DELETE"), startsWith("/_xpack/watcher/watch/")), + whenPerformRequestAsyncWith(client, new RequestMatcher(is("DELETE"), startsWith("/watcher/watch/")), responses.get(0), responses.subList(1, responses.size()), exception); expectedGets += successful; @@ -399,7 +399,7 @@ public void testWatchCheckBlocksAfterSuccessfulWatcherCheck() { } else { final String method = validLicense ? "GET" : "DELETE"; - whenPerformRequestAsyncWith(client, new RequestMatcher(is(method), startsWith("/_xpack/watcher/watch/")), exception); + whenPerformRequestAsyncWith(client, new RequestMatcher(is(method), startsWith("/watcher/watch/")), exception); } assertTrue(resources.isDirty()); @@ -454,7 +454,7 @@ public void testWatchPublishBlocksAfterSuccessfulWatcherCheck() { whenGetWatches(successful, unsuccessful + 2); // previous publishes must have succeeded - whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/_xpack/watcher/watch/")), + whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/watcher/watch/")), firstSuccess, otherResponses, exception); // GETs required for each PUT attempt (first is guaranteed "unsuccessful") @@ -465,7 +465,7 @@ public void testWatchPublishBlocksAfterSuccessfulWatcherCheck() { // fail the check so that it has to attempt the PUT whenGetWatches(0, 1); - whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/_xpack/watcher/watch/")), exception); + whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/watcher/watch/")), exception); } assertTrue(resources.isDirty()); @@ -595,13 +595,13 @@ private Response unsuccessfulGetResponse() { private Response successfulGetWatchResponse(final String watchId) { final HttpEntity goodEntity = entityForClusterAlert(true, ClusterAlertsUtil.LAST_UPDATED_VERSION); - return response("GET", "/_xpack/watcher/watch/" + watchId, successfulCheckStatus(), goodEntity); + return response("GET", "/watcher/watch/" + watchId, successfulCheckStatus(), goodEntity); } private Response unsuccessfulGetWatchResponse(final String watchId) { if (randomBoolean()) { final HttpEntity badEntity = entityForClusterAlert(false, ClusterAlertsUtil.LAST_UPDATED_VERSION); - return response("GET", "/_xpack/watcher/watch/" + watchId, successfulCheckStatus(), badEntity); + return response("GET", "/watcher/watch/" + watchId, successfulCheckStatus(), badEntity); } return unsuccessfulGetResponse(); @@ -764,21 +764,21 @@ private void whenWatcherCannotBeUsed() { private void whenGetWatches(final int successful, final int unsuccessful) { final List gets = getWatcherResponses(0, successful, unsuccessful); - whenPerformRequestAsyncWith(client, new RequestMatcher(is("GET"), startsWith("/_xpack/watcher/watch/")), gets); + whenPerformRequestAsyncWith(client, new RequestMatcher(is("GET"), startsWith("/watcher/watch/")), gets); } private void whenSuccessfulPutWatches(final int successful) { final List successfulPuts = successfulPutResponses(successful); // empty is possible if they all exist - whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/_xpack/watcher/watch/")), successfulPuts); + whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/watcher/watch/")), successfulPuts); } private void whenSuccessfulDeleteWatches(final int successful) { final List successfulDeletes = successfulDeleteResponses(successful); // empty is possible if they all exist - whenPerformRequestAsyncWith(client, new RequestMatcher(is("DELETE"), startsWith("/_xpack/watcher/watch/")), successfulDeletes); + whenPerformRequestAsyncWith(client, new RequestMatcher(is("DELETE"), startsWith("/watcher/watch/")), successfulDeletes); } private void verifyVersionCheck() { @@ -811,18 +811,18 @@ private void verifyWatcherCheck() { private void verifyDeleteWatches(final int called) { verify(client, times(called)) - .performRequestAsync(argThat(new RequestMatcher(is("DELETE"), startsWith("/_xpack/watcher/watch/"))), + .performRequestAsync(argThat(new RequestMatcher(is("DELETE"), startsWith("/watcher/watch/"))), any(ResponseListener.class)); } private void verifyGetWatches(final int called) { verify(client, times(called)) - .performRequestAsync(argThat(new RequestMatcher(is("GET"), startsWith("/_xpack/watcher/watch/"))), any(ResponseListener.class)); + .performRequestAsync(argThat(new RequestMatcher(is("GET"), startsWith("/watcher/watch/"))), any(ResponseListener.class)); } private void verifyPutWatches(final int called) { verify(client, times(called)) - .performRequestAsync(argThat(new RequestMatcher(is("PUT"), startsWith("/_xpack/watcher/watch/"))), any(ResponseListener.class)); + .performRequestAsync(argThat(new RequestMatcher(is("PUT"), startsWith("/watcher/watch/"))), any(ResponseListener.class)); } private ClusterService mockClusterService(final ClusterState state) { diff --git a/x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java b/x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java index 91dc8c853894a..9d94b277f1e81 100644 --- a/x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java +++ b/x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java @@ -145,7 +145,7 @@ private void waitForWatcher() throws Exception { List> hits = objectPathResponse.evaluate("hits.hits"); for (Map hit : hits) { String id = (String) hit.get("_id"); - adminClient().performRequest(new Request("DELETE", "_xpack/watcher/watch/" + id)); + adminClient().performRequest(new Request("DELETE", "watcher/watch/" + id)); } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.ack_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.ack_watch.json index e48f6a820f840..8c5465ff933a7 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.ack_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.ack_watch.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html", "methods": [ "PUT", "POST" ], "url": { - "path": "/_xpack/watcher/watch/{watch_id}/_ack", - "paths": [ "/_xpack/watcher/watch/{watch_id}/_ack", "/_xpack/watcher/watch/{watch_id}/_ack/{action_id}"], + "path": "/watcher/watch/{watch_id}/_ack", + "paths": [ "/watcher/watch/{watch_id}/_ack", "/watcher/watch/{watch_id}/_ack/{action_id}"], "parts": { "watch_id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.activate_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.activate_watch.json index bceb74b5745de..7c370408e74ed 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.activate_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.activate_watch.json @@ -3,8 +3,8 @@ "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html", "methods": [ "PUT", "POST" ], "url": { - "path": "/_xpack/watcher/watch/{watch_id}/_activate", - "paths": [ "/_xpack/watcher/watch/{watch_id}/_activate" ], + "path": "/watcher/watch/{watch_id}/_activate", + "paths": [ "/watcher/watch/{watch_id}/_activate" ], "parts": { "watch_id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.deactivate_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.deactivate_watch.json index dff58c3702928..14f920fcf1316 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.deactivate_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.deactivate_watch.json @@ -3,8 +3,8 @@ "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html", "methods": [ "PUT", "POST" ], "url": { - "path": "/_xpack/watcher/watch/{watch_id}/_deactivate", - "paths": [ "/_xpack/watcher/watch/{watch_id}/_deactivate" ], + "path": "/watcher/watch/{watch_id}/_deactivate", + "paths": [ "/watcher/watch/{watch_id}/_deactivate" ], "parts": { "watch_id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.delete_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.delete_watch.json index ff657fd9ee929..5326c4bf34e40 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.delete_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.delete_watch.json @@ -4,8 +4,8 @@ "methods": [ "DELETE" ], "url": { - "path": "/_xpack/watcher/watch/{id}", - "paths": [ "/_xpack/watcher/watch/{id}" ], + "path": "/watcher/watch/{id}", + "paths": [ "/watcher/watch/{id}" ], "parts": { "id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.execute_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.execute_watch.json index 109124027f455..19736b46abbb6 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.execute_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.execute_watch.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html", "methods": [ "PUT", "POST" ], "url": { - "path": "/_xpack/watcher/watch/{id}/_execute", - "paths": [ "/_xpack/watcher/watch/{id}/_execute", "/_xpack/watcher/watch/_execute" ], + "path": "/watcher/watch/{id}/_execute", + "paths": [ "/watcher/watch/{id}/_execute", "/watcher/watch/_execute" ], "parts": { "id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.get_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.get_watch.json index 071421919b7cc..c424f9944d68b 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.get_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.get_watch.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html", "methods": [ "GET" ], "url": { - "path": "/_xpack/watcher/watch/{id}", - "paths": [ "/_xpack/watcher/watch/{id}" ], + "path": "/watcher/watch/{id}", + "paths": [ "/watcher/watch/{id}" ], "parts": { "id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.put_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.put_watch.json index 3eda8b764dbad..5463f959e68c1 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.put_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.put_watch.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html", "methods": [ "PUT", "POST" ], "url": { - "path": "/_xpack/watcher/watch/{id}", - "paths": [ "/_xpack/watcher/watch/{id}" ], + "path": "/watcher/watch/{id}", + "paths": [ "/watcher/watch/{id}" ], "parts": { "id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.start.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.start.json index 18379efb37938..6a0a2b82e711e 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.start.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.start.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html", "methods": [ "POST" ], "url": { - "path": "/_xpack/watcher/_start", - "paths": [ "/_xpack/watcher/_start" ], + "path": "/watcher/_start", + "paths": [ "/watcher/_start" ], "parts": { }, "params": { diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stats.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stats.json index 86c982a888151..801a969006ae1 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stats.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stats.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html", "methods": [ "GET" ], "url": { - "path": "/_xpack/watcher/stats", - "paths": [ "/_xpack/watcher/stats", "/_xpack/watcher/stats/{metric}" ], + "path": "/watcher/stats", + "paths": [ "/watcher/stats", "/watcher/stats/{metric}" ], "parts": { "metric": { "type" : "enum", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stop.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stop.json index 05881bebe1322..a2ae6a89d3f9f 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stop.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stop.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html", "methods": [ "POST" ], "url": { - "path": "/_xpack/watcher/_stop", - "paths": [ "/_xpack/watcher/_stop" ], + "path": "/watcher/_stop", + "paths": [ "/watcher/_stop" ], "parts": { }, "params": { diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java index f6c3f2189634e..f9d2e8c53bc49 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java @@ -15,7 +15,7 @@ public abstract class WatcherRestHandler extends BaseRestHandler { - protected static String URI_BASE = "_xpack/watcher"; + protected static String URI_BASE = "watcher"; public WatcherRestHandler(Settings settings) { super(settings); diff --git a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index 1192c78017176..079fb047cceaf 100644 --- a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -152,17 +152,17 @@ public void testSecurityNativeRealm() throws Exception { public void testWatcher() throws Exception { if (isRunningAgainstOldCluster()) { logger.info("Adding a watch on old cluster {}", getOldClusterVersion()); - Request createBwcWatch = new Request("PUT", "_xpack/watcher/watch/bwc_watch"); + Request createBwcWatch = new Request("PUT", "watcher/watch/bwc_watch"); createBwcWatch.setJsonEntity(loadWatch("simple-watch.json")); client().performRequest(createBwcWatch); logger.info("Adding a watch with \"fun\" throttle periods on old cluster"); - Request createBwcThrottlePeriod = new Request("PUT", "_xpack/watcher/watch/bwc_throttle_period"); + Request createBwcThrottlePeriod = new Request("PUT", "watcher/watch/bwc_throttle_period"); createBwcThrottlePeriod.setJsonEntity(loadWatch("throttle-period-watch.json")); client().performRequest(createBwcThrottlePeriod); logger.info("Adding a watch with \"fun\" read timeout on old cluster"); - Request createFunnyTimeout = new Request("PUT", "_xpack/watcher/watch/bwc_funny_timeout"); + Request createFunnyTimeout = new Request("PUT", "watcher/watch/bwc_funny_timeout"); createFunnyTimeout.setJsonEntity(loadWatch("funny-timeout-watch.json")); client().performRequest(createFunnyTimeout); @@ -206,10 +206,10 @@ public void testWatcher() throws Exception { } // Wait for watcher to actually start.... - Map startWatchResponse = entityAsMap(client().performRequest(new Request("POST", "_xpack/watcher/_start"))); + Map startWatchResponse = entityAsMap(client().performRequest(new Request("POST", "watcher/_start"))); assertThat(startWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE)); assertBusy(() -> { - Map statsWatchResponse = entityAsMap(client().performRequest(new Request("GET", "_xpack/watcher/stats"))); + Map statsWatchResponse = entityAsMap(client().performRequest(new Request("GET", "watcher/stats"))); @SuppressWarnings("unchecked") List states = ((List) statsWatchResponse.get("stats")) .stream().map(o -> ((Map) o).get("watcher_state")).collect(Collectors.toList()); @@ -224,11 +224,11 @@ public void testWatcher() throws Exception { /* Shut down watcher after every test because watcher can be a bit finicky about shutting down when the node shuts * down. This makes super sure it shuts down *and* causes the test to fail in a sensible spot if it doesn't shut down. */ - Map stopWatchResponse = entityAsMap(client().performRequest(new Request("POST", "_xpack/watcher/_stop"))); + Map stopWatchResponse = entityAsMap(client().performRequest(new Request("POST", "watcher/_stop"))); assertThat(stopWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE)); assertBusy(() -> { Map statsStoppedWatchResponse = entityAsMap(client().performRequest( - new Request("GET", "_xpack/watcher/stats"))); + new Request("GET", "watcher/stats"))); @SuppressWarnings("unchecked") List states = ((List) statsStoppedWatchResponse.get("stats")) .stream().map(o -> ((Map) o).get("watcher_state")).collect(Collectors.toList()); @@ -261,7 +261,7 @@ public void testRollupAfterRestart() throws Exception { client().performRequest(bulkRequest); // create the rollup job - final Request createRollupJobRequest = new Request("PUT", "/_xpack/rollup/job/rollup-job-test"); + final Request createRollupJobRequest = new Request("PUT", "/rollup/job/rollup-job-test"); createRollupJobRequest.setJsonEntity("{" + "\"index_pattern\":\"rollup-*\"," + "\"rollup_index\":\"results-rollup\"," @@ -282,7 +282,7 @@ public void testRollupAfterRestart() throws Exception { assertThat(createRollupJobResponse.get("acknowledged"), equalTo(Boolean.TRUE)); // start the rollup job - final Request startRollupJobRequest = new Request("POST", "_xpack/rollup/job/rollup-job-test/_start"); + final Request startRollupJobRequest = new Request("POST", "rollup/job/rollup-job-test/_start"); Map startRollupJobResponse = entityAsMap(client().performRequest(startRollupJobRequest)); assertThat(startRollupJobResponse.get("started"), equalTo(Boolean.TRUE)); @@ -313,7 +313,7 @@ public void testRollupIDSchemeAfterRestart() throws Exception { client().performRequest(indexRequest); // create the rollup job - final Request createRollupJobRequest = new Request("PUT", "/_xpack/rollup/job/rollup-id-test"); + final Request createRollupJobRequest = new Request("PUT", "/rollup/job/rollup-id-test"); createRollupJobRequest.setJsonEntity("{" + "\"index_pattern\":\"id-test-rollup\"," + "\"rollup_index\":\"id-test-results-rollup\"," @@ -341,7 +341,7 @@ public void testRollupIDSchemeAfterRestart() throws Exception { assertThat(createRollupJobResponse.get("acknowledged"), equalTo(Boolean.TRUE)); // start the rollup job - final Request startRollupJobRequest = new Request("POST", "_xpack/rollup/job/rollup-id-test/_start"); + final Request startRollupJobRequest = new Request("POST", "rollup/job/rollup-id-test/_start"); Map startRollupJobResponse = entityAsMap(client().performRequest(startRollupJobRequest)); assertThat(startRollupJobResponse.get("started"), equalTo(Boolean.TRUE)); @@ -373,14 +373,14 @@ public void testRollupIDSchemeAfterRestart() throws Exception { assertRollUpJob("rollup-id-test"); // stop the rollup job to force a state save, which will upgrade the ID - final Request stopRollupJobRequest = new Request("POST", "_xpack/rollup/job/rollup-id-test/_stop"); + final Request stopRollupJobRequest = new Request("POST", "rollup/job/rollup-id-test/_stop"); Map stopRollupJobResponse = entityAsMap(client().performRequest(stopRollupJobRequest)); assertThat(stopRollupJobResponse.get("stopped"), equalTo(Boolean.TRUE)); waitForRollUpJob("rollup-id-test", equalTo("stopped")); // start the rollup job again - final Request startRollupJobRequest = new Request("POST", "_xpack/rollup/job/rollup-id-test/_start"); + final Request startRollupJobRequest = new Request("POST", "rollup/job/rollup-id-test/_start"); Map startRollupJobResponse = entityAsMap(client().performRequest(startRollupJobRequest)); assertThat(startRollupJobResponse.get("started"), equalTo(Boolean.TRUE)); @@ -430,7 +430,7 @@ public void testSqlFailsOnIndexWithTwoTypes() throws IOException { } final Request sqlRequest; if (isRunningAgainstOldCluster()) { - sqlRequest = new Request("POST", "/_xpack/sql"); + sqlRequest = new Request("POST", "/sql"); } else { sqlRequest = new Request("POST", "/_sql"); } @@ -454,7 +454,7 @@ private void assertOldTemplatesAreDeleted() throws IOException { @SuppressWarnings("unchecked") private void assertWatchIndexContentsWork() throws Exception { // Fetch a basic watch - Map bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_xpack/watcher/watch/bwc_watch"))); + Map bwcWatch = entityAsMap(client().performRequest(new Request("GET", "watcher/watch/bwc_watch"))); logger.error("-----> {}", bwcWatch); @@ -469,7 +469,7 @@ private void assertWatchIndexContentsWork() throws Exception { assertThat(ObjectPath.eval("actions.index_payload.index.timeout_in_millis", source), equalTo(timeout)); // Fetch a watch with "fun" throttle periods - bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_xpack/watcher/watch/bwc_throttle_period"))); + bwcWatch = entityAsMap(client().performRequest(new Request("GET", "watcher/watch/bwc_throttle_period"))); assertThat(bwcWatch.get("found"), equalTo(true)); source = (Map) bwcWatch.get("watch"); assertEquals(timeout, source.get("throttle_period_in_millis")); @@ -479,7 +479,7 @@ private void assertWatchIndexContentsWork() throws Exception { * Fetch a watch with a funny timeout to verify loading fractional time * values. */ - bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_xpack/watcher/watch/bwc_funny_timeout"))); + bwcWatch = entityAsMap(client().performRequest(new Request("GET", "watcher/watch/bwc_funny_timeout"))); assertThat(bwcWatch.get("found"), equalTo(true)); source = (Map) bwcWatch.get("watch"); @@ -508,7 +508,7 @@ private void assertBasicWatchInteractions() throws Exception { .condition(InternalAlwaysCondition.INSTANCE) .trigger(ScheduleTrigger.builder(new IntervalSchedule(IntervalSchedule.Interval.seconds(1)))) .addAction("awesome", LoggingAction.builder(new TextTemplate("test"))).buildAsBytes(XContentType.JSON).utf8ToString(); - Request createWatchRequest = new Request("PUT", "_xpack/watcher/watch/new_watch"); + Request createWatchRequest = new Request("PUT", "watcher/watch/new_watch"); createWatchRequest.setJsonEntity(watch); Map createWatch = entityAsMap(client().performRequest(createWatchRequest)); @@ -521,7 +521,7 @@ private void assertBasicWatchInteractions() throws Exception { assertThat(updateWatch.get("created"), equalTo(false)); assertThat(updateWatch.get("_version"), equalTo(2)); - Map get = entityAsMap(client().performRequest(new Request("GET", "_xpack/watcher/watch/new_watch"))); + Map get = entityAsMap(client().performRequest(new Request("GET", "watcher/watch/new_watch"))); assertThat(get.get("found"), equalTo(true)); @SuppressWarnings("unchecked") Map source = (Map) get.get("watch"); Map logging = ObjectPath.eval("actions.awesome.logging", source); @@ -568,7 +568,7 @@ static String toStr(Response response) throws IOException { } private void createUser(final String id) throws Exception { - Request request = new Request("PUT", "/_xpack/security/user/" + id); + Request request = new Request("PUT", "/security/user/" + id); request.setJsonEntity( "{\n" + " \"password\" : \"j@rV1s\",\n" + @@ -581,7 +581,7 @@ private void createUser(final String id) throws Exception { } private void createRole(final String id) throws Exception { - Request request = new Request("PUT", "/_xpack/security/role/" + id); + Request request = new Request("PUT", "/security/role/" + id); request.setJsonEntity( "{\n" + " \"run_as\": [ \"abc\" ],\n" + @@ -601,7 +601,7 @@ private void createRole(final String id) throws Exception { } private void assertUserInfo(final String user) throws Exception { - Map response = entityAsMap(client().performRequest(new Request("GET", "/_xpack/security/user/" + user))); + Map response = entityAsMap(client().performRequest(new Request("GET", "/security/user/" + user))); @SuppressWarnings("unchecked") Map userInfo = (Map) response.get(user); assertEquals(user + "@example.com", userInfo.get("email")); assertNotNull(userInfo.get("full_name")); @@ -610,7 +610,7 @@ private void assertUserInfo(final String user) throws Exception { private void assertRoleInfo(final String role) throws Exception { @SuppressWarnings("unchecked") Map response = (Map) - entityAsMap(client().performRequest(new Request("GET", "/_xpack/security/role/" + role))).get(role); + entityAsMap(client().performRequest(new Request("GET", "/security/role/" + role))).get(role); assertNotNull(response.get("run_as")); assertNotNull(response.get("cluster")); assertNotNull(response.get("indices")); @@ -622,7 +622,7 @@ private void assertRollUpJob(final String rollupJob) throws Exception { waitForRollUpJob(rollupJob, expectedStates); // check that the rollup job is started using the RollUp API - final Request getRollupJobRequest = new Request("GET", "_xpack/rollup/job/" + rollupJob); + final Request getRollupJobRequest = new Request("GET", "rollup/job/" + rollupJob); Map getRollupJobResponse = entityAsMap(client().performRequest(getRollupJobRequest)); Map job = getJob(getRollupJobResponse, rollupJob); if (job != null) { @@ -668,7 +668,7 @@ private void assertRollUpJob(final String rollupJob) throws Exception { private void waitForRollUpJob(final String rollupJob, final Matcher expectedStates) throws Exception { assertBusy(() -> { - final Request getRollupJobRequest = new Request("GET", "_xpack/rollup/job/" + rollupJob); + final Request getRollupJobRequest = new Request("GET", "rollup/job/" + rollupJob); Response getRollupJobResponse = client().performRequest(getRollupJobRequest); assertThat(getRollupJobResponse.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus())); diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java index 395ab375bd249..f36dcc9111a31 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java @@ -17,16 +17,16 @@ public class WatcherRestartIT extends AbstractUpgradeTestCase { public void testWatcherRestart() throws Exception { - client().performRequest(new Request("POST", "/_xpack/watcher/_stop")); + client().performRequest(new Request("POST", "/watcher/_stop")); ensureWatcherStopped(); - client().performRequest(new Request("POST", "/_xpack/watcher/_start")); + client().performRequest(new Request("POST", "/watcher/_start")); ensureWatcherStarted(); } private void ensureWatcherStopped() throws Exception { assertBusy(() -> { - Response stats = client().performRequest(new Request("GET", "_xpack/watcher/stats")); + Response stats = client().performRequest(new Request("GET", "watcher/stats")); String responseBody = EntityUtils.toString(stats.getEntity(), StandardCharsets.UTF_8); assertThat(responseBody, containsString("\"watcher_state\":\"stopped\"")); assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\""))); @@ -37,7 +37,7 @@ private void ensureWatcherStopped() throws Exception { private void ensureWatcherStarted() throws Exception { assertBusy(() -> { - Response response = client().performRequest(new Request("GET", "_xpack/watcher/stats")); + Response response = client().performRequest(new Request("GET", "watcher/stats")); String responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); assertThat(responseBody, containsString("\"watcher_state\":\"started\"")); assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\""))); diff --git a/x-pack/qa/smoke-test-monitoring-with-watcher/src/test/java/org/elasticsearch/smoketest/MonitoringWithWatcherRestIT.java b/x-pack/qa/smoke-test-monitoring-with-watcher/src/test/java/org/elasticsearch/smoketest/MonitoringWithWatcherRestIT.java index d3b9a974398da..24d1ed59d1a5a 100644 --- a/x-pack/qa/smoke-test-monitoring-with-watcher/src/test/java/org/elasticsearch/smoketest/MonitoringWithWatcherRestIT.java +++ b/x-pack/qa/smoke-test-monitoring-with-watcher/src/test/java/org/elasticsearch/smoketest/MonitoringWithWatcherRestIT.java @@ -77,7 +77,7 @@ public void testThatHttpExporterAddsWatches() throws Exception { } private void assertMonitoringWatchHasBeenOverWritten(String watchId) throws Exception { - ObjectPath path = ObjectPath.createFromResponse(client().performRequest(new Request("GET", "/_xpack/watcher/watch/" + watchId))); + ObjectPath path = ObjectPath.createFromResponse(client().performRequest(new Request("GET", "/watcher/watch/" + watchId))); String interval = path.evaluate("watch.trigger.schedule.interval"); assertThat(interval, is("1m")); } @@ -94,7 +94,7 @@ private void assertTotalWatchCount(int expectedWatches) throws Exception { private String createMonitoringWatch() throws Exception { String clusterUUID = getClusterUUID(); String watchId = clusterUUID + "_kibana_version_mismatch"; - Request request = new Request("PUT", "/_xpack/watcher/watch/" + watchId); + Request request = new Request("PUT", "/watcher/watch/" + watchId); request.setJsonEntity(WatchSourceBuilders.watchBuilder() .trigger(TriggerBuilders.schedule(new IntervalSchedule(new IntervalSchedule.Interval(1000, MINUTES)))) .input(simpleInput()) diff --git a/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java b/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java index 02083cbedb271..1dc6452b16007 100644 --- a/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java +++ b/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java @@ -56,13 +56,13 @@ public void startWatcher() throws Exception { assertBusy(() -> { try { - Response statsResponse = adminClient().performRequest(new Request("GET", "/_xpack/watcher/stats")); + Response statsResponse = adminClient().performRequest(new Request("GET", "/watcher/stats")); ObjectPath objectPath = ObjectPath.createFromResponse(statsResponse); String state = objectPath.evaluate("stats.0.watcher_state"); switch (state) { case "stopped": - Response startResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_start")); + Response startResponse = adminClient().performRequest(new Request("POST", "/watcher/_start")); Map responseMap = entityAsMap(startResponse); assertThat(responseMap, hasEntry("acknowledged", true)); throw new AssertionError("waiting until stopped state reached started state"); @@ -94,7 +94,7 @@ public void stopWatcher() throws Exception { assertBusy(() -> { try { - Response statsResponse = adminClient().performRequest(new Request("GET", "/_xpack/watcher/stats")); + Response statsResponse = adminClient().performRequest(new Request("GET", "/watcher/stats")); ObjectPath objectPath = ObjectPath.createFromResponse(statsResponse); String state = objectPath.evaluate("stats.0.watcher_state"); @@ -107,7 +107,7 @@ public void stopWatcher() throws Exception { case "starting": throw new AssertionError("waiting until starting state reached started state to stop"); case "started": - Response stopResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_stop")); + Response stopResponse = adminClient().performRequest(new Request("POST", "/watcher/_stop")); String body = EntityUtils.toString(stopResponse.getEntity()); assertThat(body, containsString("\"acknowledged\":true")); throw new AssertionError("waiting until started state reached stopped state"); @@ -290,7 +290,7 @@ public void testIndexActionInsufficientPrivileges() throws Exception { } private void indexWatch(String watchId, XContentBuilder builder) throws Exception { - Request request = new Request("PUT", "/_xpack/watcher/watch/" + watchId); + Request request = new Request("PUT", "/watcher/watch/" + watchId); request.setJsonEntity(Strings.toString(builder)); Response response = client().performRequest(request); Map responseMap = entityAsMap(response); diff --git a/x-pack/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherTestSuiteIT.java b/x-pack/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherTestSuiteIT.java index 93089a78e5b1d..57312cd3135ef 100644 --- a/x-pack/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherTestSuiteIT.java +++ b/x-pack/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherTestSuiteIT.java @@ -40,12 +40,12 @@ public void startWatcher() throws Exception { assertOK(adminClient().performRequest(new Request("DELETE", "/.watcher-history-*"))); assertBusy(() -> { - Response response = adminClient().performRequest(new Request("GET", "/_xpack/watcher/stats")); + Response response = adminClient().performRequest(new Request("GET", "/watcher/stats")); String state = ObjectPath.createFromResponse(response).evaluate("stats.0.watcher_state"); switch (state) { case "stopped": - Response startResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_start")); + Response startResponse = adminClient().performRequest(new Request("POST", "/watcher/_start")); boolean isAcknowledged = ObjectPath.createFromResponse(startResponse).evaluate("acknowledged"); assertThat(isAcknowledged, is(true)); throw new AssertionError("waiting until stopped state reached started state"); @@ -72,7 +72,7 @@ public void startWatcher() throws Exception { @After public void stopWatcher() throws Exception { assertBusy(() -> { - Response response = adminClient().performRequest(new Request("GET", "/_xpack/watcher/stats")); + Response response = adminClient().performRequest(new Request("GET", "/watcher/stats")); String state = ObjectPath.createFromResponse(response).evaluate("stats.0.watcher_state"); switch (state) { @@ -84,7 +84,7 @@ public void stopWatcher() throws Exception { case "starting": throw new AssertionError("waiting until starting state reached started state to stop"); case "started": - Response stopResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_stop")); + Response stopResponse = adminClient().performRequest(new Request("POST", "/watcher/_stop")); boolean isAcknowledged = ObjectPath.createFromResponse(stopResponse).evaluate("acknowledged"); assertThat(isAcknowledged, is(true)); throw new AssertionError("waiting until started state reached stopped state"); @@ -162,7 +162,7 @@ public void testMonitorClusterHealth() throws Exception { } private void indexWatch(String watchId, XContentBuilder builder) throws Exception { - Request request = new Request("PUT", "/_xpack/watcher/watch/" + watchId); + Request request = new Request("PUT", "/watcher/watch/" + watchId); request.setJsonEntity(Strings.toString(builder)); Response response = client().performRequest(request); Map responseMap = entityAsMap(response); @@ -170,7 +170,7 @@ private void indexWatch(String watchId, XContentBuilder builder) throws Exceptio } private void deleteWatch(String watchId) throws IOException { - Response response = client().performRequest(new Request("DELETE", "/_xpack/watcher/watch/" + watchId)); + Response response = client().performRequest(new Request("DELETE", "/watcher/watch/" + watchId)); assertOK(response); ObjectPath path = ObjectPath.createFromResponse(response); boolean found = path.evaluate("found"); @@ -207,7 +207,7 @@ private ObjectPath getWatchHistoryEntry(String watchId) throws Exception { } private void assertWatchCount(int expectedWatches) throws IOException { - Response watcherStatsResponse = adminClient().performRequest(new Request("GET", "/_xpack/watcher/stats")); + Response watcherStatsResponse = adminClient().performRequest(new Request("GET", "/watcher/stats")); ObjectPath objectPath = ObjectPath.createFromResponse(watcherStatsResponse); int watchCount = objectPath.evaluate("stats.0.watch_count"); assertThat(watchCount, is(expectedWatches)); From d6c7039adebe6789a750704883d97effe4aef960 Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Tue, 4 Dec 2018 09:57:42 -0600 Subject: [PATCH 2/7] Missed reference due to backslash --- x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc index 3ff4cf9635579..2a9b907703ac4 100644 --- a/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc @@ -237,7 +237,7 @@ parameter: -------------------------------------------------- POST watcher/watch/my_watch/_ack -------------------------------------------------- -// TEST[s/^/POST _xpack\/watcher\/watch\/my_watch\/_execute\n{ "record_execution" : true }\n/] +// TEST[s/^/POST watcher\/watch\/my_watch\/_execute\n{ "record_execution" : true }\n/] // CONSOLE From 7652e698dadbae7cce4416b63bdc15fafe21ec2c Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Tue, 4 Dec 2018 10:45:54 -0600 Subject: [PATCH 3/7] Adding underbar to the index name for reserving it --- .../client/WatcherRequestConverters.java | 18 +++---- .../org/elasticsearch/client/WatcherIT.java | 2 +- .../client/WatcherRequestConvertersTests.java | 18 +++---- .../documentation/WatcherDocumentationIT.java | 2 +- .../en/rest-api/watcher/ack-watch.asciidoc | 22 ++++---- .../rest-api/watcher/activate-watch.asciidoc | 6 +-- .../watcher/deactivate-watch.asciidoc | 6 +-- .../en/rest-api/watcher/delete-watch.asciidoc | 4 +- .../rest-api/watcher/execute-watch.asciidoc | 16 +++--- .../en/rest-api/watcher/get-watch.asciidoc | 4 +- .../en/rest-api/watcher/put-watch.asciidoc | 6 +-- .../docs/en/rest-api/watcher/start.asciidoc | 4 +- .../docs/en/rest-api/watcher/stats.asciidoc | 12 ++--- x-pack/docs/en/rest-api/watcher/stop.asciidoc | 4 +- x-pack/docs/en/watcher/actions.asciidoc | 8 +-- .../example-watch-clusterstatus.asciidoc | 12 ++--- .../example-watch-meetupdata.asciidoc | 4 +- .../watching-time-series-data.asciidoc | 4 +- .../docs/en/watcher/getting-started.asciidoc | 8 +-- .../en/watcher/how-watcher-works.asciidoc | 2 +- .../authz/privilege/ClusterPrivilege.java | 4 +- .../authz/store/ReservedRolesStore.java | 6 +-- .../transport/actions/ack/AckWatchAction.java | 2 +- .../actions/activate/ActivateWatchAction.java | 2 +- .../actions/delete/DeleteWatchAction.java | 2 +- .../actions/execute/ExecuteWatchAction.java | 2 +- .../transport/actions/get/GetWatchAction.java | 2 +- .../transport/actions/put/PutWatchAction.java | 2 +- .../actions/service/WatcherServiceAction.java | 2 +- .../actions/stats/WatcherStatsAction.java | 2 +- .../http/ClusterAlertHttpResource.java | 6 +-- .../http/ClusterAlertHttpResourceTests.java | 22 ++++---- .../exporter/http/HttpExporterIT.java | 6 +-- .../http/HttpExporterResourceTests.java | 26 +++++----- .../xpack/test/rest/XPackRestIT.java | 2 +- .../api/xpack.watcher.ack_watch.json | 4 +- .../api/xpack.watcher.activate_watch.json | 4 +- .../api/xpack.watcher.deactivate_watch.json | 4 +- .../api/xpack.watcher.delete_watch.json | 4 +- .../api/xpack.watcher.execute_watch.json | 4 +- .../api/xpack.watcher.get_watch.json | 4 +- .../api/xpack.watcher.put_watch.json | 4 +- .../api/xpack.watcher.start.json | 4 +- .../api/xpack.watcher.stats.json | 4 +- .../rest-api-spec/api/xpack.watcher.stop.json | 4 +- .../watcher/rest/WatcherRestHandler.java | 2 +- .../xpack/restart/FullClusterRestartIT.java | 50 +++++++++---------- .../upgrades/WatcherRestartIT.java | 8 +-- .../MonitoringWithWatcherRestIT.java | 4 +- .../SmokeTestWatcherWithSecurityIT.java | 10 ++-- .../SmokeTestWatcherTestSuiteIT.java | 14 +++--- 51 files changed, 189 insertions(+), 189 deletions(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java index d7c895feaec43..0d6efa780ea52 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java @@ -42,7 +42,7 @@ private WatcherRequestConverters() {} static Request startWatchService(StartWatchServiceRequest startWatchServiceRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("watcher") + .addPathPartAsIs("_watcher") .addPathPartAsIs("_start") .build(); @@ -51,7 +51,7 @@ static Request startWatchService(StartWatchServiceRequest startWatchServiceReque static Request stopWatchService(StopWatchServiceRequest stopWatchServiceRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("watcher") + .addPathPartAsIs("_watcher") .addPathPartAsIs("_stop") .build(); @@ -60,7 +60,7 @@ static Request stopWatchService(StopWatchServiceRequest stopWatchServiceRequest) static Request putWatch(PutWatchRequest putWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("watcher", "watch") + .addPathPartAsIs("_watcher", "watch") .addPathPart(putWatchRequest.getId()) .build(); @@ -78,7 +78,7 @@ static Request putWatch(PutWatchRequest putWatchRequest) { static Request getWatch(GetWatchRequest getWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("watcher", "watch") + .addPathPartAsIs("_watcher", "watch") .addPathPart(getWatchRequest.getId()) .build(); @@ -87,7 +87,7 @@ static Request getWatch(GetWatchRequest getWatchRequest) { static Request deactivateWatch(DeactivateWatchRequest deactivateWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("watcher") + .addPathPartAsIs("_watcher") .addPathPartAsIs("watch") .addPathPart(deactivateWatchRequest.getWatchId()) .addPathPartAsIs("_deactivate") @@ -97,7 +97,7 @@ static Request deactivateWatch(DeactivateWatchRequest deactivateWatchRequest) { static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("watcher", "watch") + .addPathPartAsIs("_watcher", "watch") .addPathPart(deleteWatchRequest.getId()) .build(); @@ -107,7 +107,7 @@ static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) { public static Request ackWatch(AckWatchRequest ackWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("watcher", "watch") + .addPathPartAsIs("_watcher", "watch") .addPathPart(ackWatchRequest.getWatchId()) .addPathPartAsIs("_ack") .addCommaSeparatedPathParts(ackWatchRequest.getActionIds()) @@ -118,7 +118,7 @@ public static Request ackWatch(AckWatchRequest ackWatchRequest) { static Request activateWatch(ActivateWatchRequest activateWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("watcher", "watch") + .addPathPartAsIs("_watcher", "watch") .addPathPart(activateWatchRequest.getWatchId()) .addPathPartAsIs("_activate") .build(); @@ -127,7 +127,7 @@ static Request activateWatch(ActivateWatchRequest activateWatchRequest) { } static Request watcherStats(WatcherStatsRequest watcherStatsRequest) { - RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder().addPathPartAsIs("watcher", "stats"); + RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher", "stats"); String endpoint = builder.build(); Request request = new Request(HttpGet.METHOD_NAME, endpoint); RequestConverters.Params parameters = new RequestConverters.Params(request); 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 3c514917c0a1e..c87de1ca0856f 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 @@ -146,7 +146,7 @@ public void testAckWatch() throws Exception { assertEquals(AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION, actionStatus.ackStatus().state()); // TODO: use the high-level REST client here once it supports 'execute watch'. - Request executeWatchRequest = new Request("POST", "watcher/watch/" + watchId + "/_execute"); + Request executeWatchRequest = new Request("POST", "_watcher/watch/" + watchId + "/_execute"); executeWatchRequest.setJsonEntity("{ \"record_execution\": true }"); Response executeResponse = client().performRequest(executeWatchRequest); assertEquals(RestStatus.OK.getStatus(), executeResponse.getStatusLine().getStatusCode()); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java index c888ef7e2314a..4b89f2bd82d83 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java @@ -56,13 +56,13 @@ public class WatcherRequestConvertersTests extends ESTestCase { public void testStartWatchService() { Request request = WatcherRequestConverters.startWatchService(new StartWatchServiceRequest()); assertEquals(HttpPost.METHOD_NAME, request.getMethod()); - assertEquals("/watcher/_start", request.getEndpoint()); + assertEquals("/_watcher/_start", request.getEndpoint()); } public void testStopWatchService() { Request request = WatcherRequestConverters.stopWatchService(new StopWatchServiceRequest()); assertEquals(HttpPost.METHOD_NAME, request.getMethod()); - assertEquals("/watcher/_stop", request.getEndpoint()); + assertEquals("/_watcher/_stop", request.getEndpoint()); } public void testPutWatch() throws Exception { @@ -84,7 +84,7 @@ public void testPutWatch() throws Exception { Request request = WatcherRequestConverters.putWatch(putWatchRequest); assertEquals(HttpPut.METHOD_NAME, request.getMethod()); - assertEquals("/watcher/watch/" + watchId, request.getEndpoint()); + assertEquals("/_watcher/watch/" + watchId, request.getEndpoint()); assertEquals(expectedParams, request.getParameters()); assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters())); ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -98,7 +98,7 @@ public void testGetWatch() throws Exception { Request request = WatcherRequestConverters.getWatch(getWatchRequest); assertEquals(HttpGet.METHOD_NAME, request.getMethod()); - assertEquals("/watcher/watch/" + watchId, request.getEndpoint()); + assertEquals("/_watcher/watch/" + watchId, request.getEndpoint()); assertThat(request.getEntity(), nullValue()); } @@ -108,7 +108,7 @@ public void testDeactivateWatch() { Request request = WatcherRequestConverters.deactivateWatch(deactivateWatchRequest); assertEquals(HttpPut.METHOD_NAME, request.getMethod()); - assertEquals("/watcher/watch/" + watchId + "/_deactivate", request.getEndpoint()); + assertEquals("/_watcher/watch/" + watchId + "/_deactivate", request.getEndpoint()); } public void testDeleteWatch() { @@ -117,7 +117,7 @@ public void testDeleteWatch() { Request request = WatcherRequestConverters.deleteWatch(deleteWatchRequest); assertEquals(HttpDelete.METHOD_NAME, request.getMethod()); - assertEquals("/watcher/watch/" + watchId, request.getEndpoint()); + assertEquals("/_watcher/watch/" + watchId, request.getEndpoint()); assertThat(request.getEntity(), nullValue()); } @@ -131,7 +131,7 @@ public void testAckWatch() { assertEquals(HttpPut.METHOD_NAME, request.getMethod()); StringJoiner expectedEndpoint = new StringJoiner("/", "/", "") - .add("watcher").add("watch").add(watchId).add("_ack"); + .add("_watcher").add("watch").add(watchId).add("_ack"); if (ackWatchRequest.getActionIds().length > 0) { String actionsParam = String.join(",", ackWatchRequest.getActionIds()); expectedEndpoint.add(actionsParam); @@ -147,7 +147,7 @@ public void testActivateWatchRequestConversion() { Request request = WatcherRequestConverters.activateWatch(activateWatchRequest); assertEquals(HttpPut.METHOD_NAME, request.getMethod()); - assertEquals("/watcher/watch/" + watchId + "/_activate", request.getEndpoint()); + assertEquals("/_watcher/watch/" + watchId + "/_activate", request.getEndpoint()); assertThat(request.getEntity(), nullValue()); } @@ -158,7 +158,7 @@ public void testWatcherStatsRequest() { WatcherStatsRequest watcherStatsRequest = new WatcherStatsRequest(includeCurrent, includeQueued); Request request = WatcherRequestConverters.watcherStats(watcherStatsRequest); - assertThat(request.getEndpoint(), equalTo("/watcher/stats")); + assertThat(request.getEndpoint(), equalTo("/_watcher/stats")); assertThat(request.getMethod(), equalTo(HttpGet.METHOD_NAME)); if (includeCurrent || includeQueued) { assertThat(request.getParameters(), hasKey("metric")); 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 651b495769e84..5b7dba9bb09fd 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 @@ -298,7 +298,7 @@ public void testAckWatch() throws Exception { client.watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT); // TODO: use the high-level REST client here once it supports 'execute watch'. - Request executeWatchRequest = new Request("POST", "watcher/watch/my_watch_id/_execute"); + Request executeWatchRequest = new Request("POST", "_watcher/watch/my_watch_id/_execute"); executeWatchRequest.setJsonEntity("{ \"record_execution\": true }"); Response executeResponse = client().performRequest(executeWatchRequest); assertEquals(RestStatus.OK.getStatus(), executeResponse.getStatusLine().getStatusCode()); diff --git a/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc index 2a9b907703ac4..f2e1da5309d46 100644 --- a/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc @@ -14,9 +14,9 @@ execution. [float] ==== Request -`PUT watcher/watch//_ack` + +`PUT _watcher/watch//_ack` + -`PUT watcher/watch//_ack/` +`PUT _watcher/watch//_ack/` [float] ==== Path Parameters @@ -42,7 +42,7 @@ To demonstrate let's create a new watch: [source,js] -------------------------------------------------- -PUT watcher/watch/my_watch +PUT _watcher/watch/my_watch { "trigger": { "schedule": { @@ -80,7 +80,7 @@ watch definition when you call the <>: [source,js] -------------------------------------------------- -GET watcher/watch/my_watch +GET _watcher/watch/my_watch -------------------------------------------------- // CONSOLE @@ -117,12 +117,12 @@ check the status: [source,js] -------------------------------------------------- -POST watcher/watch/my_watch/_execute +POST _watcher/watch/my_watch/_execute { "record_execution" : true } -GET watcher/watch/my_watch +GET _watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[continued] @@ -172,8 +172,8 @@ Now we can acknowledge it: [source,js] -------------------------------------------------- -PUT watcher/watch/my_watch/_ack/test_index -GET watcher/watch/my_watch +PUT _watcher/watch/my_watch/_ack/test_index +GET _watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[continued] @@ -226,7 +226,7 @@ comma-separated list of action ids: [source,js] -------------------------------------------------- -POST watcher/watch/my_watch/_ack/action1,action2 +POST _watcher/watch/my_watch/_ack/action1,action2 -------------------------------------------------- // CONSOLE @@ -235,9 +235,9 @@ parameter: [source,js] -------------------------------------------------- -POST watcher/watch/my_watch/_ack +POST _watcher/watch/my_watch/_ack -------------------------------------------------- -// TEST[s/^/POST watcher\/watch\/my_watch\/_execute\n{ "record_execution" : true }\n/] +// TEST[s/^/POST _watcher\/watch\/my_watch\/_execute\n{ "record_execution" : true }\n/] // CONSOLE diff --git a/x-pack/docs/en/rest-api/watcher/activate-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/activate-watch.asciidoc index fd14888a36774..638ef4c55a8fc 100644 --- a/x-pack/docs/en/rest-api/watcher/activate-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/activate-watch.asciidoc @@ -9,7 +9,7 @@ API enables you to activate a currently inactive watch. [float] ==== Request -`PUT watcher/watch//_activate` +`PUT _watcher/watch//_activate` [float] ==== Path Parameters @@ -31,7 +31,7 @@ call the <>: [source,js] -------------------------------------------------- -GET watcher/watch/my_watch +GET _watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[setup:my_inactive_watch] @@ -62,7 +62,7 @@ You can activate the watch by executing the following API call: [source,js] -------------------------------------------------- -PUT watcher/watch/my_watch/_activate +PUT _watcher/watch/my_watch/_activate -------------------------------------------------- // CONSOLE // TEST[setup:my_inactive_watch] diff --git a/x-pack/docs/en/rest-api/watcher/deactivate-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/deactivate-watch.asciidoc index 9cfccaec59c9a..cdda46c2592f1 100644 --- a/x-pack/docs/en/rest-api/watcher/deactivate-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/deactivate-watch.asciidoc @@ -9,7 +9,7 @@ API enables you to deactivate a currently active watch. [float] ==== Request -`PUT watcher/watch//_deactivate` +`PUT _watcher/watch//_deactivate` [float] ==== Path Parameters @@ -30,7 +30,7 @@ call the <>: [source,js] -------------------------------------------------- -GET watcher/watch/my_watch +GET _watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[setup:my_active_watch] @@ -61,7 +61,7 @@ You can deactivate the watch by executing the following API call: [source,js] -------------------------------------------------- -PUT watcher/watch/my_watch/_deactivate +PUT _watcher/watch/my_watch/_deactivate -------------------------------------------------- // CONSOLE // TEST[setup:my_active_watch] diff --git a/x-pack/docs/en/rest-api/watcher/delete-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/delete-watch.asciidoc index 9daf58bc216bf..8a2fbd5a57721 100644 --- a/x-pack/docs/en/rest-api/watcher/delete-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/delete-watch.asciidoc @@ -7,7 +7,7 @@ The DELETE watch API removes a watch from {watcher}. [float] ==== Request -`DELETE watcher/watch/` +`DELETE _watcher/watch/` [float] ==== Description @@ -42,7 +42,7 @@ The following example deletes a watch with the `my-watch` id: [source,js] -------------------------------------------------- -DELETE watcher/watch/my_watch +DELETE _watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[setup:my_active_watch] diff --git a/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc index cd67658decc32..926c1b87883da 100644 --- a/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc @@ -9,9 +9,9 @@ watch execution for debugging purposes. [float] ==== Request -`POST watcher/watch//_execute` + +`POST _watcher/watch//_execute` + -`POST watcher/watch/_execute` +`POST _watcher/watch/_execute` [float] ==== Description @@ -137,7 +137,7 @@ The following example executes the `my_watch` watch: [source,js] -------------------------------------------------- -POST watcher/watch/my_watch/_execute +POST _watcher/watch/my_watch/_execute -------------------------------------------------- // CONSOLE // TEST[setup:my_active_watch] @@ -146,7 +146,7 @@ The following example shows a comprehensive example of executing the `my-watch` [source,js] -------------------------------------------------- -POST watcher/watch/my_watch/_execute +POST _watcher/watch/my_watch/_execute { "trigger_data" : { <1> "triggered_time" : "now", @@ -289,7 +289,7 @@ name with the action id: [source,js] -------------------------------------------------- -POST watcher/watch/my_watch/_execute +POST _watcher/watch/my_watch/_execute { "action_modes" : { "action1" : "force_simulate", @@ -305,7 +305,7 @@ using `_all` as the action id: [source,js] -------------------------------------------------- -POST watcher/watch/my_watch/_execute +POST _watcher/watch/my_watch/_execute { "action_modes" : { "_all" : "force_execute" @@ -319,7 +319,7 @@ The following example shows how to execute a watch inline: [source,js] -------------------------------------------------- -POST watcher/watch/_execute +POST _watcher/watch/_execute { "watch" : { "trigger" : { "schedule" : { "interval" : "10s" } }, @@ -356,7 +356,7 @@ during the execution this condition will be ignored: [source,js] -------------------------------------------------- -POST watcher/watch/_execute +POST _watcher/watch/_execute { "ignore_condition" : true, "watch" : { diff --git a/x-pack/docs/en/rest-api/watcher/get-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/get-watch.asciidoc index 7359aa5908f8a..434ce73703bf3 100644 --- a/x-pack/docs/en/rest-api/watcher/get-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/get-watch.asciidoc @@ -7,7 +7,7 @@ This API retrieves a watch by its ID. [float] ==== Request -`GET watcher/watch/` +`GET _watcher/watch/` [float] ==== Path Parameters @@ -29,7 +29,7 @@ The following example gets a watch with `my-watch` id: [source,js] -------------------------------------------------- -GET watcher/watch/my_watch +GET _watcher/watch/my_watch -------------------------------------------------- // CONSOLE // TEST[setup:my_active_watch] diff --git a/x-pack/docs/en/rest-api/watcher/put-watch.asciidoc b/x-pack/docs/en/rest-api/watcher/put-watch.asciidoc index 17ddb9b825820..8026d2e565d4e 100644 --- a/x-pack/docs/en/rest-api/watcher/put-watch.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/put-watch.asciidoc @@ -8,7 +8,7 @@ existing one. [float] ==== Request -`PUT watcher/watch/` +`PUT _watcher/watch/` [float] ==== Description @@ -96,7 +96,7 @@ characteristics: [source,js] -------------------------------------------------- -PUT watcher/watch/my-watch +PUT _watcher/watch/my-watch { "trigger" : { "schedule" : { "cron" : "0 0/1 * * * ?" } @@ -151,7 +151,7 @@ it to be inactive by default: [source,js] -------------------------------------------------- -PUT watcher/watch/my-watch?active=false +PUT _watcher/watch/my-watch?active=false -------------------------------------------------- NOTE: If you omit the `active` parameter, the watch is active by default. diff --git a/x-pack/docs/en/rest-api/watcher/start.asciidoc b/x-pack/docs/en/rest-api/watcher/start.asciidoc index 81a1aaaaea199..25f41586c0783 100644 --- a/x-pack/docs/en/rest-api/watcher/start.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/start.asciidoc @@ -8,7 +8,7 @@ running. [float] ==== Request -`POST watcher/_start` +`POST _watcher/_start` ==== Authorization @@ -20,7 +20,7 @@ information, see {xpack-ref}/security-privileges.html[Security Privileges]. [source,js] -------------------------------------------------- -POST watcher/_start +POST _watcher/_start -------------------------------------------------- // CONSOLE diff --git a/x-pack/docs/en/rest-api/watcher/stats.asciidoc b/x-pack/docs/en/rest-api/watcher/stats.asciidoc index d9b9f8e790c11..3d99915514a9e 100644 --- a/x-pack/docs/en/rest-api/watcher/stats.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/stats.asciidoc @@ -7,9 +7,9 @@ The `stats` API returns the current {watcher} metrics. [float] ==== Request -`GET watcher/stats` + +`GET _watcher/stats` + -`GET watcher/stats/` +`GET _watcher/stats/` [float] ==== Description @@ -69,7 +69,7 @@ The following example calls the `stats` API to retrieve basic metrics: [source,js] -------------------------------------------------- -GET watcher/stats +GET _watcher/stats -------------------------------------------------- // CONSOLE @@ -98,7 +98,7 @@ and will include the basic metrics and metrics about the current executing watch [source,js] -------------------------------------------------- -GET watcher/stats?metric=current_watches +GET _watcher/stats?metric=current_watches -------------------------------------------------- // CONSOLE @@ -106,7 +106,7 @@ The following example specifies the `metric` option as part of the url path: [source,js] -------------------------------------------------- -GET watcher/stats/current_watches +GET _watcher/stats/current_watches -------------------------------------------------- // CONSOLE @@ -151,7 +151,7 @@ both the basic metrics and the queued watches: [source,js] -------------------------------------------------- -GET watcher/stats/queued_watches +GET _watcher/stats/queued_watches -------------------------------------------------- // CONSOLE diff --git a/x-pack/docs/en/rest-api/watcher/stop.asciidoc b/x-pack/docs/en/rest-api/watcher/stop.asciidoc index 4a983cfc5f299..0d34717d4eeed 100644 --- a/x-pack/docs/en/rest-api/watcher/stop.asciidoc +++ b/x-pack/docs/en/rest-api/watcher/stop.asciidoc @@ -7,7 +7,7 @@ The `stop` API stops the {watcher} service if the service is running. [float] ==== Request -`POST watcher/_stop` +`POST _watcher/_stop` [float] ==== Authorization @@ -20,7 +20,7 @@ information, see {xpack-ref}/security-privileges.html[Security Privileges]. [source,js] -------------------------------------------------- -POST watcher/_stop +POST _watcher/_stop -------------------------------------------------- // CONSOLE diff --git a/x-pack/docs/en/watcher/actions.asciidoc b/x-pack/docs/en/watcher/actions.asciidoc index f6701ae65583a..0c07ffe69032f 100644 --- a/x-pack/docs/en/watcher/actions.asciidoc +++ b/x-pack/docs/en/watcher/actions.asciidoc @@ -46,7 +46,7 @@ a throttle period with the `email_administrator` action: [source,js] -------------------------------------------------- -PUT watcher/watch/error_logs_alert +PUT _watcher/watch/error_logs_alert { "metadata" : { "color" : "red" @@ -101,7 +101,7 @@ defined in the watch: [source,js] -------------------------------------------------- -PUT watcher/watch/log_event_watch +PUT _watcher/watch/log_event_watch { "trigger" : { "schedule" : { "interval" : "5m" } @@ -177,7 +177,7 @@ To acknowledge an action, you use the [source,js] ---------------------------------------------------------------------- -POST watcher/watch//_ack/ +POST _watcher/watch//_ack/ ---------------------------------------------------------------------- // CONSOLE // TEST[skip:https://github.com/elastic/x-plugins/issues/2513] @@ -204,7 +204,7 @@ there are more than 5 hits in the search result. [source,js] -------------------------------------------------- -PUT watcher/watch/log_event_watch +PUT _watcher/watch/log_event_watch { "trigger" : { "schedule" : { "interval" : "5m" } diff --git a/x-pack/docs/en/watcher/example-watches/example-watch-clusterstatus.asciidoc b/x-pack/docs/en/watcher/example-watches/example-watch-clusterstatus.asciidoc index 19f305d3c70f9..5506f206b45fc 100644 --- a/x-pack/docs/en/watcher/example-watches/example-watch-clusterstatus.asciidoc +++ b/x-pack/docs/en/watcher/example-watches/example-watch-clusterstatus.asciidoc @@ -24,7 +24,7 @@ the following schedule runs every 10 seconds: [source,js] -------------------------------------------------- -PUT watcher/watch/cluster_health_watch +PUT _watcher/watch/cluster_health_watch { "trigger" : { "schedule" : { "interval" : "10s" } <1> @@ -52,7 +52,7 @@ To load the health status into your watch, you simply add an [source,js] -------------------------------------------------- -PUT watcher/watch/cluster_health_watch +PUT _watcher/watch/cluster_health_watch { "trigger" : { "schedule" : { "interval" : "10s" } @@ -74,7 +74,7 @@ If you're using Security, then you'll also need to supply some authentication cr [source,js] -------------------------------------------------- -PUT watcher/watch/cluster_health_watch +PUT _watcher/watch/cluster_health_watch { "trigger" : { "schedule" : { "interval" : "10s" } @@ -134,7 +134,7 @@ For example, you could add a condition to check to see if the status is RED. [source,js] -------------------------------------------------- -PUT watcher/watch/cluster_health_watch +PUT _watcher/watch/cluster_health_watch { "trigger" : { "schedule" : { "interval" : "10s" } <1> @@ -191,7 +191,7 @@ when the status is RED. [source,js] -------------------------------------------------- -PUT watcher/watch/cluster_health_watch +PUT _watcher/watch/cluster_health_watch { "trigger" : { "schedule" : { "interval" : "10s" } @@ -280,7 +280,7 @@ To remove the watch, use the {ref}/watcher-api-delete-watch.html[DELETE watch AP [source,js] ------------------------------------------------------- -DELETE watcher/watch/cluster_health_watch +DELETE _watcher/watch/cluster_health_watch ------------------------------------------------------- // CONSOLE // TEST[continued] diff --git a/x-pack/docs/en/watcher/example-watches/example-watch-meetupdata.asciidoc b/x-pack/docs/en/watcher/example-watches/example-watch-meetupdata.asciidoc index 4f53c14727229..fd9c1ea3aa7ee 100644 --- a/x-pack/docs/en/watcher/example-watches/example-watch-meetupdata.asciidoc +++ b/x-pack/docs/en/watcher/example-watches/example-watch-meetupdata.asciidoc @@ -194,7 +194,7 @@ NOTE: To enable Watcher to send emails, you must configure an email account in ` The complete watch looks like this: [source,js] -------------------------------------------------- -PUT watcher/watch/meetup +PUT _watcher/watch/meetup { "trigger": { "schedule": { @@ -300,7 +300,7 @@ Now that you've created your watch, you can use the [source,js] -------------------------------------------------- -POST watcher/watch/meetup/_execute +POST _watcher/watch/meetup/_execute -------------------------------------------------- // CONSOLE // TEST[continued] diff --git a/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc b/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc index f307e247d1d40..d79eef11da468 100644 --- a/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc +++ b/x-pack/docs/en/watcher/example-watches/watching-time-series-data.asciidoc @@ -157,7 +157,7 @@ The complete watch looks like this: [source,js] -------------------------------------------------- -PUT watcher/watch/rss_watch +PUT _watcher/watch/rss_watch { "trigger" : { "schedule" : { @@ -215,7 +215,7 @@ use the {ref}/watcher-api-execute-watch.html[`_execute` API]: [source,js] -------------------------------------------------- -POST watcher/watch/rss_watch/_execute +POST _watcher/watch/rss_watch/_execute { "ignore_condition" : true, "action_modes" : { diff --git a/x-pack/docs/en/watcher/getting-started.asciidoc b/x-pack/docs/en/watcher/getting-started.asciidoc index fb3ec7f8c57f3..6ab5124383bd3 100644 --- a/x-pack/docs/en/watcher/getting-started.asciidoc +++ b/x-pack/docs/en/watcher/getting-started.asciidoc @@ -28,7 +28,7 @@ the `logs` index for errors every 10 seconds: [source,js] ------------------------------------------------------------ -PUT watcher/watch/log_error_watch +PUT _watcher/watch/log_error_watch { "trigger" : { "schedule" : { "interval" : "10s" } <1> @@ -86,7 +86,7 @@ search input returned any hits. [source,js] -------------------------------------------------- -PUT watcher/watch/log_error_watch +PUT _watcher/watch/log_error_watch { "trigger" : { "schedule" : { "interval" : "10s" }}, "input" : { @@ -165,7 +165,7 @@ log when an error is detected. [source,js] -------------------------------------------------- -PUT watcher/watch/log_error_watch +PUT _watcher/watch/log_error_watch { "trigger" : { "schedule" : { "interval" : "10s" }}, "input" : { @@ -207,7 +207,7 @@ To remove the watch, use the {ref}/watcher-api-delete-watch.html[DELETE watch AP [source,js] -------------------------------------------------- -DELETE watcher/watch/log_error_watch +DELETE _watcher/watch/log_error_watch -------------------------------------------------- // CONSOLE // TEST[continued] diff --git a/x-pack/docs/en/watcher/how-watcher-works.asciidoc b/x-pack/docs/en/watcher/how-watcher-works.asciidoc index 0ea85fd14ef00..4980075fa01b4 100644 --- a/x-pack/docs/en/watcher/how-watcher-works.asciidoc +++ b/x-pack/docs/en/watcher/how-watcher-works.asciidoc @@ -48,7 +48,7 @@ looks for log error events: [source,js] -------------------------------------------------- -PUT watcher/watch/log_errors +PUT _watcher/watch/log_errors { "metadata" : { <1> "color" : "red" diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilege.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilege.java index 1147109767673..9c03941b0313a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilege.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/privilege/ClusterPrivilege.java @@ -34,12 +34,12 @@ public final class ClusterPrivilege extends Privilege { private static final Automaton MANAGE_TOKEN_AUTOMATON = patterns("cluster:admin/xpack/security/token/*"); private static final Automaton MONITOR_AUTOMATON = patterns("cluster:monitor/*"); private static final Automaton MONITOR_ML_AUTOMATON = patterns("cluster:monitor/xpack/ml/*"); - private static final Automaton MONITOR_WATCHER_AUTOMATON = patterns("cluster:monitor/watcher/*"); + private static final Automaton MONITOR_WATCHER_AUTOMATON = patterns("cluster:monitor/xpack/watcher/*"); private static final Automaton MONITOR_ROLLUP_AUTOMATON = patterns("cluster:monitor/xpack/rollup/*"); private static final Automaton ALL_CLUSTER_AUTOMATON = patterns("cluster:*", "indices:admin/template/*"); private static final Automaton MANAGE_AUTOMATON = minusAndMinimize(ALL_CLUSTER_AUTOMATON, MANAGE_SECURITY_AUTOMATON); private static final Automaton MANAGE_ML_AUTOMATON = patterns("cluster:admin/xpack/ml/*", "cluster:monitor/xpack/ml/*"); - private static final Automaton MANAGE_WATCHER_AUTOMATON = patterns("cluster:admin/watcher/*", "cluster:monitor/watcher/*"); + private static final Automaton MANAGE_WATCHER_AUTOMATON = patterns("cluster:admin/xpack/watcher/*", "cluster:monitor/xpack/watcher/*"); private static final Automaton TRANSPORT_CLIENT_AUTOMATON = patterns("cluster:monitor/nodes/liveness", "cluster:monitor/state"); private static final Automaton MANAGE_IDX_TEMPLATE_AUTOMATON = patterns("indices:admin/template/*"); private static final Automaton MANAGE_INGEST_PIPELINE_AUTOMATON = patterns("cluster:admin/ingest/pipeline/*"); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java index a414dcaa087e3..046cf59254957 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java @@ -67,9 +67,9 @@ private static Map initializeReservedRoles() { .put("remote_monitoring_agent", new RoleDescriptor("remote_monitoring_agent", new String[] { "manage_index_templates", "manage_ingest_pipelines", "monitor", - "cluster:monitor/watcher/watch/get", - "cluster:admin/watcher/watch/put", - "cluster:admin/watcher/watch/delete", + "cluster:monitor/xpack/watcher/watch/get", + "cluster:admin/xpack/watcher/watch/put", + "cluster:admin/xpack/watcher/watch/delete", }, new RoleDescriptor.IndicesPrivileges[] { RoleDescriptor.IndicesPrivileges.builder().indices(".monitoring-*").privileges("all").build(), diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/ack/AckWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/ack/AckWatchAction.java index d0ce3559f06e6..04ec95a369af2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/ack/AckWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/ack/AckWatchAction.java @@ -13,7 +13,7 @@ public class AckWatchAction extends Action { public static final AckWatchAction INSTANCE = new AckWatchAction(); - public static final String NAME = "cluster:admin/watcher/watch/ack"; + public static final String NAME = "cluster:admin/xpack/watcher/watch/ack"; private AckWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/activate/ActivateWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/activate/ActivateWatchAction.java index 35e9868b88765..936a21711547e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/activate/ActivateWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/activate/ActivateWatchAction.java @@ -13,7 +13,7 @@ public class ActivateWatchAction extends Action { public static final ActivateWatchAction INSTANCE = new ActivateWatchAction(); - public static final String NAME = "cluster:admin/watcher/watch/activate"; + public static final String NAME = "cluster:admin/xpack/watcher/watch/activate"; private ActivateWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/delete/DeleteWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/delete/DeleteWatchAction.java index 1fc2ef1280616..eb440ddc2510e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/delete/DeleteWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/delete/DeleteWatchAction.java @@ -14,7 +14,7 @@ public class DeleteWatchAction extends Action { public static final DeleteWatchAction INSTANCE = new DeleteWatchAction(); - public static final String NAME = "cluster:admin/watcher/watch/delete"; + public static final String NAME = "cluster:admin/xpack/watcher/watch/delete"; private DeleteWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/execute/ExecuteWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/execute/ExecuteWatchAction.java index b207525e36531..924f170959426 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/execute/ExecuteWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/execute/ExecuteWatchAction.java @@ -14,7 +14,7 @@ public class ExecuteWatchAction extends Action { public static final ExecuteWatchAction INSTANCE = new ExecuteWatchAction(); - public static final String NAME = "cluster:admin/watcher/watch/execute"; + public static final String NAME = "cluster:admin/xpack/watcher/watch/execute"; private ExecuteWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/get/GetWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/get/GetWatchAction.java index abe6327434dae..4df72a964b65f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/get/GetWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/get/GetWatchAction.java @@ -11,7 +11,7 @@ public class GetWatchAction extends org.elasticsearch.action.Action { public static final GetWatchAction INSTANCE = new GetWatchAction(); - public static final String NAME = "cluster:monitor/watcher/watch/get"; + public static final String NAME = "cluster:monitor/xpack/watcher/watch/get"; private GetWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/put/PutWatchAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/put/PutWatchAction.java index 07ead7fa4c211..509116b018e2b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/put/PutWatchAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/put/PutWatchAction.java @@ -14,7 +14,7 @@ public class PutWatchAction extends Action { public static final PutWatchAction INSTANCE = new PutWatchAction(); - public static final String NAME = "cluster:admin/watcher/watch/put"; + public static final String NAME = "cluster:admin/xpack/watcher/watch/put"; private PutWatchAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java index f692d8e0d5893..30b0b54725b5f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java @@ -12,7 +12,7 @@ public class WatcherServiceAction extends Action { public static final WatcherServiceAction INSTANCE = new WatcherServiceAction(); - public static final String NAME = "cluster:admin/watcher/service"; + public static final String NAME = "cluster:admin/xpack/watcher/service"; private WatcherServiceAction() { super(NAME); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsAction.java index 26610d5533f57..59fcff090f59e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/stats/WatcherStatsAction.java @@ -13,7 +13,7 @@ public class WatcherStatsAction extends Action { public static final WatcherStatsAction INSTANCE = new WatcherStatsAction(); - public static final String NAME = "cluster:monitor/watcher/stats/dist"; + public static final String NAME = "cluster:monitor/xpack/watcher/stats/dist"; private WatcherStatsAction() { super(NAME); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java index a6f445f97b9f9..f6547c575f787 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResource.java @@ -87,13 +87,13 @@ protected void doCheck(final RestClient client, final ActionListener li (response) -> shouldReplaceClusterAlert(response, XContentType.JSON.xContent(), LAST_UPDATED_VERSION); checkForResource(client, listener, logger, - "/watcher/watch", watchId.get(), "monitoring cluster alert", + "/_watcher/watch", watchId.get(), "monitoring cluster alert", resourceOwnerName, "monitoring cluster", GET_EXISTS, GET_DOES_NOT_EXIST, watchChecker, this::alwaysReplaceResource); } else { // if we should be deleting, then just try to delete it (same level of effort as checking) - deleteResource(client, listener, logger, "/watcher/watch", watchId.get(), + deleteResource(client, listener, logger, "/_watcher/watch", watchId.get(), "monitoring cluster alert", resourceOwnerName, "monitoring cluster"); } @@ -105,7 +105,7 @@ protected void doCheck(final RestClient client, final ActionListener li @Override protected void doPublish(final RestClient client, final ActionListener listener) { putResource(client, listener, logger, - "/watcher/watch", watchId.get(), this::watchToHttpEntity, "monitoring cluster alert", + "/_watcher/watch", watchId.get(), this::watchToHttpEntity, "monitoring cluster alert", resourceOwnerName, "monitoring cluster"); } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResourceTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResourceTests.java index efcd8b875ac95..af608d85911cb 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResourceTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/ClusterAlertHttpResourceTests.java @@ -63,7 +63,7 @@ public void testDoCheckGetWatchExists() throws IOException { final HttpEntity entity = entityForClusterAlert(true, minimumVersion); - doCheckWithStatusCode(resource, "/watcher/watch", watchId, successfulCheckStatus(), true, entity); + doCheckWithStatusCode(resource, "/_watcher/watch", watchId, successfulCheckStatus(), true, entity); } public void testDoCheckGetWatchDoesNotExist() throws IOException { @@ -71,12 +71,12 @@ public void testDoCheckGetWatchDoesNotExist() throws IOException { if (randomBoolean()) { // it does not exist because it's literally not there - assertCheckDoesNotExist(resource, "/watcher/watch", watchId); + assertCheckDoesNotExist(resource, "/_watcher/watch", watchId); } else { // it does not exist because we need to replace it final HttpEntity entity = entityForClusterAlert(false, minimumVersion); - doCheckWithStatusCode(resource, "/watcher/watch", watchId, successfulCheckStatus(), false, entity); + doCheckWithStatusCode(resource, "/_watcher/watch", watchId, successfulCheckStatus(), false, entity); } } @@ -85,12 +85,12 @@ public void testDoCheckWithExceptionGetWatchError() throws IOException { if (randomBoolean()) { // error because of a server error - assertCheckWithException(resource, "/watcher/watch", watchId); + assertCheckWithException(resource, "/_watcher/watch", watchId); } else { // error because of a malformed response final HttpEntity entity = entityForClusterAlert(null, minimumVersion); - doCheckWithStatusCode(resource, "/watcher/watch", watchId, successfulCheckStatus(), null, entity); + doCheckWithStatusCode(resource, "/_watcher/watch", watchId, successfulCheckStatus(), null, entity); } } @@ -101,7 +101,7 @@ public void testDoCheckAsDeleteWatchExistsWhenNoWatchIsSpecified() throws IOExce // should not matter when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(clusterAlertsAllowed); - assertCheckAsDeleteExists(noWatchResource, "/watcher/watch", watchId); + assertCheckAsDeleteExists(noWatchResource, "/_watcher/watch", watchId); } public void testDoCheckWithExceptionAsDeleteWatchErrorWhenNoWatchIsSpecified() throws IOException { @@ -111,27 +111,27 @@ public void testDoCheckWithExceptionAsDeleteWatchErrorWhenNoWatchIsSpecified() t // should not matter when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(clusterAlertsAllowed); - assertCheckAsDeleteWithException(noWatchResource, "/watcher/watch", watchId); + assertCheckAsDeleteWithException(noWatchResource, "/_watcher/watch", watchId); } public void testDoCheckAsDeleteWatchExists() throws IOException { when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(false); - assertCheckAsDeleteExists(resource, "/watcher/watch", watchId); + assertCheckAsDeleteExists(resource, "/_watcher/watch", watchId); } public void testDoCheckWithExceptionAsDeleteWatchError() throws IOException { when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(false); - assertCheckAsDeleteWithException(resource, "/watcher/watch", watchId); + assertCheckAsDeleteWithException(resource, "/_watcher/watch", watchId); } public void testDoPublishTrue() throws IOException { - assertPublishSucceeds(resource, "/watcher/watch", watchId, StringEntity.class); + assertPublishSucceeds(resource, "/_watcher/watch", watchId, StringEntity.class); } public void testDoPublishFalseWithException() throws IOException { - assertPublishWithException(resource, "/watcher/watch", watchId, StringEntity.class); + assertPublishWithException(resource, "/_watcher/watch", watchId, StringEntity.class); } public void testShouldReplaceClusterAlertRethrowsIOException() throws IOException { diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java index 2012f44896f4a..1f9ab90e86542 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterIT.java @@ -497,7 +497,7 @@ private void assertMonitorWatches(final MockWebServer webServer, // GET / PUT if we are allowed to use it if (currentLicenseAllowsWatcher && clusterAlertBlacklist.contains(watch.v1()) == false) { assertThat(request.getMethod(), equalTo("GET")); - assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/watcher/watch/" + uniqueWatchId)); + assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/_watcher/watch/" + uniqueWatchId)); assertThat(request.getUri().getQuery(), equalTo(resourceClusterAlertQueryString())); assertHeaders(request, customHeaders); @@ -505,7 +505,7 @@ private void assertMonitorWatches(final MockWebServer webServer, request = webServer.takeRequest(); assertThat(request.getMethod(), equalTo("PUT")); - assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/watcher/watch/" + uniqueWatchId)); + assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/_watcher/watch/" + uniqueWatchId)); assertThat(request.getUri().getQuery(), equalTo(resourceClusterAlertQueryString())); assertThat(request.getBody(), equalTo(watch.v2())); assertHeaders(request, customHeaders); @@ -513,7 +513,7 @@ private void assertMonitorWatches(final MockWebServer webServer, // DELETE if we're not allowed to use it } else { assertThat(request.getMethod(), equalTo("DELETE")); - assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/watcher/watch/" + uniqueWatchId)); + assertThat(request.getUri().getPath(), equalTo(pathPrefix + "/_watcher/watch/" + uniqueWatchId)); assertThat(request.getUri().getQuery(), equalTo(resourceClusterAlertQueryString())); assertHeaders(request, customHeaders); } diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java index da95c778d0bec..e6f896a2aa050 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterResourceTests.java @@ -376,7 +376,7 @@ public void testWatchCheckBlocksAfterSuccessfulWatcherCheck() { final List otherResponses = getWatcherResponses(1, successful, unsuccessful); // last check fails implies that N - 2 publishes succeeded! - whenPerformRequestAsyncWith(client, new RequestMatcher(is("GET"), startsWith("/watcher/watch/")), + whenPerformRequestAsyncWith(client, new RequestMatcher(is("GET"), startsWith("/_watcher/watch/")), first, otherResponses, exception); whenSuccessfulPutWatches(otherResponses.size() + 1); @@ -391,7 +391,7 @@ public void testWatchCheckBlocksAfterSuccessfulWatcherCheck() { // there is no form of an unsuccessful delete; only success or error final List responses = successfulDeleteResponses(successful); - whenPerformRequestAsyncWith(client, new RequestMatcher(is("DELETE"), startsWith("/watcher/watch/")), + whenPerformRequestAsyncWith(client, new RequestMatcher(is("DELETE"), startsWith("/_watcher/watch/")), responses.get(0), responses.subList(1, responses.size()), exception); expectedGets += successful; @@ -399,7 +399,7 @@ public void testWatchCheckBlocksAfterSuccessfulWatcherCheck() { } else { final String method = validLicense ? "GET" : "DELETE"; - whenPerformRequestAsyncWith(client, new RequestMatcher(is(method), startsWith("/watcher/watch/")), exception); + whenPerformRequestAsyncWith(client, new RequestMatcher(is(method), startsWith("/_watcher/watch/")), exception); } assertTrue(resources.isDirty()); @@ -454,7 +454,7 @@ public void testWatchPublishBlocksAfterSuccessfulWatcherCheck() { whenGetWatches(successful, unsuccessful + 2); // previous publishes must have succeeded - whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/watcher/watch/")), + whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/_watcher/watch/")), firstSuccess, otherResponses, exception); // GETs required for each PUT attempt (first is guaranteed "unsuccessful") @@ -465,7 +465,7 @@ public void testWatchPublishBlocksAfterSuccessfulWatcherCheck() { // fail the check so that it has to attempt the PUT whenGetWatches(0, 1); - whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/watcher/watch/")), exception); + whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/_watcher/watch/")), exception); } assertTrue(resources.isDirty()); @@ -595,13 +595,13 @@ private Response unsuccessfulGetResponse() { private Response successfulGetWatchResponse(final String watchId) { final HttpEntity goodEntity = entityForClusterAlert(true, ClusterAlertsUtil.LAST_UPDATED_VERSION); - return response("GET", "/watcher/watch/" + watchId, successfulCheckStatus(), goodEntity); + return response("GET", "/_watcher/watch/" + watchId, successfulCheckStatus(), goodEntity); } private Response unsuccessfulGetWatchResponse(final String watchId) { if (randomBoolean()) { final HttpEntity badEntity = entityForClusterAlert(false, ClusterAlertsUtil.LAST_UPDATED_VERSION); - return response("GET", "/watcher/watch/" + watchId, successfulCheckStatus(), badEntity); + return response("GET", "/_watcher/watch/" + watchId, successfulCheckStatus(), badEntity); } return unsuccessfulGetResponse(); @@ -764,21 +764,21 @@ private void whenWatcherCannotBeUsed() { private void whenGetWatches(final int successful, final int unsuccessful) { final List gets = getWatcherResponses(0, successful, unsuccessful); - whenPerformRequestAsyncWith(client, new RequestMatcher(is("GET"), startsWith("/watcher/watch/")), gets); + whenPerformRequestAsyncWith(client, new RequestMatcher(is("GET"), startsWith("/_watcher/watch/")), gets); } private void whenSuccessfulPutWatches(final int successful) { final List successfulPuts = successfulPutResponses(successful); // empty is possible if they all exist - whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/watcher/watch/")), successfulPuts); + whenPerformRequestAsyncWith(client, new RequestMatcher(is("PUT"), startsWith("/_watcher/watch/")), successfulPuts); } private void whenSuccessfulDeleteWatches(final int successful) { final List successfulDeletes = successfulDeleteResponses(successful); // empty is possible if they all exist - whenPerformRequestAsyncWith(client, new RequestMatcher(is("DELETE"), startsWith("/watcher/watch/")), successfulDeletes); + whenPerformRequestAsyncWith(client, new RequestMatcher(is("DELETE"), startsWith("/_watcher/watch/")), successfulDeletes); } private void verifyVersionCheck() { @@ -811,18 +811,18 @@ private void verifyWatcherCheck() { private void verifyDeleteWatches(final int called) { verify(client, times(called)) - .performRequestAsync(argThat(new RequestMatcher(is("DELETE"), startsWith("/watcher/watch/"))), + .performRequestAsync(argThat(new RequestMatcher(is("DELETE"), startsWith("/_watcher/watch/"))), any(ResponseListener.class)); } private void verifyGetWatches(final int called) { verify(client, times(called)) - .performRequestAsync(argThat(new RequestMatcher(is("GET"), startsWith("/watcher/watch/"))), any(ResponseListener.class)); + .performRequestAsync(argThat(new RequestMatcher(is("GET"), startsWith("/_watcher/watch/"))), any(ResponseListener.class)); } private void verifyPutWatches(final int called) { verify(client, times(called)) - .performRequestAsync(argThat(new RequestMatcher(is("PUT"), startsWith("/watcher/watch/"))), any(ResponseListener.class)); + .performRequestAsync(argThat(new RequestMatcher(is("PUT"), startsWith("/_watcher/watch/"))), any(ResponseListener.class)); } private ClusterService mockClusterService(final ClusterState state) { diff --git a/x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java b/x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java index 9d94b277f1e81..d495fc778380e 100644 --- a/x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java +++ b/x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java @@ -145,7 +145,7 @@ private void waitForWatcher() throws Exception { List> hits = objectPathResponse.evaluate("hits.hits"); for (Map hit : hits) { String id = (String) hit.get("_id"); - adminClient().performRequest(new Request("DELETE", "watcher/watch/" + id)); + adminClient().performRequest(new Request("DELETE", "_watcher/watch/" + id)); } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.ack_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.ack_watch.json index 8c5465ff933a7..5f1ed7f860f97 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.ack_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.ack_watch.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html", "methods": [ "PUT", "POST" ], "url": { - "path": "/watcher/watch/{watch_id}/_ack", - "paths": [ "/watcher/watch/{watch_id}/_ack", "/watcher/watch/{watch_id}/_ack/{action_id}"], + "path": "/_watcher/watch/{watch_id}/_ack", + "paths": [ "/_watcher/watch/{watch_id}/_ack", "/_watcher/watch/{watch_id}/_ack/{action_id}"], "parts": { "watch_id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.activate_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.activate_watch.json index 7c370408e74ed..12c38ce1bebf8 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.activate_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.activate_watch.json @@ -3,8 +3,8 @@ "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html", "methods": [ "PUT", "POST" ], "url": { - "path": "/watcher/watch/{watch_id}/_activate", - "paths": [ "/watcher/watch/{watch_id}/_activate" ], + "path": "/_watcher/watch/{watch_id}/_activate", + "paths": [ "/_watcher/watch/{watch_id}/_activate" ], "parts": { "watch_id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.deactivate_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.deactivate_watch.json index 14f920fcf1316..d9cb9d653bc01 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.deactivate_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.deactivate_watch.json @@ -3,8 +3,8 @@ "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html", "methods": [ "PUT", "POST" ], "url": { - "path": "/watcher/watch/{watch_id}/_deactivate", - "paths": [ "/watcher/watch/{watch_id}/_deactivate" ], + "path": "/_watcher/watch/{watch_id}/_deactivate", + "paths": [ "/_watcher/watch/{watch_id}/_deactivate" ], "parts": { "watch_id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.delete_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.delete_watch.json index 5326c4bf34e40..a243315c91a62 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.delete_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.delete_watch.json @@ -4,8 +4,8 @@ "methods": [ "DELETE" ], "url": { - "path": "/watcher/watch/{id}", - "paths": [ "/watcher/watch/{id}" ], + "path": "/_watcher/watch/{id}", + "paths": [ "/_watcher/watch/{id}" ], "parts": { "id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.execute_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.execute_watch.json index 19736b46abbb6..0456eef5f49ab 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.execute_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.execute_watch.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html", "methods": [ "PUT", "POST" ], "url": { - "path": "/watcher/watch/{id}/_execute", - "paths": [ "/watcher/watch/{id}/_execute", "/watcher/watch/_execute" ], + "path": "/_watcher/watch/{id}/_execute", + "paths": [ "/_watcher/watch/{id}/_execute", "/_watcher/watch/_execute" ], "parts": { "id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.get_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.get_watch.json index c424f9944d68b..b0587301ec425 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.get_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.get_watch.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html", "methods": [ "GET" ], "url": { - "path": "/watcher/watch/{id}", - "paths": [ "/watcher/watch/{id}" ], + "path": "/_watcher/watch/{id}", + "paths": [ "/_watcher/watch/{id}" ], "parts": { "id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.put_watch.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.put_watch.json index 5463f959e68c1..aabbc8aef7f4c 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.put_watch.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.put_watch.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html", "methods": [ "PUT", "POST" ], "url": { - "path": "/watcher/watch/{id}", - "paths": [ "/watcher/watch/{id}" ], + "path": "/_watcher/watch/{id}", + "paths": [ "/_watcher/watch/{id}" ], "parts": { "id": { "type" : "string", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.start.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.start.json index 6a0a2b82e711e..eceb2a8628517 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.start.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.start.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html", "methods": [ "POST" ], "url": { - "path": "/watcher/_start", - "paths": [ "/watcher/_start" ], + "path": "/_watcher/_start", + "paths": [ "/_watcher/_start" ], "parts": { }, "params": { diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stats.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stats.json index 801a969006ae1..13857f1791019 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stats.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stats.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html", "methods": [ "GET" ], "url": { - "path": "/watcher/stats", - "paths": [ "/watcher/stats", "/watcher/stats/{metric}" ], + "path": "/_watcher/stats", + "paths": [ "/_watcher/stats", "/_watcher/stats/{metric}" ], "parts": { "metric": { "type" : "enum", diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stop.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stop.json index a2ae6a89d3f9f..1a14947b4fb11 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stop.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.watcher.stop.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html", "methods": [ "POST" ], "url": { - "path": "/watcher/_stop", - "paths": [ "/watcher/_stop" ], + "path": "/_watcher/_stop", + "paths": [ "/_watcher/_stop" ], "parts": { }, "params": { diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java index f9d2e8c53bc49..5a3f6dbd804a1 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java @@ -15,7 +15,7 @@ public abstract class WatcherRestHandler extends BaseRestHandler { - protected static String URI_BASE = "watcher"; + protected static String URI_BASE = "_watcher"; public WatcherRestHandler(Settings settings) { super(settings); diff --git a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index 079fb047cceaf..842f258af43a9 100644 --- a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -152,17 +152,17 @@ public void testSecurityNativeRealm() throws Exception { public void testWatcher() throws Exception { if (isRunningAgainstOldCluster()) { logger.info("Adding a watch on old cluster {}", getOldClusterVersion()); - Request createBwcWatch = new Request("PUT", "watcher/watch/bwc_watch"); + Request createBwcWatch = new Request("PUT", "_watcher/watch/bwc_watch"); createBwcWatch.setJsonEntity(loadWatch("simple-watch.json")); client().performRequest(createBwcWatch); logger.info("Adding a watch with \"fun\" throttle periods on old cluster"); - Request createBwcThrottlePeriod = new Request("PUT", "watcher/watch/bwc_throttle_period"); + Request createBwcThrottlePeriod = new Request("PUT", "_watcher/watch/bwc_throttle_period"); createBwcThrottlePeriod.setJsonEntity(loadWatch("throttle-period-watch.json")); client().performRequest(createBwcThrottlePeriod); logger.info("Adding a watch with \"fun\" read timeout on old cluster"); - Request createFunnyTimeout = new Request("PUT", "watcher/watch/bwc_funny_timeout"); + Request createFunnyTimeout = new Request("PUT", "_watcher/watch/bwc_funny_timeout"); createFunnyTimeout.setJsonEntity(loadWatch("funny-timeout-watch.json")); client().performRequest(createFunnyTimeout); @@ -206,10 +206,10 @@ public void testWatcher() throws Exception { } // Wait for watcher to actually start.... - Map startWatchResponse = entityAsMap(client().performRequest(new Request("POST", "watcher/_start"))); + Map startWatchResponse = entityAsMap(client().performRequest(new Request("POST", "_watcher/_start"))); assertThat(startWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE)); assertBusy(() -> { - Map statsWatchResponse = entityAsMap(client().performRequest(new Request("GET", "watcher/stats"))); + Map statsWatchResponse = entityAsMap(client().performRequest(new Request("GET", "_watcher/stats"))); @SuppressWarnings("unchecked") List states = ((List) statsWatchResponse.get("stats")) .stream().map(o -> ((Map) o).get("watcher_state")).collect(Collectors.toList()); @@ -224,11 +224,11 @@ public void testWatcher() throws Exception { /* Shut down watcher after every test because watcher can be a bit finicky about shutting down when the node shuts * down. This makes super sure it shuts down *and* causes the test to fail in a sensible spot if it doesn't shut down. */ - Map stopWatchResponse = entityAsMap(client().performRequest(new Request("POST", "watcher/_stop"))); + Map stopWatchResponse = entityAsMap(client().performRequest(new Request("POST", "_watcher/_stop"))); assertThat(stopWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE)); assertBusy(() -> { Map statsStoppedWatchResponse = entityAsMap(client().performRequest( - new Request("GET", "watcher/stats"))); + new Request("GET", "_watcher/stats"))); @SuppressWarnings("unchecked") List states = ((List) statsStoppedWatchResponse.get("stats")) .stream().map(o -> ((Map) o).get("watcher_state")).collect(Collectors.toList()); @@ -261,7 +261,7 @@ public void testRollupAfterRestart() throws Exception { client().performRequest(bulkRequest); // create the rollup job - final Request createRollupJobRequest = new Request("PUT", "/rollup/job/rollup-job-test"); + final Request createRollupJobRequest = new Request("PUT", "/_xpack/rollup/job/rollup-job-test"); createRollupJobRequest.setJsonEntity("{" + "\"index_pattern\":\"rollup-*\"," + "\"rollup_index\":\"results-rollup\"," @@ -282,7 +282,7 @@ public void testRollupAfterRestart() throws Exception { assertThat(createRollupJobResponse.get("acknowledged"), equalTo(Boolean.TRUE)); // start the rollup job - final Request startRollupJobRequest = new Request("POST", "rollup/job/rollup-job-test/_start"); + final Request startRollupJobRequest = new Request("POST", "_xpack/rollup/job/rollup-job-test/_start"); Map startRollupJobResponse = entityAsMap(client().performRequest(startRollupJobRequest)); assertThat(startRollupJobResponse.get("started"), equalTo(Boolean.TRUE)); @@ -313,7 +313,7 @@ public void testRollupIDSchemeAfterRestart() throws Exception { client().performRequest(indexRequest); // create the rollup job - final Request createRollupJobRequest = new Request("PUT", "/rollup/job/rollup-id-test"); + final Request createRollupJobRequest = new Request("PUT", "/_xpack/rollup/job/rollup-id-test"); createRollupJobRequest.setJsonEntity("{" + "\"index_pattern\":\"id-test-rollup\"," + "\"rollup_index\":\"id-test-results-rollup\"," @@ -341,7 +341,7 @@ public void testRollupIDSchemeAfterRestart() throws Exception { assertThat(createRollupJobResponse.get("acknowledged"), equalTo(Boolean.TRUE)); // start the rollup job - final Request startRollupJobRequest = new Request("POST", "rollup/job/rollup-id-test/_start"); + final Request startRollupJobRequest = new Request("POST", "_xpack/rollup/job/rollup-id-test/_start"); Map startRollupJobResponse = entityAsMap(client().performRequest(startRollupJobRequest)); assertThat(startRollupJobResponse.get("started"), equalTo(Boolean.TRUE)); @@ -373,14 +373,14 @@ public void testRollupIDSchemeAfterRestart() throws Exception { assertRollUpJob("rollup-id-test"); // stop the rollup job to force a state save, which will upgrade the ID - final Request stopRollupJobRequest = new Request("POST", "rollup/job/rollup-id-test/_stop"); + final Request stopRollupJobRequest = new Request("POST", "_xpack/rollup/job/rollup-id-test/_stop"); Map stopRollupJobResponse = entityAsMap(client().performRequest(stopRollupJobRequest)); assertThat(stopRollupJobResponse.get("stopped"), equalTo(Boolean.TRUE)); waitForRollUpJob("rollup-id-test", equalTo("stopped")); // start the rollup job again - final Request startRollupJobRequest = new Request("POST", "rollup/job/rollup-id-test/_start"); + final Request startRollupJobRequest = new Request("POST", "_xpack/rollup/job/rollup-id-test/_start"); Map startRollupJobResponse = entityAsMap(client().performRequest(startRollupJobRequest)); assertThat(startRollupJobResponse.get("started"), equalTo(Boolean.TRUE)); @@ -430,7 +430,7 @@ public void testSqlFailsOnIndexWithTwoTypes() throws IOException { } final Request sqlRequest; if (isRunningAgainstOldCluster()) { - sqlRequest = new Request("POST", "/sql"); + sqlRequest = new Request("POST", "/_xpack/sql"); } else { sqlRequest = new Request("POST", "/_sql"); } @@ -454,7 +454,7 @@ private void assertOldTemplatesAreDeleted() throws IOException { @SuppressWarnings("unchecked") private void assertWatchIndexContentsWork() throws Exception { // Fetch a basic watch - Map bwcWatch = entityAsMap(client().performRequest(new Request("GET", "watcher/watch/bwc_watch"))); + Map bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_watcher/watch/bwc_watch"))); logger.error("-----> {}", bwcWatch); @@ -469,7 +469,7 @@ private void assertWatchIndexContentsWork() throws Exception { assertThat(ObjectPath.eval("actions.index_payload.index.timeout_in_millis", source), equalTo(timeout)); // Fetch a watch with "fun" throttle periods - bwcWatch = entityAsMap(client().performRequest(new Request("GET", "watcher/watch/bwc_throttle_period"))); + bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_watcher/watch/bwc_throttle_period"))); assertThat(bwcWatch.get("found"), equalTo(true)); source = (Map) bwcWatch.get("watch"); assertEquals(timeout, source.get("throttle_period_in_millis")); @@ -479,7 +479,7 @@ private void assertWatchIndexContentsWork() throws Exception { * Fetch a watch with a funny timeout to verify loading fractional time * values. */ - bwcWatch = entityAsMap(client().performRequest(new Request("GET", "watcher/watch/bwc_funny_timeout"))); + bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_watcher/watch/bwc_funny_timeout"))); assertThat(bwcWatch.get("found"), equalTo(true)); source = (Map) bwcWatch.get("watch"); @@ -508,7 +508,7 @@ private void assertBasicWatchInteractions() throws Exception { .condition(InternalAlwaysCondition.INSTANCE) .trigger(ScheduleTrigger.builder(new IntervalSchedule(IntervalSchedule.Interval.seconds(1)))) .addAction("awesome", LoggingAction.builder(new TextTemplate("test"))).buildAsBytes(XContentType.JSON).utf8ToString(); - Request createWatchRequest = new Request("PUT", "watcher/watch/new_watch"); + Request createWatchRequest = new Request("PUT", "_watcher/watch/new_watch"); createWatchRequest.setJsonEntity(watch); Map createWatch = entityAsMap(client().performRequest(createWatchRequest)); @@ -521,7 +521,7 @@ private void assertBasicWatchInteractions() throws Exception { assertThat(updateWatch.get("created"), equalTo(false)); assertThat(updateWatch.get("_version"), equalTo(2)); - Map get = entityAsMap(client().performRequest(new Request("GET", "watcher/watch/new_watch"))); + Map get = entityAsMap(client().performRequest(new Request("GET", "_watcher/watch/new_watch"))); assertThat(get.get("found"), equalTo(true)); @SuppressWarnings("unchecked") Map source = (Map) get.get("watch"); Map logging = ObjectPath.eval("actions.awesome.logging", source); @@ -568,7 +568,7 @@ static String toStr(Response response) throws IOException { } private void createUser(final String id) throws Exception { - Request request = new Request("PUT", "/security/user/" + id); + Request request = new Request("PUT", "/_xpack/security/user/" + id); request.setJsonEntity( "{\n" + " \"password\" : \"j@rV1s\",\n" + @@ -581,7 +581,7 @@ private void createUser(final String id) throws Exception { } private void createRole(final String id) throws Exception { - Request request = new Request("PUT", "/security/role/" + id); + Request request = new Request("PUT", "/_xpack/security/role/" + id); request.setJsonEntity( "{\n" + " \"run_as\": [ \"abc\" ],\n" + @@ -601,7 +601,7 @@ private void createRole(final String id) throws Exception { } private void assertUserInfo(final String user) throws Exception { - Map response = entityAsMap(client().performRequest(new Request("GET", "/security/user/" + user))); + Map response = entityAsMap(client().performRequest(new Request("GET", "/_xpack/security/user/" + user))); @SuppressWarnings("unchecked") Map userInfo = (Map) response.get(user); assertEquals(user + "@example.com", userInfo.get("email")); assertNotNull(userInfo.get("full_name")); @@ -610,7 +610,7 @@ private void assertUserInfo(final String user) throws Exception { private void assertRoleInfo(final String role) throws Exception { @SuppressWarnings("unchecked") Map response = (Map) - entityAsMap(client().performRequest(new Request("GET", "/security/role/" + role))).get(role); + entityAsMap(client().performRequest(new Request("GET", "/_xpack/security/role/" + role))).get(role); assertNotNull(response.get("run_as")); assertNotNull(response.get("cluster")); assertNotNull(response.get("indices")); @@ -622,7 +622,7 @@ private void assertRollUpJob(final String rollupJob) throws Exception { waitForRollUpJob(rollupJob, expectedStates); // check that the rollup job is started using the RollUp API - final Request getRollupJobRequest = new Request("GET", "rollup/job/" + rollupJob); + final Request getRollupJobRequest = new Request("GET", "_xpack/rollup/job/" + rollupJob); Map getRollupJobResponse = entityAsMap(client().performRequest(getRollupJobRequest)); Map job = getJob(getRollupJobResponse, rollupJob); if (job != null) { @@ -668,7 +668,7 @@ private void assertRollUpJob(final String rollupJob) throws Exception { private void waitForRollUpJob(final String rollupJob, final Matcher expectedStates) throws Exception { assertBusy(() -> { - final Request getRollupJobRequest = new Request("GET", "rollup/job/" + rollupJob); + final Request getRollupJobRequest = new Request("GET", "_xpack/rollup/job/" + rollupJob); Response getRollupJobResponse = client().performRequest(getRollupJobRequest); assertThat(getRollupJobResponse.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus())); diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java index f36dcc9111a31..755991a6e010d 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatcherRestartIT.java @@ -17,16 +17,16 @@ public class WatcherRestartIT extends AbstractUpgradeTestCase { public void testWatcherRestart() throws Exception { - client().performRequest(new Request("POST", "/watcher/_stop")); + client().performRequest(new Request("POST", "/_watcher/_stop")); ensureWatcherStopped(); - client().performRequest(new Request("POST", "/watcher/_start")); + client().performRequest(new Request("POST", "/_watcher/_start")); ensureWatcherStarted(); } private void ensureWatcherStopped() throws Exception { assertBusy(() -> { - Response stats = client().performRequest(new Request("GET", "watcher/stats")); + Response stats = client().performRequest(new Request("GET", "_watcher/stats")); String responseBody = EntityUtils.toString(stats.getEntity(), StandardCharsets.UTF_8); assertThat(responseBody, containsString("\"watcher_state\":\"stopped\"")); assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\""))); @@ -37,7 +37,7 @@ private void ensureWatcherStopped() throws Exception { private void ensureWatcherStarted() throws Exception { assertBusy(() -> { - Response response = client().performRequest(new Request("GET", "watcher/stats")); + Response response = client().performRequest(new Request("GET", "_watcher/stats")); String responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); assertThat(responseBody, containsString("\"watcher_state\":\"started\"")); assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\""))); diff --git a/x-pack/qa/smoke-test-monitoring-with-watcher/src/test/java/org/elasticsearch/smoketest/MonitoringWithWatcherRestIT.java b/x-pack/qa/smoke-test-monitoring-with-watcher/src/test/java/org/elasticsearch/smoketest/MonitoringWithWatcherRestIT.java index 24d1ed59d1a5a..66b52afed1652 100644 --- a/x-pack/qa/smoke-test-monitoring-with-watcher/src/test/java/org/elasticsearch/smoketest/MonitoringWithWatcherRestIT.java +++ b/x-pack/qa/smoke-test-monitoring-with-watcher/src/test/java/org/elasticsearch/smoketest/MonitoringWithWatcherRestIT.java @@ -77,7 +77,7 @@ public void testThatHttpExporterAddsWatches() throws Exception { } private void assertMonitoringWatchHasBeenOverWritten(String watchId) throws Exception { - ObjectPath path = ObjectPath.createFromResponse(client().performRequest(new Request("GET", "/watcher/watch/" + watchId))); + ObjectPath path = ObjectPath.createFromResponse(client().performRequest(new Request("GET", "/_watcher/watch/" + watchId))); String interval = path.evaluate("watch.trigger.schedule.interval"); assertThat(interval, is("1m")); } @@ -94,7 +94,7 @@ private void assertTotalWatchCount(int expectedWatches) throws Exception { private String createMonitoringWatch() throws Exception { String clusterUUID = getClusterUUID(); String watchId = clusterUUID + "_kibana_version_mismatch"; - Request request = new Request("PUT", "/watcher/watch/" + watchId); + Request request = new Request("PUT", "/_watcher/watch/" + watchId); request.setJsonEntity(WatchSourceBuilders.watchBuilder() .trigger(TriggerBuilders.schedule(new IntervalSchedule(new IntervalSchedule.Interval(1000, MINUTES)))) .input(simpleInput()) diff --git a/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java b/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java index 1dc6452b16007..fd4685f9f6d1f 100644 --- a/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java +++ b/x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java @@ -56,13 +56,13 @@ public void startWatcher() throws Exception { assertBusy(() -> { try { - Response statsResponse = adminClient().performRequest(new Request("GET", "/watcher/stats")); + Response statsResponse = adminClient().performRequest(new Request("GET", "/_watcher/stats")); ObjectPath objectPath = ObjectPath.createFromResponse(statsResponse); String state = objectPath.evaluate("stats.0.watcher_state"); switch (state) { case "stopped": - Response startResponse = adminClient().performRequest(new Request("POST", "/watcher/_start")); + Response startResponse = adminClient().performRequest(new Request("POST", "/_watcher/_start")); Map responseMap = entityAsMap(startResponse); assertThat(responseMap, hasEntry("acknowledged", true)); throw new AssertionError("waiting until stopped state reached started state"); @@ -94,7 +94,7 @@ public void stopWatcher() throws Exception { assertBusy(() -> { try { - Response statsResponse = adminClient().performRequest(new Request("GET", "/watcher/stats")); + Response statsResponse = adminClient().performRequest(new Request("GET", "/_watcher/stats")); ObjectPath objectPath = ObjectPath.createFromResponse(statsResponse); String state = objectPath.evaluate("stats.0.watcher_state"); @@ -107,7 +107,7 @@ public void stopWatcher() throws Exception { case "starting": throw new AssertionError("waiting until starting state reached started state to stop"); case "started": - Response stopResponse = adminClient().performRequest(new Request("POST", "/watcher/_stop")); + Response stopResponse = adminClient().performRequest(new Request("POST", "/_watcher/_stop")); String body = EntityUtils.toString(stopResponse.getEntity()); assertThat(body, containsString("\"acknowledged\":true")); throw new AssertionError("waiting until started state reached stopped state"); @@ -290,7 +290,7 @@ public void testIndexActionInsufficientPrivileges() throws Exception { } private void indexWatch(String watchId, XContentBuilder builder) throws Exception { - Request request = new Request("PUT", "/watcher/watch/" + watchId); + Request request = new Request("PUT", "/_watcher/watch/" + watchId); request.setJsonEntity(Strings.toString(builder)); Response response = client().performRequest(request); Map responseMap = entityAsMap(response); diff --git a/x-pack/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherTestSuiteIT.java b/x-pack/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherTestSuiteIT.java index 57312cd3135ef..14b112434a489 100644 --- a/x-pack/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherTestSuiteIT.java +++ b/x-pack/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherTestSuiteIT.java @@ -40,12 +40,12 @@ public void startWatcher() throws Exception { assertOK(adminClient().performRequest(new Request("DELETE", "/.watcher-history-*"))); assertBusy(() -> { - Response response = adminClient().performRequest(new Request("GET", "/watcher/stats")); + Response response = adminClient().performRequest(new Request("GET", "/_watcher/stats")); String state = ObjectPath.createFromResponse(response).evaluate("stats.0.watcher_state"); switch (state) { case "stopped": - Response startResponse = adminClient().performRequest(new Request("POST", "/watcher/_start")); + Response startResponse = adminClient().performRequest(new Request("POST", "/_watcher/_start")); boolean isAcknowledged = ObjectPath.createFromResponse(startResponse).evaluate("acknowledged"); assertThat(isAcknowledged, is(true)); throw new AssertionError("waiting until stopped state reached started state"); @@ -72,7 +72,7 @@ public void startWatcher() throws Exception { @After public void stopWatcher() throws Exception { assertBusy(() -> { - Response response = adminClient().performRequest(new Request("GET", "/watcher/stats")); + Response response = adminClient().performRequest(new Request("GET", "/_watcher/stats")); String state = ObjectPath.createFromResponse(response).evaluate("stats.0.watcher_state"); switch (state) { @@ -84,7 +84,7 @@ public void stopWatcher() throws Exception { case "starting": throw new AssertionError("waiting until starting state reached started state to stop"); case "started": - Response stopResponse = adminClient().performRequest(new Request("POST", "/watcher/_stop")); + Response stopResponse = adminClient().performRequest(new Request("POST", "/_watcher/_stop")); boolean isAcknowledged = ObjectPath.createFromResponse(stopResponse).evaluate("acknowledged"); assertThat(isAcknowledged, is(true)); throw new AssertionError("waiting until started state reached stopped state"); @@ -162,7 +162,7 @@ public void testMonitorClusterHealth() throws Exception { } private void indexWatch(String watchId, XContentBuilder builder) throws Exception { - Request request = new Request("PUT", "/watcher/watch/" + watchId); + Request request = new Request("PUT", "/_watcher/watch/" + watchId); request.setJsonEntity(Strings.toString(builder)); Response response = client().performRequest(request); Map responseMap = entityAsMap(response); @@ -170,7 +170,7 @@ private void indexWatch(String watchId, XContentBuilder builder) throws Exceptio } private void deleteWatch(String watchId) throws IOException { - Response response = client().performRequest(new Request("DELETE", "/watcher/watch/" + watchId)); + Response response = client().performRequest(new Request("DELETE", "/_watcher/watch/" + watchId)); assertOK(response); ObjectPath path = ObjectPath.createFromResponse(response); boolean found = path.evaluate("found"); @@ -207,7 +207,7 @@ private ObjectPath getWatchHistoryEntry(String watchId) throws Exception { } private void assertWatchCount(int expectedWatches) throws IOException { - Response watcherStatsResponse = adminClient().performRequest(new Request("GET", "/watcher/stats")); + Response watcherStatsResponse = adminClient().performRequest(new Request("GET", "/_watcher/stats")); ObjectPath objectPath = ObjectPath.createFromResponse(watcherStatsResponse); int watchCount = objectPath.evaluate("stats.0.watch_count"); assertThat(watchCount, is(expectedWatches)); From ab4d0fcaa62d9d6f563db798ff68ced0bee73961 Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Tue, 4 Dec 2018 13:41:47 -0600 Subject: [PATCH 4/7] Actually deprecate the things --- .../watcher/rest/WatcherRestHandler.java | 2 +- .../rest/action/RestAckWatchAction.java | 24 ++++++++++++---- .../rest/action/RestActivateWatchAction.java | 28 +++++++++++++++---- .../rest/action/RestDeleteWatchAction.java | 13 +++++++-- .../rest/action/RestExecuteWatchAction.java | 24 ++++++++++++---- .../rest/action/RestGetWatchAction.java | 13 +++++++-- .../rest/action/RestPutWatchAction.java | 16 +++++++++-- .../rest/action/RestWatchServiceAction.java | 18 +++++++++--- .../rest/action/RestWatcherStatsAction.java | 12 ++++++-- 9 files changed, 119 insertions(+), 31 deletions(-) diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java index 5a3f6dbd804a1..3588df514c377 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/WatcherRestHandler.java @@ -15,7 +15,7 @@ public abstract class WatcherRestHandler extends BaseRestHandler { - protected static String URI_BASE = "_watcher"; + protected static String URI_BASE = "/_xpack"; public WatcherRestHandler(Settings settings) { super(settings); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java index b75cb9cfb7ab4..23180631902b8 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java @@ -3,8 +3,11 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.xpack.watcher.rest.action; +import org.apache.logging.log4j.LogManager; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.BytesRestResponse; @@ -30,17 +33,28 @@ */ public class RestAckWatchAction extends WatcherRestHandler { + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestAckWatchAction.class)); + public RestAckWatchAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(POST, URI_BASE + "/watch/{id}/_ack", this); - controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_ack", this); - controller.registerHandler(POST, URI_BASE + "/watch/{id}/_ack/{actions}", this); - controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_ack/{actions}", this); + // TODO: remove deprecated endpoint in 8.0.0 + controller.registerWithDeprecatedHandler( + POST, "/_watcher/watch/{id}/_ack", this, + POST, URI_BASE + "/watcher/watch/{id}/_ack", deprecationLogger); + controller.registerWithDeprecatedHandler( + PUT, "/_watcher/watch/{id}/_ack", this, + PUT, URI_BASE + "/watcher/watch/{id}/_ack", deprecationLogger); + controller.registerWithDeprecatedHandler( + POST, "/_watcher/watch/{id}/_ack/{actions}", this, + POST, URI_BASE + "/watcher/watch/{id}/_ack/{actions}", deprecationLogger); + controller.registerWithDeprecatedHandler( + PUT, "/_watcher/watch/{id}/_ack/{actions}", this, + PUT, URI_BASE + "/watcher/watch/{id}/_ack/{actions}", deprecationLogger); } @Override public String getName() { - return "xpack_watcher_ack_watch_action"; + return "watcher_ack_watch"; } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java index 68fc1d6d4fc54..93ce7f1b322b0 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java @@ -3,8 +3,11 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.xpack.watcher.rest.action; +import org.apache.logging.log4j.LogManager; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.BytesRestResponse; @@ -29,18 +32,31 @@ * The rest action to de/activate a watch */ public class RestActivateWatchAction extends WatcherRestHandler { + + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestActivateWatchAction.class)); + public RestActivateWatchAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(POST, URI_BASE + "/watch/{id}/_activate", this); - controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_activate", this); + // TODO: remove deprecated endpoint in 8.0.0 + controller.registerWithDeprecatedHandler( + POST, "/_watcher/watch/{id}/_activate", this, + POST, URI_BASE + "/watcher/watch/{id}/_activate", deprecationLogger); + controller.registerWithDeprecatedHandler( + PUT, "/_watcher/watch/{id}/_activate", this, + PUT, URI_BASE + "/watcher/watch/{id}/_activate", deprecationLogger); + final DeactivateRestHandler deactivateRestHandler = new DeactivateRestHandler(settings); - controller.registerHandler(POST, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler); - controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler); + controller.registerWithDeprecatedHandler( + POST, "/_watcher/watch/{id}/_deactivate", deactivateRestHandler, + POST, URI_BASE + "/watcher/watch/{id}/_deactivate", deprecationLogger); + controller.registerWithDeprecatedHandler( + PUT, "/_watcher/watch/{id}/_deactivate", deactivateRestHandler, + PUT, URI_BASE + "/watcher/watch/{id}/_deactivate", deprecationLogger); } @Override public String getName() { - return "xpack_watcher_activate_watch_action"; + return "watcher_activate_watch"; } @Override @@ -65,7 +81,7 @@ private static class DeactivateRestHandler extends WatcherRestHandler { @Override public String getName() { - return "xpack_watcher_deactivate_watch_action"; + return "watcher_deactivate_watch"; } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java index 28eb884bbe872..0b0fbc478df36 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java @@ -3,8 +3,11 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.xpack.watcher.rest.action; +import org.apache.logging.log4j.LogManager; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.BytesRestResponse; @@ -25,14 +28,20 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestDeleteWatchAction extends WatcherRestHandler { + + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestDeleteWatchAction.class)); + public RestDeleteWatchAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(DELETE, URI_BASE + "/watch/{id}", this); + // TODO: remove deprecated endpoint in 8.0.0 + controller.registerWithDeprecatedHandler( + DELETE, "/_watcher/watch/{id}", this, + DELETE, URI_BASE + "/watcher/watch/{id}", deprecationLogger); } @Override public String getName() { - return "xpack_watcher_delete_watch_action"; + return "watcher_delete_watch"; } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java index 92927f0926ae4..4b79c72d417a5 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java @@ -3,11 +3,14 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.xpack.watcher.rest.action; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -41,6 +44,8 @@ public class RestExecuteWatchAction extends WatcherRestHandler implements RestRequestFilter { + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestExecuteWatchAction.class)); + private static final List RESERVED_FIELD_NAMES = Arrays.asList(WatchField.TRIGGER.getPreferredName(), WatchField.INPUT.getPreferredName(), WatchField.CONDITION.getPreferredName(), WatchField.ACTIONS.getPreferredName(), WatchField.TRANSFORM.getPreferredName(), @@ -50,15 +55,24 @@ public class RestExecuteWatchAction extends WatcherRestHandler implements RestRe public RestExecuteWatchAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(POST, URI_BASE + "/watch/{id}/_execute", this); - controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_execute", this); - controller.registerHandler(POST, URI_BASE + "/watch/_execute", this); - controller.registerHandler(PUT, URI_BASE + "/watch/_execute", this); + // TODO: remove deprecated endpoint in 8.0.0 + controller.registerWithDeprecatedHandler( + POST, "/_watcher/watch/{id}/_execute", this, + POST, URI_BASE + "/watcher/watch/{id}/_execute", deprecationLogger); + controller.registerWithDeprecatedHandler( + PUT, "/_watcher/watch/{id}/_execute", this, + PUT, URI_BASE + "/watcher/watch/{id}/_execute", deprecationLogger); + controller.registerWithDeprecatedHandler( + POST, "/_watcher/watch/_execute", this, + POST, URI_BASE + "/watcher/watch/_execute", deprecationLogger); + controller.registerWithDeprecatedHandler( + PUT, "/_watcher/watch/_execute", this, + PUT, URI_BASE + "/watcher/watch/_execute", deprecationLogger); } @Override public String getName() { - return "xpack_watcher_execute_watch_action"; + return "watcher_execute_watch"; } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java index e1f9200875487..1ed6b0d795e91 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java @@ -3,8 +3,11 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.xpack.watcher.rest.action; +import org.apache.logging.log4j.LogManager; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -25,14 +28,20 @@ import static org.elasticsearch.rest.RestStatus.OK; public class RestGetWatchAction extends WatcherRestHandler { + + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestGetWatchAction.class)); + public RestGetWatchAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(GET, URI_BASE + "/watch/{id}", this); + // TODO: remove deprecated endpoint in 8.0.0 + controller.registerWithDeprecatedHandler( + GET, "/_watcher/watch/{id}", this, + GET, URI_BASE + "/watcher/watch/{id}", deprecationLogger); } @Override public String getName() { - return "xpack_watcher_get_watch_action"; + return "watcher_get_watch"; } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java index 6fe93aec3a4a2..31a5162499641 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java @@ -3,8 +3,11 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.xpack.watcher.rest.action; +import org.apache.logging.log4j.LogManager; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; @@ -32,15 +35,22 @@ public class RestPutWatchAction extends WatcherRestHandler implements RestRequestFilter { + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestPutWatchAction.class)); + public RestPutWatchAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(POST, URI_BASE + "/watch/{id}", this); - controller.registerHandler(PUT, URI_BASE + "/watch/{id}", this); + // TODO: remove deprecated endpoint in 8.0.0 + controller.registerWithDeprecatedHandler( + POST, "/_watcher/watch/{id}", this, + POST, URI_BASE + "/watcher/watch/{id}", deprecationLogger); + controller.registerWithDeprecatedHandler( + PUT, "/_watcher/watch/{id}", this, + PUT, URI_BASE + "/watcher/watch/{id}", deprecationLogger); } @Override public String getName() { - return "xpack_watcher_put_watch_action"; + return "watcher_put_watch"; } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java index 745384916ba89..d2ec2bd423e54 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java @@ -3,8 +3,11 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.xpack.watcher.rest.action; +import org.apache.logging.log4j.LogManager; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestRequest; @@ -17,15 +20,22 @@ public class RestWatchServiceAction extends WatcherRestHandler { + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestWatchServiceAction.class)); + public RestWatchServiceAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(POST, URI_BASE + "/_start", this); - controller.registerHandler(POST, URI_BASE + "/_stop", new StopRestHandler(settings)); + // TODO: remove deprecated endpoint in 8.0.0 + controller.registerWithDeprecatedHandler( + POST, "/_watcher/_start", this, + POST, URI_BASE + "/watcher/_start", deprecationLogger); + controller.registerWithDeprecatedHandler( + POST, "/_watcher/_stop", new StopRestHandler(settings), + POST, URI_BASE + "/watcher/_stop", deprecationLogger); } @Override public String getName() { - return "xpack_watcher_start_service_action"; + return "watcher_start_service"; } @Override @@ -41,7 +51,7 @@ private static class StopRestHandler extends WatcherRestHandler { @Override public String getName() { - return "xpack_watcher_stop_service_action"; + return "watcher_stop_service"; } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java index fad5b9cf93fa3..6d2640d66da3d 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java @@ -3,6 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ + package org.elasticsearch.xpack.watcher.rest.action; import org.apache.logging.log4j.Logger; @@ -29,13 +30,18 @@ public class RestWatcherStatsAction extends WatcherRestHandler { public RestWatcherStatsAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(GET, URI_BASE + "/stats", this); - controller.registerHandler(GET, URI_BASE + "/stats/{metric}", this); + // TODO: remove deprecated endpoint in 8.0.0 + controller.registerWithDeprecatedHandler( + GET, "/_watcher/stats", this, + GET, URI_BASE + "/watcher/stats", deprecationLogger); + controller.registerWithDeprecatedHandler( + GET, "/_watcher/stats/{metric}", this, + GET, URI_BASE + "/watcher/stats/{metric}", deprecationLogger); } @Override public String getName() { - return "xpack_watcher_stats_action"; + return "watcher_stats"; } @Override From 2f1bf13499fbe86896a2d60a0e0903d75f532f90 Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Fri, 7 Dec 2018 23:06:17 -0600 Subject: [PATCH 5/7] Fix execute watch --- .../java/org/elasticsearch/client/WatcherRequestConverters.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java index e130df326d061..33051ae0e432a 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/WatcherRequestConverters.java @@ -111,7 +111,7 @@ static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) { static Request executeWatch(ExecuteWatchRequest executeWatchRequest) throws IOException { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack", "watcher", "watch") + .addPathPartAsIs("_watcher", "watch") .addPathPart(executeWatchRequest.getId()) // will ignore if ID is null .addPathPartAsIs("_execute").build(); From 1652d7483ded46e1e9f2da5a89522f2833038c40 Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Sat, 8 Dec 2018 07:55:24 -0600 Subject: [PATCH 6/7] fixing a test --- .../elasticsearch/client/WatcherRequestConvertersTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java index 5cfc4e753301c..a31206bee88cc 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/WatcherRequestConvertersTests.java @@ -218,7 +218,7 @@ public void testExecuteWatchByIdRequest() throws IOException { } Request req = WatcherRequestConverters.executeWatch(request); - assertThat(req.getEndpoint(), equalTo("/_xpack/watcher/watch/my_id/_execute")); + assertThat(req.getEndpoint(), equalTo("/_watcher/watch/my_id/_execute")); assertThat(req.getMethod(), equalTo(HttpPost.METHOD_NAME)); if (ignoreCondition) { @@ -293,7 +293,7 @@ public void testExecuteInlineWatchRequest() throws IOException { } Request req = WatcherRequestConverters.executeWatch(request); - assertThat(req.getEndpoint(), equalTo("/_xpack/watcher/watch/_execute")); + assertThat(req.getEndpoint(), equalTo("/_watcher/watch/_execute")); assertThat(req.getMethod(), equalTo(HttpPost.METHOD_NAME)); if (ignoreCondition) { From e4bda5759bc7cb2752780bfde0e4627208156afc Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Sat, 8 Dec 2018 11:04:13 -0600 Subject: [PATCH 7/7] Fix old version URLs --- .../elasticsearch/xpack/restart/FullClusterRestartIT.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index 150e335cb04e5..99f6a54d6bd18 100644 --- a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -154,17 +154,17 @@ public void testSecurityNativeRealm() throws Exception { public void testWatcher() throws Exception { if (isRunningAgainstOldCluster()) { logger.info("Adding a watch on old cluster {}", getOldClusterVersion()); - Request createBwcWatch = new Request("PUT", "_watcher/watch/bwc_watch"); + Request createBwcWatch = new Request("PUT", "/_xpack/watcher/watch/bwc_watch"); createBwcWatch.setJsonEntity(loadWatch("simple-watch.json")); client().performRequest(createBwcWatch); logger.info("Adding a watch with \"fun\" throttle periods on old cluster"); - Request createBwcThrottlePeriod = new Request("PUT", "_watcher/watch/bwc_throttle_period"); + Request createBwcThrottlePeriod = new Request("PUT", "_xpack/watcher/watch/bwc_throttle_period"); createBwcThrottlePeriod.setJsonEntity(loadWatch("throttle-period-watch.json")); client().performRequest(createBwcThrottlePeriod); logger.info("Adding a watch with \"fun\" read timeout on old cluster"); - Request createFunnyTimeout = new Request("PUT", "_watcher/watch/bwc_funny_timeout"); + Request createFunnyTimeout = new Request("PUT", "_xpack/watcher/watch/bwc_funny_timeout"); createFunnyTimeout.setJsonEntity(loadWatch("funny-timeout-watch.json")); client().performRequest(createFunnyTimeout);