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 3cc6826e837dc..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 @@ -46,8 +46,7 @@ private WatcherRequestConverters() {} static Request startWatchService(StartWatchServiceRequest startWatchServiceRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack") - .addPathPartAsIs("watcher") + .addPathPartAsIs("_watcher") .addPathPartAsIs("_start") .build(); @@ -56,8 +55,7 @@ static Request startWatchService(StartWatchServiceRequest startWatchServiceReque static Request stopWatchService(StopWatchServiceRequest stopWatchServiceRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack") - .addPathPartAsIs("watcher") + .addPathPartAsIs("_watcher") .addPathPartAsIs("_stop") .build(); @@ -66,7 +64,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(); @@ -84,7 +82,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(); @@ -93,8 +91,7 @@ static Request getWatch(GetWatchRequest getWatchRequest) { static Request deactivateWatch(DeactivateWatchRequest deactivateWatchRequest) { String endpoint = new RequestConverters.EndpointBuilder() - .addPathPartAsIs("_xpack") - .addPathPartAsIs("watcher") + .addPathPartAsIs("_watcher") .addPathPartAsIs("watch") .addPathPart(deactivateWatchRequest.getWatchId()) .addPathPartAsIs("_deactivate") @@ -104,7 +101,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(); @@ -114,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(); @@ -136,7 +133,7 @@ static Request executeWatch(ExecuteWatchRequest executeWatchRequest) throws IOEx 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()) @@ -147,7 +144,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(); @@ -156,7 +153,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 cb9da0af66995..23a38b47249e4 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 @@ -151,7 +151,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 3b7d533a18140..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 @@ -67,13 +67,13 @@ private static String toString(HttpEntity entity) throws IOException { 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 { @@ -95,7 +95,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(); @@ -109,7 +109,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()); } @@ -119,7 +119,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() { @@ -128,7 +128,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()); } @@ -142,7 +142,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); @@ -158,7 +158,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()); } @@ -169,7 +169,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")); @@ -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) { 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 c6c0cea0e31fa..762846cf63d15 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 @@ -407,7 +407,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..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 _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,9 +235,9 @@ 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/] +// 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 e853998415e96..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 _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..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 _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..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 _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..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 _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..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 _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..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 _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..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 _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..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 _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..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 _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 08b93c13b53d8..7e527530f4291 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..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 _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 e2757847a9287..077e27f00eddd 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 f65cc9d3c7765..74074d2ac3d0f 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 eed7f5e2fede9..8556f6b564bb9 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 55829f8d50757..80aeb69a38d5b 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/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..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, - "/_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..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, "/_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..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 + "/_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..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("/_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 df60cc43d7794..ab6289c410b55 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 @@ -147,7 +147,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..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": "/_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..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": "/_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..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": "/_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..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": "/_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..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": "/_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..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": "/_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..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": "/_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..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": "/_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..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": "/_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..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": "/_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..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 = "_xpack/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 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 ddc831e9f735e..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,7 +154,7 @@ 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", "/_xpack/watcher/watch/bwc_watch"); createBwcWatch.setJsonEntity(loadWatch("simple-watch.json")); client().performRequest(createBwcWatch); @@ -208,10 +208,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()); @@ -226,11 +226,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()); @@ -462,7 +462,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); @@ -477,7 +477,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")); @@ -487,7 +487,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"); @@ -519,7 +519,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)); @@ -532,7 +532,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); 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..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", "/_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..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", "/_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 66bcf82a50087..0a468cbf84930 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 @@ -57,13 +57,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"); @@ -95,7 +95,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"); @@ -108,7 +108,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"); @@ -291,7 +291,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 ecb03b5ddb3ea..162c6c07643cf 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 @@ -41,12 +41,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"); @@ -73,7 +73,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) { @@ -85,7 +85,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"); @@ -163,7 +163,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); @@ -171,7 +171,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"); @@ -209,7 +209,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));