Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate X-Pack centric watcher endpoints #36218

Merged
merged 8 commits into from
Dec 8, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ private WatcherRequestConverters() {}

static Request startWatchService(StartWatchServiceRequest startWatchServiceRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_xpack")
.addPathPartAsIs("watcher")
.addPathPartAsIs("_watcher")
.addPathPartAsIs("_start")
.build();

Expand All @@ -52,8 +51,7 @@ static Request startWatchService(StartWatchServiceRequest startWatchServiceReque

static Request stopWatchService(StopWatchServiceRequest stopWatchServiceRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_xpack")
.addPathPartAsIs("watcher")
.addPathPartAsIs("_watcher")
.addPathPartAsIs("_stop")
.build();

Expand All @@ -62,7 +60,7 @@ static Request stopWatchService(StopWatchServiceRequest stopWatchServiceRequest)

static Request putWatch(PutWatchRequest putWatchRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_xpack", "watcher", "watch")
.addPathPartAsIs("_watcher", "watch")
.addPathPart(putWatchRequest.getId())
.build();

Expand All @@ -80,7 +78,7 @@ static Request putWatch(PutWatchRequest putWatchRequest) {

static Request getWatch(GetWatchRequest getWatchRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_xpack", "watcher", "watch")
.addPathPartAsIs("_watcher", "watch")
.addPathPart(getWatchRequest.getId())
.build();

Expand All @@ -89,8 +87,7 @@ static Request getWatch(GetWatchRequest getWatchRequest) {

static Request deactivateWatch(DeactivateWatchRequest deactivateWatchRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_xpack")
.addPathPartAsIs("watcher")
.addPathPartAsIs("_watcher")
.addPathPartAsIs("watch")
.addPathPart(deactivateWatchRequest.getWatchId())
.addPathPartAsIs("_deactivate")
Expand All @@ -100,7 +97,7 @@ static Request deactivateWatch(DeactivateWatchRequest deactivateWatchRequest) {

static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_xpack", "watcher", "watch")
.addPathPartAsIs("_watcher", "watch")
.addPathPart(deleteWatchRequest.getId())
.build();

Expand All @@ -110,7 +107,7 @@ static Request deleteWatch(DeleteWatchRequest deleteWatchRequest) {

public static Request ackWatch(AckWatchRequest ackWatchRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_xpack", "watcher", "watch")
.addPathPartAsIs("_watcher", "watch")
.addPathPart(ackWatchRequest.getWatchId())
.addPathPartAsIs("_ack")
.addCommaSeparatedPathParts(ackWatchRequest.getActionIds())
Expand All @@ -121,7 +118,7 @@ public static Request ackWatch(AckWatchRequest ackWatchRequest) {

static Request activateWatch(ActivateWatchRequest activateWatchRequest) {
String endpoint = new RequestConverters.EndpointBuilder()
.addPathPartAsIs("_xpack", "watcher", "watch")
.addPathPartAsIs("_watcher", "watch")
.addPathPart(activateWatchRequest.getWatchId())
.addPathPartAsIs("_activate")
.build();
Expand All @@ -130,7 +127,7 @@ static Request activateWatch(ActivateWatchRequest activateWatchRequest) {
}

static Request watcherStats(WatcherStatsRequest watcherStatsRequest) {
RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder().addPathPartAsIs("_xpack", "watcher", "stats");
RequestConverters.EndpointBuilder builder = new RequestConverters.EndpointBuilder().addPathPartAsIs("_watcher", "stats");
String endpoint = builder.build();
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
RequestConverters.Params parameters = new RequestConverters.Params(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void testAckWatch() throws Exception {
assertEquals(AckStatus.State.AWAITS_SUCCESSFUL_EXECUTION, actionStatus.ackStatus().state());

// TODO: use the high-level REST client here once it supports 'execute watch'.
Request executeWatchRequest = new Request("POST", "_xpack/watcher/watch/" + watchId + "/_execute");
Request executeWatchRequest = new Request("POST", "_watcher/watch/" + watchId + "/_execute");
executeWatchRequest.setJsonEntity("{ \"record_execution\": true }");
Response executeResponse = client().performRequest(executeWatchRequest);
assertEquals(RestStatus.OK.getStatus(), executeResponse.getStatusLine().getStatusCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public class WatcherRequestConvertersTests extends ESTestCase {
public void testStartWatchService() {
Request request = WatcherRequestConverters.startWatchService(new StartWatchServiceRequest());
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
assertEquals("/_xpack/watcher/_start", request.getEndpoint());
assertEquals("/_watcher/_start", request.getEndpoint());
}

public void testStopWatchService() {
Request request = WatcherRequestConverters.stopWatchService(new StopWatchServiceRequest());
assertEquals(HttpPost.METHOD_NAME, request.getMethod());
assertEquals("/_xpack/watcher/_stop", request.getEndpoint());
assertEquals("/_watcher/_stop", request.getEndpoint());
}

public void testPutWatch() throws Exception {
Expand All @@ -84,7 +84,7 @@ public void testPutWatch() throws Exception {

Request request = WatcherRequestConverters.putWatch(putWatchRequest);
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint());
assertEquals("/_watcher/watch/" + watchId, request.getEndpoint());
assertEquals(expectedParams, request.getParameters());
assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters()));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Expand All @@ -98,7 +98,7 @@ public void testGetWatch() throws Exception {

Request request = WatcherRequestConverters.getWatch(getWatchRequest);
assertEquals(HttpGet.METHOD_NAME, request.getMethod());
assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint());
assertEquals("/_watcher/watch/" + watchId, request.getEndpoint());
assertThat(request.getEntity(), nullValue());
}

Expand All @@ -108,7 +108,7 @@ public void testDeactivateWatch() {
Request request = WatcherRequestConverters.deactivateWatch(deactivateWatchRequest);

assertEquals(HttpPut.METHOD_NAME, request.getMethod());
assertEquals("/_xpack/watcher/watch/" + watchId + "/_deactivate", request.getEndpoint());
assertEquals("/_watcher/watch/" + watchId + "/_deactivate", request.getEndpoint());
}

public void testDeleteWatch() {
Expand All @@ -117,7 +117,7 @@ public void testDeleteWatch() {

Request request = WatcherRequestConverters.deleteWatch(deleteWatchRequest);
assertEquals(HttpDelete.METHOD_NAME, request.getMethod());
assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint());
assertEquals("/_watcher/watch/" + watchId, request.getEndpoint());
assertThat(request.getEntity(), nullValue());
}

Expand All @@ -131,7 +131,7 @@ public void testAckWatch() {
assertEquals(HttpPut.METHOD_NAME, request.getMethod());

StringJoiner expectedEndpoint = new StringJoiner("/", "/", "")
.add("_xpack").add("watcher").add("watch").add(watchId).add("_ack");
.add("_watcher").add("watch").add(watchId).add("_ack");
if (ackWatchRequest.getActionIds().length > 0) {
String actionsParam = String.join(",", ackWatchRequest.getActionIds());
expectedEndpoint.add(actionsParam);
Expand All @@ -147,7 +147,7 @@ public void testActivateWatchRequestConversion() {

Request request = WatcherRequestConverters.activateWatch(activateWatchRequest);
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
assertEquals("/_xpack/watcher/watch/" + watchId + "/_activate", request.getEndpoint());
assertEquals("/_watcher/watch/" + watchId + "/_activate", request.getEndpoint());
assertThat(request.getEntity(), nullValue());
}

Expand All @@ -158,7 +158,7 @@ public void testWatcherStatsRequest() {
WatcherStatsRequest watcherStatsRequest = new WatcherStatsRequest(includeCurrent, includeQueued);

Request request = WatcherRequestConverters.watcherStats(watcherStatsRequest);
assertThat(request.getEndpoint(), equalTo("/_xpack/watcher/stats"));
assertThat(request.getEndpoint(), equalTo("/_watcher/stats"));
assertThat(request.getMethod(), equalTo(HttpGet.METHOD_NAME));
if (includeCurrent || includeQueued) {
assertThat(request.getParameters(), hasKey("metric"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public void testAckWatch() throws Exception {
client.watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT);

// TODO: use the high-level REST client here once it supports 'execute watch'.
Request executeWatchRequest = new Request("POST", "_xpack/watcher/watch/my_watch_id/_execute");
Request executeWatchRequest = new Request("POST", "_watcher/watch/my_watch_id/_execute");
executeWatchRequest.setJsonEntity("{ \"record_execution\": true }");
Response executeResponse = client().performRequest(executeWatchRequest);
assertEquals(RestStatus.OK.getStatus(), executeResponse.getStatusLine().getStatusCode());
Expand Down
22 changes: 11 additions & 11 deletions x-pack/docs/en/rest-api/watcher/ack-watch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ execution.
[float]
==== 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]
==== Path Parameters
Expand All @@ -42,7 +42,7 @@ To demonstrate let's create a new watch:

[source,js]
--------------------------------------------------
PUT _xpack/watcher/watch/my_watch
PUT _watcher/watch/my_watch
{
"trigger": {
"schedule": {
Expand Down Expand Up @@ -80,7 +80,7 @@ watch definition when you call the <<watcher-api-get-watch, Get Watch API>>:

[source,js]
--------------------------------------------------
GET _xpack/watcher/watch/my_watch
GET _watcher/watch/my_watch
--------------------------------------------------
// CONSOLE

Expand Down Expand Up @@ -117,12 +117,12 @@ check the status:

[source,js]
--------------------------------------------------
POST _xpack/watcher/watch/my_watch/_execute
POST _watcher/watch/my_watch/_execute
{
"record_execution" : true
}

GET _xpack/watcher/watch/my_watch
GET _watcher/watch/my_watch
--------------------------------------------------
// CONSOLE
// TEST[continued]
Expand Down Expand Up @@ -172,8 +172,8 @@ Now we can acknowledge it:

[source,js]
--------------------------------------------------
PUT _xpack/watcher/watch/my_watch/_ack/test_index
GET _xpack/watcher/watch/my_watch
PUT _watcher/watch/my_watch/_ack/test_index
GET _watcher/watch/my_watch
--------------------------------------------------
// CONSOLE
// TEST[continued]
Expand Down Expand Up @@ -226,7 +226,7 @@ comma-separated list of action ids:

[source,js]
--------------------------------------------------
POST _xpack/watcher/watch/my_watch/_ack/action1,action2
POST _watcher/watch/my_watch/_ack/action1,action2
--------------------------------------------------
// CONSOLE

Expand All @@ -235,9 +235,9 @@ parameter:

[source,js]
--------------------------------------------------
POST _xpack/watcher/watch/my_watch/_ack
POST _watcher/watch/my_watch/_ack
--------------------------------------------------
// TEST[s/^/POST _xpack\/watcher\/watch\/my_watch\/_execute\n{ "record_execution" : true }\n/]
// TEST[s/^/POST _watcher\/watch\/my_watch\/_execute\n{ "record_execution" : true }\n/]
// CONSOLE


Expand Down
6 changes: 3 additions & 3 deletions x-pack/docs/en/rest-api/watcher/activate-watch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ API enables you to activate a currently inactive watch.
[float]
==== Request

`PUT _xpack/watcher/watch/<watch_id>/_activate`
`PUT _watcher/watch/<watch_id>/_activate`

[float]
==== Path Parameters
Expand All @@ -31,7 +31,7 @@ call the <<watcher-api-get-watch, Get Watch API>>:

[source,js]
--------------------------------------------------
GET _xpack/watcher/watch/my_watch
GET _watcher/watch/my_watch
--------------------------------------------------
// CONSOLE
// TEST[setup:my_inactive_watch]
Expand Down Expand Up @@ -62,7 +62,7 @@ You can activate the watch by executing the following API call:

[source,js]
--------------------------------------------------
PUT _xpack/watcher/watch/my_watch/_activate
PUT _watcher/watch/my_watch/_activate
--------------------------------------------------
// CONSOLE
// TEST[setup:my_inactive_watch]
Expand Down
6 changes: 3 additions & 3 deletions x-pack/docs/en/rest-api/watcher/deactivate-watch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ API enables you to deactivate a currently active watch.
[float]
==== Request

`PUT _xpack/watcher/watch/<watch_id>/_deactivate`
`PUT _watcher/watch/<watch_id>/_deactivate`

[float]
==== Path Parameters
Expand All @@ -30,7 +30,7 @@ call the <<watcher-api-get-watch, Get Watch API>>:

[source,js]
--------------------------------------------------
GET _xpack/watcher/watch/my_watch
GET _watcher/watch/my_watch
--------------------------------------------------
// CONSOLE
// TEST[setup:my_active_watch]
Expand Down Expand Up @@ -61,7 +61,7 @@ You can deactivate the watch by executing the following API call:

[source,js]
--------------------------------------------------
PUT _xpack/watcher/watch/my_watch/_deactivate
PUT _watcher/watch/my_watch/_deactivate
--------------------------------------------------
// CONSOLE
// TEST[setup:my_active_watch]
Expand Down
4 changes: 2 additions & 2 deletions x-pack/docs/en/rest-api/watcher/delete-watch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The DELETE watch API removes a watch from {watcher}.
[float]
==== Request

`DELETE _xpack/watcher/watch/<watch_id>`
`DELETE _watcher/watch/<watch_id>`

[float]
==== Description
Expand Down Expand Up @@ -42,7 +42,7 @@ The following example deletes a watch with the `my-watch` id:

[source,js]
--------------------------------------------------
DELETE _xpack/watcher/watch/my_watch
DELETE _watcher/watch/my_watch
--------------------------------------------------
// CONSOLE
// TEST[setup:my_active_watch]
Expand Down
16 changes: 8 additions & 8 deletions x-pack/docs/en/rest-api/watcher/execute-watch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ watch execution for debugging purposes.
[float]
==== Request

`POST _xpack/watcher/watch/<watch_id>/_execute` +
`POST _watcher/watch/<watch_id>/_execute` +

`POST _xpack/watcher/watch/_execute`
`POST _watcher/watch/_execute`

[float]
==== Description
Expand Down Expand Up @@ -137,7 +137,7 @@ The following example executes the `my_watch` watch:

[source,js]
--------------------------------------------------
POST _xpack/watcher/watch/my_watch/_execute
POST _watcher/watch/my_watch/_execute
--------------------------------------------------
// CONSOLE
// TEST[setup:my_active_watch]
Expand All @@ -146,7 +146,7 @@ The following example shows a comprehensive example of executing the `my-watch`

[source,js]
--------------------------------------------------
POST _xpack/watcher/watch/my_watch/_execute
POST _watcher/watch/my_watch/_execute
{
"trigger_data" : { <1>
"triggered_time" : "now",
Expand Down Expand Up @@ -289,7 +289,7 @@ name with the action id:

[source,js]
--------------------------------------------------
POST _xpack/watcher/watch/my_watch/_execute
POST _watcher/watch/my_watch/_execute
{
"action_modes" : {
"action1" : "force_simulate",
Expand All @@ -305,7 +305,7 @@ using `_all` as the action id:

[source,js]
--------------------------------------------------
POST _xpack/watcher/watch/my_watch/_execute
POST _watcher/watch/my_watch/_execute
{
"action_modes" : {
"_all" : "force_execute"
Expand All @@ -319,7 +319,7 @@ The following example shows how to execute a watch inline:

[source,js]
--------------------------------------------------
POST _xpack/watcher/watch/_execute
POST _watcher/watch/_execute
{
"watch" : {
"trigger" : { "schedule" : { "interval" : "10s" } },
Expand Down Expand Up @@ -356,7 +356,7 @@ during the execution this condition will be ignored:

[source,js]
--------------------------------------------------
POST _xpack/watcher/watch/_execute
POST _watcher/watch/_execute
{
"ignore_condition" : true,
"watch" : {
Expand Down
Loading