Deprecate X-Pack centric watcher endpoints (#36218)
This commit is part of our plan to deprecate and ultimately remove the use of _xpack in the REST APIs. Relates #35958
This commit is contained in:
parent
9f86e996fe
commit
b5b6e37a60
|
@ -46,8 +46,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request startWatchService(StartWatchServiceRequest startWatchServiceRequest) {
|
static Request startWatchService(StartWatchServiceRequest startWatchServiceRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack")
|
.addPathPartAsIs("_watcher")
|
||||||
.addPathPartAsIs("watcher")
|
|
||||||
.addPathPartAsIs("_start")
|
.addPathPartAsIs("_start")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -56,8 +55,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request stopWatchService(StopWatchServiceRequest stopWatchServiceRequest) {
|
static Request stopWatchService(StopWatchServiceRequest stopWatchServiceRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack")
|
.addPathPartAsIs("_watcher")
|
||||||
.addPathPartAsIs("watcher")
|
|
||||||
.addPathPartAsIs("_stop")
|
.addPathPartAsIs("_stop")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -66,7 +64,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request putWatch(PutWatchRequest putWatchRequest) {
|
static Request putWatch(PutWatchRequest putWatchRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack", "watcher", "watch")
|
.addPathPartAsIs("_watcher", "watch")
|
||||||
.addPathPart(putWatchRequest.getId())
|
.addPathPart(putWatchRequest.getId())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -84,7 +82,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request getWatch(GetWatchRequest getWatchRequest) {
|
static Request getWatch(GetWatchRequest getWatchRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack", "watcher", "watch")
|
.addPathPartAsIs("_watcher", "watch")
|
||||||
.addPathPart(getWatchRequest.getId())
|
.addPathPart(getWatchRequest.getId())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -93,8 +91,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request deactivateWatch(DeactivateWatchRequest deactivateWatchRequest) {
|
static Request deactivateWatch(DeactivateWatchRequest deactivateWatchRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack")
|
.addPathPartAsIs("_watcher")
|
||||||
.addPathPartAsIs("watcher")
|
|
||||||
.addPathPartAsIs("watch")
|
.addPathPartAsIs("watch")
|
||||||
.addPathPart(deactivateWatchRequest.getWatchId())
|
.addPathPart(deactivateWatchRequest.getWatchId())
|
||||||
.addPathPartAsIs("_deactivate")
|
.addPathPartAsIs("_deactivate")
|
||||||
|
@ -104,7 +101,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) {
|
static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack", "watcher", "watch")
|
.addPathPartAsIs("_watcher", "watch")
|
||||||
.addPathPart(deleteWatchRequest.getId())
|
.addPathPart(deleteWatchRequest.getId())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -114,7 +111,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request executeWatch(ExecuteWatchRequest executeWatchRequest) throws IOException {
|
static Request executeWatch(ExecuteWatchRequest executeWatchRequest) throws IOException {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack", "watcher", "watch")
|
.addPathPartAsIs("_watcher", "watch")
|
||||||
.addPathPart(executeWatchRequest.getId()) // will ignore if ID is null
|
.addPathPart(executeWatchRequest.getId()) // will ignore if ID is null
|
||||||
.addPathPartAsIs("_execute").build();
|
.addPathPartAsIs("_execute").build();
|
||||||
|
|
||||||
|
@ -136,7 +133,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
public static Request ackWatch(AckWatchRequest ackWatchRequest) {
|
public static Request ackWatch(AckWatchRequest ackWatchRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack", "watcher", "watch")
|
.addPathPartAsIs("_watcher", "watch")
|
||||||
.addPathPart(ackWatchRequest.getWatchId())
|
.addPathPart(ackWatchRequest.getWatchId())
|
||||||
.addPathPartAsIs("_ack")
|
.addPathPartAsIs("_ack")
|
||||||
.addCommaSeparatedPathParts(ackWatchRequest.getActionIds())
|
.addCommaSeparatedPathParts(ackWatchRequest.getActionIds())
|
||||||
|
@ -147,7 +144,7 @@ final class WatcherRequestConverters {
|
||||||
|
|
||||||
static Request activateWatch(ActivateWatchRequest activateWatchRequest) {
|
static Request activateWatch(ActivateWatchRequest activateWatchRequest) {
|
||||||
String endpoint = new RequestConverters.EndpointBuilder()
|
String endpoint = new RequestConverters.EndpointBuilder()
|
||||||
.addPathPartAsIs("_xpack", "watcher", "watch")
|
.addPathPartAsIs("_watcher", "watch")
|
||||||
.addPathPart(activateWatchRequest.getWatchId())
|
.addPathPart(activateWatchRequest.getWatchId())
|
||||||
.addPathPartAsIs("_activate")
|
.addPathPartAsIs("_activate")
|
||||||
.build();
|
.build();
|
||||||
|
@ -156,7 +153,7 @@ final class WatcherRequestConverters {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Request watcherStats(WatcherStatsRequest watcherStatsRequest) {
|
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();
|
String endpoint = builder.build();
|
||||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||||
RequestConverters.Params parameters = new RequestConverters.Params(request);
|
RequestConverters.Params parameters = new RequestConverters.Params(request);
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class WatcherIT extends ESRestHighLevelClientTestCase {
|
||||||
assertEquals(AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION, actionStatus.ackStatus().state());
|
assertEquals(AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION, actionStatus.ackStatus().state());
|
||||||
|
|
||||||
// TODO: use the high-level REST client here once it supports 'execute watch'.
|
// 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 }");
|
executeWatchRequest.setJsonEntity("{ \"record_execution\": true }");
|
||||||
Response executeResponse = client().performRequest(executeWatchRequest);
|
Response executeResponse = client().performRequest(executeWatchRequest);
|
||||||
assertEquals(RestStatus.OK.getStatus(), executeResponse.getStatusLine().getStatusCode());
|
assertEquals(RestStatus.OK.getStatus(), executeResponse.getStatusLine().getStatusCode());
|
||||||
|
|
|
@ -67,13 +67,13 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
public void testStartWatchService() {
|
public void testStartWatchService() {
|
||||||
Request request = WatcherRequestConverters.startWatchService(new StartWatchServiceRequest());
|
Request request = WatcherRequestConverters.startWatchService(new StartWatchServiceRequest());
|
||||||
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
|
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
|
||||||
assertEquals("/_xpack/watcher/_start", request.getEndpoint());
|
assertEquals("/_watcher/_start", request.getEndpoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStopWatchService() {
|
public void testStopWatchService() {
|
||||||
Request request = WatcherRequestConverters.stopWatchService(new StopWatchServiceRequest());
|
Request request = WatcherRequestConverters.stopWatchService(new StopWatchServiceRequest());
|
||||||
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
|
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
|
||||||
assertEquals("/_xpack/watcher/_stop", request.getEndpoint());
|
assertEquals("/_watcher/_stop", request.getEndpoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPutWatch() throws Exception {
|
public void testPutWatch() throws Exception {
|
||||||
|
@ -95,7 +95,7 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
|
|
||||||
Request request = WatcherRequestConverters.putWatch(putWatchRequest);
|
Request request = WatcherRequestConverters.putWatch(putWatchRequest);
|
||||||
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
|
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
|
||||||
assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint());
|
assertEquals("/_watcher/watch/" + watchId, request.getEndpoint());
|
||||||
assertEquals(expectedParams, request.getParameters());
|
assertEquals(expectedParams, request.getParameters());
|
||||||
assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters()));
|
assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters()));
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
@ -109,7 +109,7 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
|
|
||||||
Request request = WatcherRequestConverters.getWatch(getWatchRequest);
|
Request request = WatcherRequestConverters.getWatch(getWatchRequest);
|
||||||
assertEquals(HttpGet.METHOD_NAME, request.getMethod());
|
assertEquals(HttpGet.METHOD_NAME, request.getMethod());
|
||||||
assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint());
|
assertEquals("/_watcher/watch/" + watchId, request.getEndpoint());
|
||||||
assertThat(request.getEntity(), nullValue());
|
assertThat(request.getEntity(), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
Request request = WatcherRequestConverters.deactivateWatch(deactivateWatchRequest);
|
Request request = WatcherRequestConverters.deactivateWatch(deactivateWatchRequest);
|
||||||
|
|
||||||
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
|
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
|
||||||
assertEquals("/_xpack/watcher/watch/" + watchId + "/_deactivate", request.getEndpoint());
|
assertEquals("/_watcher/watch/" + watchId + "/_deactivate", request.getEndpoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeleteWatch() {
|
public void testDeleteWatch() {
|
||||||
|
@ -128,7 +128,7 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
|
|
||||||
Request request = WatcherRequestConverters.deleteWatch(deleteWatchRequest);
|
Request request = WatcherRequestConverters.deleteWatch(deleteWatchRequest);
|
||||||
assertEquals(HttpDelete.METHOD_NAME, request.getMethod());
|
assertEquals(HttpDelete.METHOD_NAME, request.getMethod());
|
||||||
assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint());
|
assertEquals("/_watcher/watch/" + watchId, request.getEndpoint());
|
||||||
assertThat(request.getEntity(), nullValue());
|
assertThat(request.getEntity(), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
|
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
|
||||||
|
|
||||||
StringJoiner expectedEndpoint = new StringJoiner("/", "/", "")
|
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) {
|
if (ackWatchRequest.getActionIds().length > 0) {
|
||||||
String actionsParam = String.join(",", ackWatchRequest.getActionIds());
|
String actionsParam = String.join(",", ackWatchRequest.getActionIds());
|
||||||
expectedEndpoint.add(actionsParam);
|
expectedEndpoint.add(actionsParam);
|
||||||
|
@ -158,7 +158,7 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
|
|
||||||
Request request = WatcherRequestConverters.activateWatch(activateWatchRequest);
|
Request request = WatcherRequestConverters.activateWatch(activateWatchRequest);
|
||||||
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
|
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());
|
assertThat(request.getEntity(), nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
WatcherStatsRequest watcherStatsRequest = new WatcherStatsRequest(includeCurrent, includeQueued);
|
WatcherStatsRequest watcherStatsRequest = new WatcherStatsRequest(includeCurrent, includeQueued);
|
||||||
|
|
||||||
Request request = WatcherRequestConverters.watcherStats(watcherStatsRequest);
|
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));
|
assertThat(request.getMethod(), equalTo(HttpGet.METHOD_NAME));
|
||||||
if (includeCurrent || includeQueued) {
|
if (includeCurrent || includeQueued) {
|
||||||
assertThat(request.getParameters(), hasKey("metric"));
|
assertThat(request.getParameters(), hasKey("metric"));
|
||||||
|
@ -218,7 +218,7 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
Request req = WatcherRequestConverters.executeWatch(request);
|
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));
|
assertThat(req.getMethod(), equalTo(HttpPost.METHOD_NAME));
|
||||||
|
|
||||||
if (ignoreCondition) {
|
if (ignoreCondition) {
|
||||||
|
@ -293,7 +293,7 @@ public class WatcherRequestConvertersTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
Request req = WatcherRequestConverters.executeWatch(request);
|
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));
|
assertThat(req.getMethod(), equalTo(HttpPost.METHOD_NAME));
|
||||||
|
|
||||||
if (ignoreCondition) {
|
if (ignoreCondition) {
|
||||||
|
|
|
@ -407,7 +407,7 @@ public class WatcherDocumentationIT extends ESRestHighLevelClientTestCase {
|
||||||
client.watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT);
|
client.watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT);
|
||||||
|
|
||||||
// TODO: use the high-level REST client here once it supports 'execute watch'.
|
// 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 }");
|
executeWatchRequest.setJsonEntity("{ \"record_execution\": true }");
|
||||||
Response executeResponse = client().performRequest(executeWatchRequest);
|
Response executeResponse = client().performRequest(executeWatchRequest);
|
||||||
assertEquals(RestStatus.OK.getStatus(), executeResponse.getStatusLine().getStatusCode());
|
assertEquals(RestStatus.OK.getStatus(), executeResponse.getStatusLine().getStatusCode());
|
||||||
|
|
|
@ -14,9 +14,9 @@ execution.
|
||||||
[float]
|
[float]
|
||||||
==== Request
|
==== Request
|
||||||
|
|
||||||
`PUT _xpack/watcher/watch/<watch_id>/_ack` +
|
`PUT _watcher/watch/<watch_id>/_ack` +
|
||||||
|
|
||||||
`PUT _xpack/watcher/watch/<watch_id>/_ack/<action_id>`
|
`PUT _watcher/watch/<watch_id>/_ack/<action_id>`
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Path Parameters
|
==== Path Parameters
|
||||||
|
@ -42,7 +42,7 @@ To demonstrate let's create a new watch:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/my_watch
|
PUT _watcher/watch/my_watch
|
||||||
{
|
{
|
||||||
"trigger": {
|
"trigger": {
|
||||||
"schedule": {
|
"schedule": {
|
||||||
|
@ -80,7 +80,7 @@ watch definition when you call the <<watcher-api-get-watch, Get Watch API>>:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET _xpack/watcher/watch/my_watch
|
GET _watcher/watch/my_watch
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
||||||
|
@ -117,12 +117,12 @@ check the status:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/watch/my_watch/_execute
|
POST _watcher/watch/my_watch/_execute
|
||||||
{
|
{
|
||||||
"record_execution" : true
|
"record_execution" : true
|
||||||
}
|
}
|
||||||
|
|
||||||
GET _xpack/watcher/watch/my_watch
|
GET _watcher/watch/my_watch
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
|
@ -172,8 +172,8 @@ Now we can acknowledge it:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/my_watch/_ack/test_index
|
PUT _watcher/watch/my_watch/_ack/test_index
|
||||||
GET _xpack/watcher/watch/my_watch
|
GET _watcher/watch/my_watch
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
|
@ -226,7 +226,7 @@ comma-separated list of action ids:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/watch/my_watch/_ack/action1,action2
|
POST _watcher/watch/my_watch/_ack/action1,action2
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
||||||
|
@ -235,9 +235,9 @@ parameter:
|
||||||
|
|
||||||
[source,js]
|
[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
|
// CONSOLE
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ API enables you to activate a currently inactive watch.
|
||||||
[float]
|
[float]
|
||||||
==== Request
|
==== Request
|
||||||
|
|
||||||
`PUT _xpack/watcher/watch/<watch_id>/_activate`
|
`PUT _watcher/watch/<watch_id>/_activate`
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Path Parameters
|
==== Path Parameters
|
||||||
|
@ -31,7 +31,7 @@ call the <<watcher-api-get-watch, Get Watch API>>:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET _xpack/watcher/watch/my_watch
|
GET _watcher/watch/my_watch
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[setup:my_inactive_watch]
|
// TEST[setup:my_inactive_watch]
|
||||||
|
@ -62,7 +62,7 @@ You can activate the watch by executing the following API call:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/my_watch/_activate
|
PUT _watcher/watch/my_watch/_activate
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[setup:my_inactive_watch]
|
// TEST[setup:my_inactive_watch]
|
||||||
|
|
|
@ -9,7 +9,7 @@ API enables you to deactivate a currently active watch.
|
||||||
[float]
|
[float]
|
||||||
==== Request
|
==== Request
|
||||||
|
|
||||||
`PUT _xpack/watcher/watch/<watch_id>/_deactivate`
|
`PUT _watcher/watch/<watch_id>/_deactivate`
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Path Parameters
|
==== Path Parameters
|
||||||
|
@ -30,7 +30,7 @@ call the <<watcher-api-get-watch, Get Watch API>>:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET _xpack/watcher/watch/my_watch
|
GET _watcher/watch/my_watch
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[setup:my_active_watch]
|
// TEST[setup:my_active_watch]
|
||||||
|
@ -61,7 +61,7 @@ You can deactivate the watch by executing the following API call:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/my_watch/_deactivate
|
PUT _watcher/watch/my_watch/_deactivate
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[setup:my_active_watch]
|
// TEST[setup:my_active_watch]
|
||||||
|
|
|
@ -7,7 +7,7 @@ The DELETE watch API removes a watch from {watcher}.
|
||||||
[float]
|
[float]
|
||||||
==== Request
|
==== Request
|
||||||
|
|
||||||
`DELETE _xpack/watcher/watch/<watch_id>`
|
`DELETE _watcher/watch/<watch_id>`
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Description
|
==== Description
|
||||||
|
@ -42,7 +42,7 @@ The following example deletes a watch with the `my-watch` id:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
DELETE _xpack/watcher/watch/my_watch
|
DELETE _watcher/watch/my_watch
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[setup:my_active_watch]
|
// TEST[setup:my_active_watch]
|
||||||
|
|
|
@ -9,9 +9,9 @@ watch execution for debugging purposes.
|
||||||
[float]
|
[float]
|
||||||
==== Request
|
==== Request
|
||||||
|
|
||||||
`POST _xpack/watcher/watch/<watch_id>/_execute` +
|
`POST _watcher/watch/<watch_id>/_execute` +
|
||||||
|
|
||||||
`POST _xpack/watcher/watch/_execute`
|
`POST _watcher/watch/_execute`
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Description
|
==== Description
|
||||||
|
@ -137,7 +137,7 @@ The following example executes the `my_watch` watch:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/watch/my_watch/_execute
|
POST _watcher/watch/my_watch/_execute
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[setup:my_active_watch]
|
// TEST[setup:my_active_watch]
|
||||||
|
@ -146,7 +146,7 @@ The following example shows a comprehensive example of executing the `my-watch`
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/watch/my_watch/_execute
|
POST _watcher/watch/my_watch/_execute
|
||||||
{
|
{
|
||||||
"trigger_data" : { <1>
|
"trigger_data" : { <1>
|
||||||
"triggered_time" : "now",
|
"triggered_time" : "now",
|
||||||
|
@ -289,7 +289,7 @@ name with the action id:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/watch/my_watch/_execute
|
POST _watcher/watch/my_watch/_execute
|
||||||
{
|
{
|
||||||
"action_modes" : {
|
"action_modes" : {
|
||||||
"action1" : "force_simulate",
|
"action1" : "force_simulate",
|
||||||
|
@ -305,7 +305,7 @@ using `_all` as the action id:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/watch/my_watch/_execute
|
POST _watcher/watch/my_watch/_execute
|
||||||
{
|
{
|
||||||
"action_modes" : {
|
"action_modes" : {
|
||||||
"_all" : "force_execute"
|
"_all" : "force_execute"
|
||||||
|
@ -319,7 +319,7 @@ The following example shows how to execute a watch inline:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/watch/_execute
|
POST _watcher/watch/_execute
|
||||||
{
|
{
|
||||||
"watch" : {
|
"watch" : {
|
||||||
"trigger" : { "schedule" : { "interval" : "10s" } },
|
"trigger" : { "schedule" : { "interval" : "10s" } },
|
||||||
|
@ -356,7 +356,7 @@ during the execution this condition will be ignored:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/watch/_execute
|
POST _watcher/watch/_execute
|
||||||
{
|
{
|
||||||
"ignore_condition" : true,
|
"ignore_condition" : true,
|
||||||
"watch" : {
|
"watch" : {
|
||||||
|
|
|
@ -7,7 +7,7 @@ This API retrieves a watch by its ID.
|
||||||
[float]
|
[float]
|
||||||
==== Request
|
==== Request
|
||||||
|
|
||||||
`GET _xpack/watcher/watch/<watch_id>`
|
`GET _watcher/watch/<watch_id>`
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Path Parameters
|
==== Path Parameters
|
||||||
|
@ -29,7 +29,7 @@ The following example gets a watch with `my-watch` id:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET _xpack/watcher/watch/my_watch
|
GET _watcher/watch/my_watch
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[setup:my_active_watch]
|
// TEST[setup:my_active_watch]
|
||||||
|
|
|
@ -8,7 +8,7 @@ existing one.
|
||||||
[float]
|
[float]
|
||||||
==== Request
|
==== Request
|
||||||
|
|
||||||
`PUT _xpack/watcher/watch/<watch_id>`
|
`PUT _watcher/watch/<watch_id>`
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Description
|
==== Description
|
||||||
|
@ -96,7 +96,7 @@ characteristics:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/my-watch
|
PUT _watcher/watch/my-watch
|
||||||
{
|
{
|
||||||
"trigger" : {
|
"trigger" : {
|
||||||
"schedule" : { "cron" : "0 0/1 * * * ?" }
|
"schedule" : { "cron" : "0 0/1 * * * ?" }
|
||||||
|
@ -151,7 +151,7 @@ it to be inactive by default:
|
||||||
|
|
||||||
[source,js]
|
[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.
|
NOTE: If you omit the `active` parameter, the watch is active by default.
|
||||||
|
|
|
@ -8,7 +8,7 @@ running.
|
||||||
[float]
|
[float]
|
||||||
==== Request
|
==== Request
|
||||||
|
|
||||||
`POST _xpack/watcher/_start`
|
`POST _watcher/_start`
|
||||||
|
|
||||||
==== Authorization
|
==== Authorization
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ information, see {xpack-ref}/security-privileges.html[Security Privileges].
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/_start
|
POST _watcher/_start
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ The `stats` API returns the current {watcher} metrics.
|
||||||
[float]
|
[float]
|
||||||
==== Request
|
==== Request
|
||||||
|
|
||||||
`GET _xpack/watcher/stats` +
|
`GET _watcher/stats` +
|
||||||
|
|
||||||
`GET _xpack/watcher/stats/<metric>`
|
`GET _watcher/stats/<metric>`
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Description
|
==== Description
|
||||||
|
@ -69,7 +69,7 @@ The following example calls the `stats` API to retrieve basic metrics:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET _xpack/watcher/stats
|
GET _watcher/stats
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ and will include the basic metrics and metrics about the current executing watch
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET _xpack/watcher/stats?metric=current_watches
|
GET _watcher/stats?metric=current_watches
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ The following example specifies the `metric` option as part of the url path:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET _xpack/watcher/stats/current_watches
|
GET _watcher/stats/current_watches
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ both the basic metrics and the queued watches:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
GET _xpack/watcher/stats/queued_watches
|
GET _watcher/stats/queued_watches
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ The `stop` API stops the {watcher} service if the service is running.
|
||||||
[float]
|
[float]
|
||||||
==== Request
|
==== Request
|
||||||
|
|
||||||
`POST _xpack/watcher/_stop`
|
`POST _watcher/_stop`
|
||||||
|
|
||||||
[float]
|
[float]
|
||||||
==== Authorization
|
==== Authorization
|
||||||
|
@ -20,7 +20,7 @@ information, see {xpack-ref}/security-privileges.html[Security Privileges].
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/_stop
|
POST _watcher/_stop
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ a throttle period with the `email_administrator` action:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/error_logs_alert
|
PUT _watcher/watch/error_logs_alert
|
||||||
{
|
{
|
||||||
"metadata" : {
|
"metadata" : {
|
||||||
"color" : "red"
|
"color" : "red"
|
||||||
|
@ -101,7 +101,7 @@ defined in the watch:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/log_event_watch
|
PUT _watcher/watch/log_event_watch
|
||||||
{
|
{
|
||||||
"trigger" : {
|
"trigger" : {
|
||||||
"schedule" : { "interval" : "5m" }
|
"schedule" : { "interval" : "5m" }
|
||||||
|
@ -177,7 +177,7 @@ To acknowledge an action, you use the
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
POST _xpack/watcher/watch/<id>/_ack/<action_ids>
|
POST _watcher/watch/<id>/_ack/<action_ids>
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[skip:https://github.com/elastic/x-plugins/issues/2513]
|
// 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]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/log_event_watch
|
PUT _watcher/watch/log_event_watch
|
||||||
{
|
{
|
||||||
"trigger" : {
|
"trigger" : {
|
||||||
"schedule" : { "interval" : "5m" }
|
"schedule" : { "interval" : "5m" }
|
||||||
|
|
|
@ -24,7 +24,7 @@ the following schedule runs every 10 seconds:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/cluster_health_watch
|
PUT _watcher/watch/cluster_health_watch
|
||||||
{
|
{
|
||||||
"trigger" : {
|
"trigger" : {
|
||||||
"schedule" : { "interval" : "10s" } <1>
|
"schedule" : { "interval" : "10s" } <1>
|
||||||
|
@ -52,7 +52,7 @@ To load the health status into your watch, you simply add an
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/cluster_health_watch
|
PUT _watcher/watch/cluster_health_watch
|
||||||
{
|
{
|
||||||
"trigger" : {
|
"trigger" : {
|
||||||
"schedule" : { "interval" : "10s" }
|
"schedule" : { "interval" : "10s" }
|
||||||
|
@ -74,7 +74,7 @@ If you're using Security, then you'll also need to supply some authentication cr
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/cluster_health_watch
|
PUT _watcher/watch/cluster_health_watch
|
||||||
{
|
{
|
||||||
"trigger" : {
|
"trigger" : {
|
||||||
"schedule" : { "interval" : "10s" }
|
"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]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/cluster_health_watch
|
PUT _watcher/watch/cluster_health_watch
|
||||||
{
|
{
|
||||||
"trigger" : {
|
"trigger" : {
|
||||||
"schedule" : { "interval" : "10s" } <1>
|
"schedule" : { "interval" : "10s" } <1>
|
||||||
|
@ -191,7 +191,7 @@ when the status is RED.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/cluster_health_watch
|
PUT _watcher/watch/cluster_health_watch
|
||||||
{
|
{
|
||||||
"trigger" : {
|
"trigger" : {
|
||||||
"schedule" : { "interval" : "10s" }
|
"schedule" : { "interval" : "10s" }
|
||||||
|
@ -280,7 +280,7 @@ To remove the watch, use the {ref}/watcher-api-delete-watch.html[DELETE watch AP
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
DELETE _xpack/watcher/watch/cluster_health_watch
|
DELETE _watcher/watch/cluster_health_watch
|
||||||
-------------------------------------------------------
|
-------------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
|
|
|
@ -194,7 +194,7 @@ NOTE: To enable Watcher to send emails, you must configure an email account in `
|
||||||
The complete watch looks like this:
|
The complete watch looks like this:
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/meetup
|
PUT _watcher/watch/meetup
|
||||||
{
|
{
|
||||||
"trigger": {
|
"trigger": {
|
||||||
"schedule": {
|
"schedule": {
|
||||||
|
@ -300,7 +300,7 @@ Now that you've created your watch, you can use the
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/watch/meetup/_execute
|
POST _watcher/watch/meetup/_execute
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
|
|
|
@ -157,7 +157,7 @@ The complete watch looks like this:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/rss_watch
|
PUT _watcher/watch/rss_watch
|
||||||
{
|
{
|
||||||
"trigger" : {
|
"trigger" : {
|
||||||
"schedule" : {
|
"schedule" : {
|
||||||
|
@ -215,7 +215,7 @@ use the {ref}/watcher-api-execute-watch.html[`_execute` API]:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
POST _xpack/watcher/watch/rss_watch/_execute
|
POST _watcher/watch/rss_watch/_execute
|
||||||
{
|
{
|
||||||
"ignore_condition" : true,
|
"ignore_condition" : true,
|
||||||
"action_modes" : {
|
"action_modes" : {
|
||||||
|
|
|
@ -28,7 +28,7 @@ the `logs` index for errors every 10 seconds:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
------------------------------------------------------------
|
------------------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/log_error_watch
|
PUT _watcher/watch/log_error_watch
|
||||||
{
|
{
|
||||||
"trigger" : {
|
"trigger" : {
|
||||||
"schedule" : { "interval" : "10s" } <1>
|
"schedule" : { "interval" : "10s" } <1>
|
||||||
|
@ -86,7 +86,7 @@ search input returned any hits.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/log_error_watch
|
PUT _watcher/watch/log_error_watch
|
||||||
{
|
{
|
||||||
"trigger" : { "schedule" : { "interval" : "10s" }},
|
"trigger" : { "schedule" : { "interval" : "10s" }},
|
||||||
"input" : {
|
"input" : {
|
||||||
|
@ -165,7 +165,7 @@ log when an error is detected.
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/log_error_watch
|
PUT _watcher/watch/log_error_watch
|
||||||
{
|
{
|
||||||
"trigger" : { "schedule" : { "interval" : "10s" }},
|
"trigger" : { "schedule" : { "interval" : "10s" }},
|
||||||
"input" : {
|
"input" : {
|
||||||
|
@ -207,7 +207,7 @@ To remove the watch, use the {ref}/watcher-api-delete-watch.html[DELETE watch AP
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
DELETE _xpack/watcher/watch/log_error_watch
|
DELETE _watcher/watch/log_error_watch
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[continued]
|
// TEST[continued]
|
||||||
|
|
|
@ -48,7 +48,7 @@ looks for log error events:
|
||||||
|
|
||||||
[source,js]
|
[source,js]
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
PUT _xpack/watcher/watch/log_errors
|
PUT _watcher/watch/log_errors
|
||||||
{
|
{
|
||||||
"metadata" : { <1>
|
"metadata" : { <1>
|
||||||
"color" : "red"
|
"color" : "red"
|
||||||
|
|
|
@ -87,13 +87,13 @@ public class ClusterAlertHttpResource extends PublishableHttpResource {
|
||||||
(response) -> shouldReplaceClusterAlert(response, XContentType.JSON.xContent(), LAST_UPDATED_VERSION);
|
(response) -> shouldReplaceClusterAlert(response, XContentType.JSON.xContent(), LAST_UPDATED_VERSION);
|
||||||
|
|
||||||
checkForResource(client, listener, logger,
|
checkForResource(client, listener, logger,
|
||||||
"/_xpack/watcher/watch", watchId.get(), "monitoring cluster alert",
|
"/_watcher/watch", watchId.get(), "monitoring cluster alert",
|
||||||
resourceOwnerName, "monitoring cluster",
|
resourceOwnerName, "monitoring cluster",
|
||||||
GET_EXISTS, GET_DOES_NOT_EXIST,
|
GET_EXISTS, GET_DOES_NOT_EXIST,
|
||||||
watchChecker, this::alwaysReplaceResource);
|
watchChecker, this::alwaysReplaceResource);
|
||||||
} else {
|
} else {
|
||||||
// if we should be deleting, then just try to delete it (same level of effort as checking)
|
// 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",
|
"monitoring cluster alert",
|
||||||
resourceOwnerName, "monitoring cluster");
|
resourceOwnerName, "monitoring cluster");
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public class ClusterAlertHttpResource extends PublishableHttpResource {
|
||||||
@Override
|
@Override
|
||||||
protected void doPublish(final RestClient client, final ActionListener<Boolean> listener) {
|
protected void doPublish(final RestClient client, final ActionListener<Boolean> listener) {
|
||||||
putResource(client, listener, logger,
|
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");
|
resourceOwnerName, "monitoring cluster");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ClusterAlertHttpResourceTests extends AbstractPublishableHttpResour
|
||||||
|
|
||||||
final HttpEntity entity = entityForClusterAlert(true, minimumVersion);
|
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 {
|
public void testDoCheckGetWatchDoesNotExist() throws IOException {
|
||||||
|
@ -71,12 +71,12 @@ public class ClusterAlertHttpResourceTests extends AbstractPublishableHttpResour
|
||||||
|
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
// it does not exist because it's literally not there
|
// it does not exist because it's literally not there
|
||||||
assertCheckDoesNotExist(resource, "/_xpack/watcher/watch", watchId);
|
assertCheckDoesNotExist(resource, "/_watcher/watch", watchId);
|
||||||
} else {
|
} else {
|
||||||
// it does not exist because we need to replace it
|
// it does not exist because we need to replace it
|
||||||
final HttpEntity entity = entityForClusterAlert(false, minimumVersion);
|
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 class ClusterAlertHttpResourceTests extends AbstractPublishableHttpResour
|
||||||
|
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
// error because of a server error
|
// error because of a server error
|
||||||
assertCheckWithException(resource, "/_xpack/watcher/watch", watchId);
|
assertCheckWithException(resource, "/_watcher/watch", watchId);
|
||||||
} else {
|
} else {
|
||||||
// error because of a malformed response
|
// error because of a malformed response
|
||||||
final HttpEntity entity = entityForClusterAlert(null, minimumVersion);
|
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 class ClusterAlertHttpResourceTests extends AbstractPublishableHttpResour
|
||||||
// should not matter
|
// should not matter
|
||||||
when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(clusterAlertsAllowed);
|
when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(clusterAlertsAllowed);
|
||||||
|
|
||||||
assertCheckAsDeleteExists(noWatchResource, "/_xpack/watcher/watch", watchId);
|
assertCheckAsDeleteExists(noWatchResource, "/_watcher/watch", watchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDoCheckWithExceptionAsDeleteWatchErrorWhenNoWatchIsSpecified() throws IOException {
|
public void testDoCheckWithExceptionAsDeleteWatchErrorWhenNoWatchIsSpecified() throws IOException {
|
||||||
|
@ -111,27 +111,27 @@ public class ClusterAlertHttpResourceTests extends AbstractPublishableHttpResour
|
||||||
// should not matter
|
// should not matter
|
||||||
when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(clusterAlertsAllowed);
|
when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(clusterAlertsAllowed);
|
||||||
|
|
||||||
assertCheckAsDeleteWithException(noWatchResource, "/_xpack/watcher/watch", watchId);
|
assertCheckAsDeleteWithException(noWatchResource, "/_watcher/watch", watchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDoCheckAsDeleteWatchExists() throws IOException {
|
public void testDoCheckAsDeleteWatchExists() throws IOException {
|
||||||
when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(false);
|
when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(false);
|
||||||
|
|
||||||
assertCheckAsDeleteExists(resource, "/_xpack/watcher/watch", watchId);
|
assertCheckAsDeleteExists(resource, "/_watcher/watch", watchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDoCheckWithExceptionAsDeleteWatchError() throws IOException {
|
public void testDoCheckWithExceptionAsDeleteWatchError() throws IOException {
|
||||||
when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(false);
|
when(licenseState.isMonitoringClusterAlertsAllowed()).thenReturn(false);
|
||||||
|
|
||||||
assertCheckAsDeleteWithException(resource, "/_xpack/watcher/watch", watchId);
|
assertCheckAsDeleteWithException(resource, "/_watcher/watch", watchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDoPublishTrue() throws IOException {
|
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 {
|
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 {
|
public void testShouldReplaceClusterAlertRethrowsIOException() throws IOException {
|
||||||
|
|
|
@ -497,7 +497,7 @@ public class HttpExporterIT extends MonitoringIntegTestCase {
|
||||||
// GET / PUT if we are allowed to use it
|
// GET / PUT if we are allowed to use it
|
||||||
if (currentLicenseAllowsWatcher && clusterAlertBlacklist.contains(watch.v1()) == false) {
|
if (currentLicenseAllowsWatcher && clusterAlertBlacklist.contains(watch.v1()) == false) {
|
||||||
assertThat(request.getMethod(), equalTo("GET"));
|
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()));
|
assertThat(request.getUri().getQuery(), equalTo(resourceClusterAlertQueryString()));
|
||||||
assertHeaders(request, customHeaders);
|
assertHeaders(request, customHeaders);
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ public class HttpExporterIT extends MonitoringIntegTestCase {
|
||||||
request = webServer.takeRequest();
|
request = webServer.takeRequest();
|
||||||
|
|
||||||
assertThat(request.getMethod(), equalTo("PUT"));
|
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.getUri().getQuery(), equalTo(resourceClusterAlertQueryString()));
|
||||||
assertThat(request.getBody(), equalTo(watch.v2()));
|
assertThat(request.getBody(), equalTo(watch.v2()));
|
||||||
assertHeaders(request, customHeaders);
|
assertHeaders(request, customHeaders);
|
||||||
|
@ -513,7 +513,7 @@ public class HttpExporterIT extends MonitoringIntegTestCase {
|
||||||
// DELETE if we're not allowed to use it
|
// DELETE if we're not allowed to use it
|
||||||
} else {
|
} else {
|
||||||
assertThat(request.getMethod(), equalTo("DELETE"));
|
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()));
|
assertThat(request.getUri().getQuery(), equalTo(resourceClusterAlertQueryString()));
|
||||||
assertHeaders(request, customHeaders);
|
assertHeaders(request, customHeaders);
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,7 +376,7 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe
|
||||||
final List<Response> otherResponses = getWatcherResponses(1, successful, unsuccessful);
|
final List<Response> otherResponses = getWatcherResponses(1, successful, unsuccessful);
|
||||||
|
|
||||||
// last check fails implies that N - 2 publishes succeeded!
|
// 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);
|
first, otherResponses, exception);
|
||||||
whenSuccessfulPutWatches(otherResponses.size() + 1);
|
whenSuccessfulPutWatches(otherResponses.size() + 1);
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe
|
||||||
// there is no form of an unsuccessful delete; only success or error
|
// there is no form of an unsuccessful delete; only success or error
|
||||||
final List<Response> responses = successfulDeleteResponses(successful);
|
final List<Response> 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);
|
responses.get(0), responses.subList(1, responses.size()), exception);
|
||||||
|
|
||||||
expectedGets += successful;
|
expectedGets += successful;
|
||||||
|
@ -399,7 +399,7 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe
|
||||||
} else {
|
} else {
|
||||||
final String method = validLicense ? "GET" : "DELETE";
|
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());
|
assertTrue(resources.isDirty());
|
||||||
|
@ -454,7 +454,7 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe
|
||||||
whenGetWatches(successful, unsuccessful + 2);
|
whenGetWatches(successful, unsuccessful + 2);
|
||||||
|
|
||||||
// previous publishes must have succeeded
|
// 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);
|
firstSuccess, otherResponses, exception);
|
||||||
|
|
||||||
// GETs required for each PUT attempt (first is guaranteed "unsuccessful")
|
// GETs required for each PUT attempt (first is guaranteed "unsuccessful")
|
||||||
|
@ -465,7 +465,7 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe
|
||||||
// fail the check so that it has to attempt the PUT
|
// fail the check so that it has to attempt the PUT
|
||||||
whenGetWatches(0, 1);
|
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());
|
assertTrue(resources.isDirty());
|
||||||
|
@ -595,13 +595,13 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe
|
||||||
private Response successfulGetWatchResponse(final String watchId) {
|
private Response successfulGetWatchResponse(final String watchId) {
|
||||||
final HttpEntity goodEntity = entityForClusterAlert(true, ClusterAlertsUtil.LAST_UPDATED_VERSION);
|
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) {
|
private Response unsuccessfulGetWatchResponse(final String watchId) {
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
final HttpEntity badEntity = entityForClusterAlert(false, ClusterAlertsUtil.LAST_UPDATED_VERSION);
|
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();
|
return unsuccessfulGetResponse();
|
||||||
|
@ -764,21 +764,21 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe
|
||||||
private void whenGetWatches(final int successful, final int unsuccessful) {
|
private void whenGetWatches(final int successful, final int unsuccessful) {
|
||||||
final List<Response> gets = getWatcherResponses(0, successful, unsuccessful);
|
final List<Response> 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) {
|
private void whenSuccessfulPutWatches(final int successful) {
|
||||||
final List<Response> successfulPuts = successfulPutResponses(successful);
|
final List<Response> successfulPuts = successfulPutResponses(successful);
|
||||||
|
|
||||||
// empty is possible if they all exist
|
// 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) {
|
private void whenSuccessfulDeleteWatches(final int successful) {
|
||||||
final List<Response> successfulDeletes = successfulDeleteResponses(successful);
|
final List<Response> successfulDeletes = successfulDeleteResponses(successful);
|
||||||
|
|
||||||
// empty is possible if they all exist
|
// 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() {
|
private void verifyVersionCheck() {
|
||||||
|
@ -811,18 +811,18 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe
|
||||||
|
|
||||||
private void verifyDeleteWatches(final int called) {
|
private void verifyDeleteWatches(final int called) {
|
||||||
verify(client, times(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));
|
any(ResponseListener.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyGetWatches(final int called) {
|
private void verifyGetWatches(final int called) {
|
||||||
verify(client, times(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) {
|
private void verifyPutWatches(final int called) {
|
||||||
verify(client, times(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) {
|
private ClusterService mockClusterService(final ClusterState state) {
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class XPackRestIT extends ESClientYamlSuiteTestCase {
|
||||||
List<Map<String, Object>> hits = objectPathResponse.evaluate("hits.hits");
|
List<Map<String, Object>> hits = objectPathResponse.evaluate("hits.hits");
|
||||||
for (Map<String, Object> hit : hits) {
|
for (Map<String, Object> hit : hits) {
|
||||||
String id = (String) hit.get("_id");
|
String id = (String) hit.get("_id");
|
||||||
adminClient().performRequest(new Request("DELETE", "_xpack/watcher/watch/" + id));
|
adminClient().performRequest(new Request("DELETE", "_watcher/watch/" + id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html",
|
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html",
|
||||||
"methods": [ "PUT", "POST" ],
|
"methods": [ "PUT", "POST" ],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/watcher/watch/{watch_id}/_ack",
|
"path": "/_watcher/watch/{watch_id}/_ack",
|
||||||
"paths": [ "/_xpack/watcher/watch/{watch_id}/_ack", "/_xpack/watcher/watch/{watch_id}/_ack/{action_id}"],
|
"paths": [ "/_watcher/watch/{watch_id}/_ack", "/_watcher/watch/{watch_id}/_ack/{action_id}"],
|
||||||
"parts": {
|
"parts": {
|
||||||
"watch_id": {
|
"watch_id": {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html",
|
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html",
|
||||||
"methods": [ "PUT", "POST" ],
|
"methods": [ "PUT", "POST" ],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/watcher/watch/{watch_id}/_activate",
|
"path": "/_watcher/watch/{watch_id}/_activate",
|
||||||
"paths": [ "/_xpack/watcher/watch/{watch_id}/_activate" ],
|
"paths": [ "/_watcher/watch/{watch_id}/_activate" ],
|
||||||
"parts": {
|
"parts": {
|
||||||
"watch_id": {
|
"watch_id": {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html",
|
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html",
|
||||||
"methods": [ "PUT", "POST" ],
|
"methods": [ "PUT", "POST" ],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/watcher/watch/{watch_id}/_deactivate",
|
"path": "/_watcher/watch/{watch_id}/_deactivate",
|
||||||
"paths": [ "/_xpack/watcher/watch/{watch_id}/_deactivate" ],
|
"paths": [ "/_watcher/watch/{watch_id}/_deactivate" ],
|
||||||
"parts": {
|
"parts": {
|
||||||
"watch_id": {
|
"watch_id": {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
"methods": [ "DELETE" ],
|
"methods": [ "DELETE" ],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/watcher/watch/{id}",
|
"path": "/_watcher/watch/{id}",
|
||||||
"paths": [ "/_xpack/watcher/watch/{id}" ],
|
"paths": [ "/_watcher/watch/{id}" ],
|
||||||
"parts": {
|
"parts": {
|
||||||
"id": {
|
"id": {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html",
|
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html",
|
||||||
"methods": [ "PUT", "POST" ],
|
"methods": [ "PUT", "POST" ],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/watcher/watch/{id}/_execute",
|
"path": "/_watcher/watch/{id}/_execute",
|
||||||
"paths": [ "/_xpack/watcher/watch/{id}/_execute", "/_xpack/watcher/watch/_execute" ],
|
"paths": [ "/_watcher/watch/{id}/_execute", "/_watcher/watch/_execute" ],
|
||||||
"parts": {
|
"parts": {
|
||||||
"id": {
|
"id": {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html",
|
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html",
|
||||||
"methods": [ "GET" ],
|
"methods": [ "GET" ],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/watcher/watch/{id}",
|
"path": "/_watcher/watch/{id}",
|
||||||
"paths": [ "/_xpack/watcher/watch/{id}" ],
|
"paths": [ "/_watcher/watch/{id}" ],
|
||||||
"parts": {
|
"parts": {
|
||||||
"id": {
|
"id": {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html",
|
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html",
|
||||||
"methods": [ "PUT", "POST" ],
|
"methods": [ "PUT", "POST" ],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/watcher/watch/{id}",
|
"path": "/_watcher/watch/{id}",
|
||||||
"paths": [ "/_xpack/watcher/watch/{id}" ],
|
"paths": [ "/_watcher/watch/{id}" ],
|
||||||
"parts": {
|
"parts": {
|
||||||
"id": {
|
"id": {
|
||||||
"type" : "string",
|
"type" : "string",
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html",
|
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html",
|
||||||
"methods": [ "POST" ],
|
"methods": [ "POST" ],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/watcher/_start",
|
"path": "/_watcher/_start",
|
||||||
"paths": [ "/_xpack/watcher/_start" ],
|
"paths": [ "/_watcher/_start" ],
|
||||||
"parts": {
|
"parts": {
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html",
|
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html",
|
||||||
"methods": [ "GET" ],
|
"methods": [ "GET" ],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/watcher/stats",
|
"path": "/_watcher/stats",
|
||||||
"paths": [ "/_xpack/watcher/stats", "/_xpack/watcher/stats/{metric}" ],
|
"paths": [ "/_watcher/stats", "/_watcher/stats/{metric}" ],
|
||||||
"parts": {
|
"parts": {
|
||||||
"metric": {
|
"metric": {
|
||||||
"type" : "enum",
|
"type" : "enum",
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html",
|
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html",
|
||||||
"methods": [ "POST" ],
|
"methods": [ "POST" ],
|
||||||
"url": {
|
"url": {
|
||||||
"path": "/_xpack/watcher/_stop",
|
"path": "/_watcher/_stop",
|
||||||
"paths": [ "/_xpack/watcher/_stop" ],
|
"paths": [ "/_watcher/_stop" ],
|
||||||
"parts": {
|
"parts": {
|
||||||
},
|
},
|
||||||
"params": {
|
"params": {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
public abstract class WatcherRestHandler extends BaseRestHandler {
|
public abstract class WatcherRestHandler extends BaseRestHandler {
|
||||||
|
|
||||||
protected static String URI_BASE = "_xpack/watcher";
|
protected static String URI_BASE = "/_xpack";
|
||||||
|
|
||||||
public WatcherRestHandler(Settings settings) {
|
public WatcherRestHandler(Settings settings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
|
|
|
@ -3,8 +3,11 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.xpack.watcher.rest.action;
|
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.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.rest.BytesRestResponse;
|
import org.elasticsearch.rest.BytesRestResponse;
|
||||||
|
@ -30,17 +33,28 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT;
|
||||||
*/
|
*/
|
||||||
public class RestAckWatchAction extends WatcherRestHandler {
|
public class RestAckWatchAction extends WatcherRestHandler {
|
||||||
|
|
||||||
|
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestAckWatchAction.class));
|
||||||
|
|
||||||
public RestAckWatchAction(Settings settings, RestController controller) {
|
public RestAckWatchAction(Settings settings, RestController controller) {
|
||||||
super(settings);
|
super(settings);
|
||||||
controller.registerHandler(POST, URI_BASE + "/watch/{id}/_ack", this);
|
// TODO: remove deprecated endpoint in 8.0.0
|
||||||
controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_ack", this);
|
controller.registerWithDeprecatedHandler(
|
||||||
controller.registerHandler(POST, URI_BASE + "/watch/{id}/_ack/{actions}", this);
|
POST, "/_watcher/watch/{id}/_ack", this,
|
||||||
controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_ack/{actions}", 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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_watcher_ack_watch_action";
|
return "watcher_ack_watch";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,8 +3,11 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.xpack.watcher.rest.action;
|
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.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.rest.BytesRestResponse;
|
import org.elasticsearch.rest.BytesRestResponse;
|
||||||
|
@ -29,18 +32,31 @@ import static org.elasticsearch.rest.RestRequest.Method.PUT;
|
||||||
* The rest action to de/activate a watch
|
* The rest action to de/activate a watch
|
||||||
*/
|
*/
|
||||||
public class RestActivateWatchAction extends WatcherRestHandler {
|
public class RestActivateWatchAction extends WatcherRestHandler {
|
||||||
|
|
||||||
|
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestActivateWatchAction.class));
|
||||||
|
|
||||||
public RestActivateWatchAction(Settings settings, RestController controller) {
|
public RestActivateWatchAction(Settings settings, RestController controller) {
|
||||||
super(settings);
|
super(settings);
|
||||||
controller.registerHandler(POST, URI_BASE + "/watch/{id}/_activate", this);
|
// TODO: remove deprecated endpoint in 8.0.0
|
||||||
controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_activate", this);
|
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);
|
final DeactivateRestHandler deactivateRestHandler = new DeactivateRestHandler(settings);
|
||||||
controller.registerHandler(POST, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler);
|
controller.registerWithDeprecatedHandler(
|
||||||
controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler);
|
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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_watcher_activate_watch_action";
|
return "watcher_activate_watch";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,7 +81,7 @@ public class RestActivateWatchAction extends WatcherRestHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_watcher_deactivate_watch_action";
|
return "watcher_deactivate_watch";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,8 +3,11 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.xpack.watcher.rest.action;
|
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.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.rest.BytesRestResponse;
|
import org.elasticsearch.rest.BytesRestResponse;
|
||||||
|
@ -25,14 +28,20 @@ import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
|
||||||
import static org.elasticsearch.rest.RestStatus.OK;
|
import static org.elasticsearch.rest.RestStatus.OK;
|
||||||
|
|
||||||
public class RestDeleteWatchAction extends WatcherRestHandler {
|
public class RestDeleteWatchAction extends WatcherRestHandler {
|
||||||
|
|
||||||
|
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestDeleteWatchAction.class));
|
||||||
|
|
||||||
public RestDeleteWatchAction(Settings settings, RestController controller) {
|
public RestDeleteWatchAction(Settings settings, RestController controller) {
|
||||||
super(settings);
|
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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_watcher_delete_watch_action";
|
return "watcher_delete_watch";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,11 +3,14 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.xpack.watcher.rest.action;
|
package org.elasticsearch.xpack.watcher.rest.action;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
|
import org.elasticsearch.common.logging.DeprecationLogger;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -41,6 +44,8 @@ import static org.elasticsearch.xpack.watcher.rest.action.RestExecuteWatchAction
|
||||||
|
|
||||||
public class RestExecuteWatchAction extends WatcherRestHandler implements RestRequestFilter {
|
public class RestExecuteWatchAction extends WatcherRestHandler implements RestRequestFilter {
|
||||||
|
|
||||||
|
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestExecuteWatchAction.class));
|
||||||
|
|
||||||
private static final List<String> RESERVED_FIELD_NAMES = Arrays.asList(WatchField.TRIGGER.getPreferredName(),
|
private static final List<String> RESERVED_FIELD_NAMES = Arrays.asList(WatchField.TRIGGER.getPreferredName(),
|
||||||
WatchField.INPUT.getPreferredName(), WatchField.CONDITION.getPreferredName(),
|
WatchField.INPUT.getPreferredName(), WatchField.CONDITION.getPreferredName(),
|
||||||
WatchField.ACTIONS.getPreferredName(), WatchField.TRANSFORM.getPreferredName(),
|
WatchField.ACTIONS.getPreferredName(), WatchField.TRANSFORM.getPreferredName(),
|
||||||
|
@ -50,15 +55,24 @@ public class RestExecuteWatchAction extends WatcherRestHandler implements RestRe
|
||||||
|
|
||||||
public RestExecuteWatchAction(Settings settings, RestController controller) {
|
public RestExecuteWatchAction(Settings settings, RestController controller) {
|
||||||
super(settings);
|
super(settings);
|
||||||
controller.registerHandler(POST, URI_BASE + "/watch/{id}/_execute", this);
|
// TODO: remove deprecated endpoint in 8.0.0
|
||||||
controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_execute", this);
|
controller.registerWithDeprecatedHandler(
|
||||||
controller.registerHandler(POST, URI_BASE + "/watch/_execute", this);
|
POST, "/_watcher/watch/{id}/_execute", this,
|
||||||
controller.registerHandler(PUT, URI_BASE + "/watch/_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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_watcher_execute_watch_action";
|
return "watcher_execute_watch";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,8 +3,11 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.xpack.watcher.rest.action;
|
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.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -25,14 +28,20 @@ import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
|
||||||
import static org.elasticsearch.rest.RestStatus.OK;
|
import static org.elasticsearch.rest.RestStatus.OK;
|
||||||
|
|
||||||
public class RestGetWatchAction extends WatcherRestHandler {
|
public class RestGetWatchAction extends WatcherRestHandler {
|
||||||
|
|
||||||
|
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestGetWatchAction.class));
|
||||||
|
|
||||||
public RestGetWatchAction(Settings settings, RestController controller) {
|
public RestGetWatchAction(Settings settings, RestController controller) {
|
||||||
super(settings);
|
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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_watcher_get_watch_action";
|
return "watcher_get_watch";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,8 +3,11 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.xpack.watcher.rest.action;
|
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.lucene.uid.Versions;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.util.set.Sets;
|
import org.elasticsearch.common.util.set.Sets;
|
||||||
|
@ -32,15 +35,22 @@ import static org.elasticsearch.rest.RestStatus.OK;
|
||||||
|
|
||||||
public class RestPutWatchAction extends WatcherRestHandler implements RestRequestFilter {
|
public class RestPutWatchAction extends WatcherRestHandler implements RestRequestFilter {
|
||||||
|
|
||||||
|
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestPutWatchAction.class));
|
||||||
|
|
||||||
public RestPutWatchAction(Settings settings, RestController controller) {
|
public RestPutWatchAction(Settings settings, RestController controller) {
|
||||||
super(settings);
|
super(settings);
|
||||||
controller.registerHandler(POST, URI_BASE + "/watch/{id}", this);
|
// TODO: remove deprecated endpoint in 8.0.0
|
||||||
controller.registerHandler(PUT, URI_BASE + "/watch/{id}", this);
|
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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_watcher_put_watch_action";
|
return "watcher_put_watch";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,8 +3,11 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.xpack.watcher.rest.action;
|
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.settings.Settings;
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
|
@ -17,15 +20,22 @@ import static org.elasticsearch.rest.RestRequest.Method.POST;
|
||||||
|
|
||||||
public class RestWatchServiceAction extends WatcherRestHandler {
|
public class RestWatchServiceAction extends WatcherRestHandler {
|
||||||
|
|
||||||
|
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestWatchServiceAction.class));
|
||||||
|
|
||||||
public RestWatchServiceAction(Settings settings, RestController controller) {
|
public RestWatchServiceAction(Settings settings, RestController controller) {
|
||||||
super(settings);
|
super(settings);
|
||||||
controller.registerHandler(POST, URI_BASE + "/_start", this);
|
// TODO: remove deprecated endpoint in 8.0.0
|
||||||
controller.registerHandler(POST, URI_BASE + "/_stop", new StopRestHandler(settings));
|
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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_watcher_start_service_action";
|
return "watcher_start_service";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,7 +51,7 @@ public class RestWatchServiceAction extends WatcherRestHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_watcher_stop_service_action";
|
return "watcher_stop_service";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* or more contributor license agreements. Licensed under the Elastic License;
|
* or more contributor license agreements. Licensed under the Elastic License;
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.elasticsearch.xpack.watcher.rest.action;
|
package org.elasticsearch.xpack.watcher.rest.action;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -29,13 +30,18 @@ public class RestWatcherStatsAction extends WatcherRestHandler {
|
||||||
|
|
||||||
public RestWatcherStatsAction(Settings settings, RestController controller) {
|
public RestWatcherStatsAction(Settings settings, RestController controller) {
|
||||||
super(settings);
|
super(settings);
|
||||||
controller.registerHandler(GET, URI_BASE + "/stats", this);
|
// TODO: remove deprecated endpoint in 8.0.0
|
||||||
controller.registerHandler(GET, URI_BASE + "/stats/{metric}", this);
|
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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "xpack_watcher_stats_action";
|
return "watcher_stats";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
public void testWatcher() throws Exception {
|
public void testWatcher() throws Exception {
|
||||||
if (isRunningAgainstOldCluster()) {
|
if (isRunningAgainstOldCluster()) {
|
||||||
logger.info("Adding a watch on old cluster {}", getOldClusterVersion());
|
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"));
|
createBwcWatch.setJsonEntity(loadWatch("simple-watch.json"));
|
||||||
client().performRequest(createBwcWatch);
|
client().performRequest(createBwcWatch);
|
||||||
|
|
||||||
|
@ -208,10 +208,10 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for watcher to actually start....
|
// Wait for watcher to actually start....
|
||||||
Map<String, Object> startWatchResponse = entityAsMap(client().performRequest(new Request("POST", "_xpack/watcher/_start")));
|
Map<String, Object> startWatchResponse = entityAsMap(client().performRequest(new Request("POST", "_watcher/_start")));
|
||||||
assertThat(startWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE));
|
assertThat(startWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE));
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
Map<String, Object> statsWatchResponse = entityAsMap(client().performRequest(new Request("GET", "_xpack/watcher/stats")));
|
Map<String, Object> statsWatchResponse = entityAsMap(client().performRequest(new Request("GET", "_watcher/stats")));
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Object> states = ((List<Object>) statsWatchResponse.get("stats"))
|
List<Object> states = ((List<Object>) statsWatchResponse.get("stats"))
|
||||||
.stream().map(o -> ((Map<String, Object>) o).get("watcher_state")).collect(Collectors.toList());
|
.stream().map(o -> ((Map<String, Object>) o).get("watcher_state")).collect(Collectors.toList());
|
||||||
|
@ -226,11 +226,11 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
/* Shut down watcher after every test because watcher can be a bit finicky about shutting down when the node shuts
|
/* 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.
|
* 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<String, Object> stopWatchResponse = entityAsMap(client().performRequest(new Request("POST", "_xpack/watcher/_stop")));
|
Map<String, Object> stopWatchResponse = entityAsMap(client().performRequest(new Request("POST", "_watcher/_stop")));
|
||||||
assertThat(stopWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE));
|
assertThat(stopWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE));
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
Map<String, Object> statsStoppedWatchResponse = entityAsMap(client().performRequest(
|
Map<String, Object> statsStoppedWatchResponse = entityAsMap(client().performRequest(
|
||||||
new Request("GET", "_xpack/watcher/stats")));
|
new Request("GET", "_watcher/stats")));
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Object> states = ((List<Object>) statsStoppedWatchResponse.get("stats"))
|
List<Object> states = ((List<Object>) statsStoppedWatchResponse.get("stats"))
|
||||||
.stream().map(o -> ((Map<String, Object>) o).get("watcher_state")).collect(Collectors.toList());
|
.stream().map(o -> ((Map<String, Object>) o).get("watcher_state")).collect(Collectors.toList());
|
||||||
|
@ -462,7 +462,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void assertWatchIndexContentsWork() throws Exception {
|
private void assertWatchIndexContentsWork() throws Exception {
|
||||||
// Fetch a basic watch
|
// Fetch a basic watch
|
||||||
Map<String, Object> bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_xpack/watcher/watch/bwc_watch")));
|
Map<String, Object> bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_watcher/watch/bwc_watch")));
|
||||||
|
|
||||||
logger.error("-----> {}", bwcWatch);
|
logger.error("-----> {}", bwcWatch);
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
assertThat(ObjectPath.eval("actions.index_payload.index.timeout_in_millis", source), equalTo(timeout));
|
assertThat(ObjectPath.eval("actions.index_payload.index.timeout_in_millis", source), equalTo(timeout));
|
||||||
|
|
||||||
// Fetch a watch with "fun" throttle periods
|
// 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));
|
assertThat(bwcWatch.get("found"), equalTo(true));
|
||||||
source = (Map<String, Object>) bwcWatch.get("watch");
|
source = (Map<String, Object>) bwcWatch.get("watch");
|
||||||
assertEquals(timeout, source.get("throttle_period_in_millis"));
|
assertEquals(timeout, source.get("throttle_period_in_millis"));
|
||||||
|
@ -487,7 +487,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
* Fetch a watch with a funny timeout to verify loading fractional time
|
* Fetch a watch with a funny timeout to verify loading fractional time
|
||||||
* values.
|
* 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));
|
assertThat(bwcWatch.get("found"), equalTo(true));
|
||||||
source = (Map<String, Object>) bwcWatch.get("watch");
|
source = (Map<String, Object>) bwcWatch.get("watch");
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
.condition(InternalAlwaysCondition.INSTANCE)
|
.condition(InternalAlwaysCondition.INSTANCE)
|
||||||
.trigger(ScheduleTrigger.builder(new IntervalSchedule(IntervalSchedule.Interval.seconds(1))))
|
.trigger(ScheduleTrigger.builder(new IntervalSchedule(IntervalSchedule.Interval.seconds(1))))
|
||||||
.addAction("awesome", LoggingAction.builder(new TextTemplate("test"))).buildAsBytes(XContentType.JSON).utf8ToString();
|
.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);
|
createWatchRequest.setJsonEntity(watch);
|
||||||
Map<String, Object> createWatch = entityAsMap(client().performRequest(createWatchRequest));
|
Map<String, Object> createWatch = entityAsMap(client().performRequest(createWatchRequest));
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
assertThat(updateWatch.get("created"), equalTo(false));
|
assertThat(updateWatch.get("created"), equalTo(false));
|
||||||
assertThat(updateWatch.get("_version"), equalTo(2));
|
assertThat(updateWatch.get("_version"), equalTo(2));
|
||||||
|
|
||||||
Map<String, Object> get = entityAsMap(client().performRequest(new Request("GET", "_xpack/watcher/watch/new_watch")));
|
Map<String, Object> get = entityAsMap(client().performRequest(new Request("GET", "_watcher/watch/new_watch")));
|
||||||
assertThat(get.get("found"), equalTo(true));
|
assertThat(get.get("found"), equalTo(true));
|
||||||
@SuppressWarnings("unchecked") Map<?, ?> source = (Map<String, Object>) get.get("watch");
|
@SuppressWarnings("unchecked") Map<?, ?> source = (Map<String, Object>) get.get("watch");
|
||||||
Map<String, Object> logging = ObjectPath.eval("actions.awesome.logging", source);
|
Map<String, Object> logging = ObjectPath.eval("actions.awesome.logging", source);
|
||||||
|
|
|
@ -17,16 +17,16 @@ import static org.hamcrest.Matchers.not;
|
||||||
public class WatcherRestartIT extends AbstractUpgradeTestCase {
|
public class WatcherRestartIT extends AbstractUpgradeTestCase {
|
||||||
|
|
||||||
public void testWatcherRestart() throws Exception {
|
public void testWatcherRestart() throws Exception {
|
||||||
client().performRequest(new Request("POST", "/_xpack/watcher/_stop"));
|
client().performRequest(new Request("POST", "/_watcher/_stop"));
|
||||||
ensureWatcherStopped();
|
ensureWatcherStopped();
|
||||||
|
|
||||||
client().performRequest(new Request("POST", "/_xpack/watcher/_start"));
|
client().performRequest(new Request("POST", "/_watcher/_start"));
|
||||||
ensureWatcherStarted();
|
ensureWatcherStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureWatcherStopped() throws Exception {
|
private void ensureWatcherStopped() throws Exception {
|
||||||
assertBusy(() -> {
|
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);
|
String responseBody = EntityUtils.toString(stats.getEntity(), StandardCharsets.UTF_8);
|
||||||
assertThat(responseBody, containsString("\"watcher_state\":\"stopped\""));
|
assertThat(responseBody, containsString("\"watcher_state\":\"stopped\""));
|
||||||
assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\"")));
|
assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\"")));
|
||||||
|
@ -37,7 +37,7 @@ public class WatcherRestartIT extends AbstractUpgradeTestCase {
|
||||||
|
|
||||||
private void ensureWatcherStarted() throws Exception {
|
private void ensureWatcherStarted() throws Exception {
|
||||||
assertBusy(() -> {
|
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);
|
String responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||||
assertThat(responseBody, containsString("\"watcher_state\":\"started\""));
|
assertThat(responseBody, containsString("\"watcher_state\":\"started\""));
|
||||||
assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\"")));
|
assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\"")));
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class MonitoringWithWatcherRestIT extends ESRestTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertMonitoringWatchHasBeenOverWritten(String watchId) 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");
|
String interval = path.evaluate("watch.trigger.schedule.interval");
|
||||||
assertThat(interval, is("1m"));
|
assertThat(interval, is("1m"));
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class MonitoringWithWatcherRestIT extends ESRestTestCase {
|
||||||
private String createMonitoringWatch() throws Exception {
|
private String createMonitoringWatch() throws Exception {
|
||||||
String clusterUUID = getClusterUUID();
|
String clusterUUID = getClusterUUID();
|
||||||
String watchId = clusterUUID + "_kibana_version_mismatch";
|
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()
|
request.setJsonEntity(WatchSourceBuilders.watchBuilder()
|
||||||
.trigger(TriggerBuilders.schedule(new IntervalSchedule(new IntervalSchedule.Interval(1000, MINUTES))))
|
.trigger(TriggerBuilders.schedule(new IntervalSchedule(new IntervalSchedule.Interval(1000, MINUTES))))
|
||||||
.input(simpleInput())
|
.input(simpleInput())
|
||||||
|
|
|
@ -57,13 +57,13 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase {
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
try {
|
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);
|
ObjectPath objectPath = ObjectPath.createFromResponse(statsResponse);
|
||||||
String state = objectPath.evaluate("stats.0.watcher_state");
|
String state = objectPath.evaluate("stats.0.watcher_state");
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case "stopped":
|
case "stopped":
|
||||||
Response startResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_start"));
|
Response startResponse = adminClient().performRequest(new Request("POST", "/_watcher/_start"));
|
||||||
Map<String, Object> responseMap = entityAsMap(startResponse);
|
Map<String, Object> responseMap = entityAsMap(startResponse);
|
||||||
assertThat(responseMap, hasEntry("acknowledged", true));
|
assertThat(responseMap, hasEntry("acknowledged", true));
|
||||||
throw new AssertionError("waiting until stopped state reached started state");
|
throw new AssertionError("waiting until stopped state reached started state");
|
||||||
|
@ -95,7 +95,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase {
|
||||||
|
|
||||||
assertBusy(() -> {
|
assertBusy(() -> {
|
||||||
try {
|
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);
|
ObjectPath objectPath = ObjectPath.createFromResponse(statsResponse);
|
||||||
String state = objectPath.evaluate("stats.0.watcher_state");
|
String state = objectPath.evaluate("stats.0.watcher_state");
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase {
|
||||||
case "starting":
|
case "starting":
|
||||||
throw new AssertionError("waiting until starting state reached started state to stop");
|
throw new AssertionError("waiting until starting state reached started state to stop");
|
||||||
case "started":
|
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());
|
String body = EntityUtils.toString(stopResponse.getEntity());
|
||||||
assertThat(body, containsString("\"acknowledged\":true"));
|
assertThat(body, containsString("\"acknowledged\":true"));
|
||||||
throw new AssertionError("waiting until started state reached stopped state");
|
throw new AssertionError("waiting until started state reached stopped state");
|
||||||
|
@ -291,7 +291,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void indexWatch(String watchId, XContentBuilder builder) 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));
|
request.setJsonEntity(Strings.toString(builder));
|
||||||
Response response = client().performRequest(request);
|
Response response = client().performRequest(request);
|
||||||
Map<String, Object> responseMap = entityAsMap(response);
|
Map<String, Object> responseMap = entityAsMap(response);
|
||||||
|
|
|
@ -41,12 +41,12 @@ public class SmokeTestWatcherTestSuiteIT extends ESRestTestCase {
|
||||||
assertOK(adminClient().performRequest(new Request("DELETE", "/.watcher-history-*")));
|
assertOK(adminClient().performRequest(new Request("DELETE", "/.watcher-history-*")));
|
||||||
|
|
||||||
assertBusy(() -> {
|
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");
|
String state = ObjectPath.createFromResponse(response).evaluate("stats.0.watcher_state");
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case "stopped":
|
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");
|
boolean isAcknowledged = ObjectPath.createFromResponse(startResponse).evaluate("acknowledged");
|
||||||
assertThat(isAcknowledged, is(true));
|
assertThat(isAcknowledged, is(true));
|
||||||
throw new AssertionError("waiting until stopped state reached started state");
|
throw new AssertionError("waiting until stopped state reached started state");
|
||||||
|
@ -73,7 +73,7 @@ public class SmokeTestWatcherTestSuiteIT extends ESRestTestCase {
|
||||||
@After
|
@After
|
||||||
public void stopWatcher() throws Exception {
|
public void stopWatcher() throws Exception {
|
||||||
assertBusy(() -> {
|
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");
|
String state = ObjectPath.createFromResponse(response).evaluate("stats.0.watcher_state");
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -85,7 +85,7 @@ public class SmokeTestWatcherTestSuiteIT extends ESRestTestCase {
|
||||||
case "starting":
|
case "starting":
|
||||||
throw new AssertionError("waiting until starting state reached started state to stop");
|
throw new AssertionError("waiting until starting state reached started state to stop");
|
||||||
case "started":
|
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");
|
boolean isAcknowledged = ObjectPath.createFromResponse(stopResponse).evaluate("acknowledged");
|
||||||
assertThat(isAcknowledged, is(true));
|
assertThat(isAcknowledged, is(true));
|
||||||
throw new AssertionError("waiting until started state reached stopped state");
|
throw new AssertionError("waiting until started state reached stopped state");
|
||||||
|
@ -163,7 +163,7 @@ public class SmokeTestWatcherTestSuiteIT extends ESRestTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void indexWatch(String watchId, XContentBuilder builder) 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));
|
request.setJsonEntity(Strings.toString(builder));
|
||||||
Response response = client().performRequest(request);
|
Response response = client().performRequest(request);
|
||||||
Map<String, Object> responseMap = entityAsMap(response);
|
Map<String, Object> responseMap = entityAsMap(response);
|
||||||
|
@ -171,7 +171,7 @@ public class SmokeTestWatcherTestSuiteIT extends ESRestTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteWatch(String watchId) throws IOException {
|
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);
|
assertOK(response);
|
||||||
ObjectPath path = ObjectPath.createFromResponse(response);
|
ObjectPath path = ObjectPath.createFromResponse(response);
|
||||||
boolean found = path.evaluate("found");
|
boolean found = path.evaluate("found");
|
||||||
|
@ -209,7 +209,7 @@ public class SmokeTestWatcherTestSuiteIT extends ESRestTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertWatchCount(int expectedWatches) throws IOException {
|
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);
|
ObjectPath objectPath = ObjectPath.createFromResponse(watcherStatsResponse);
|
||||||
int watchCount = objectPath.evaluate("stats.0.watch_count");
|
int watchCount = objectPath.evaluate("stats.0.watch_count");
|
||||||
assertThat(watchCount, is(expectedWatches));
|
assertThat(watchCount, is(expectedWatches));
|
||||||
|
|
Loading…
Reference in New Issue