From e57d62c0ba050ee74ae5ff144a6246aaddc3dc0f Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Wed, 5 Dec 2018 09:41:43 -0600 Subject: [PATCH 1/2] Undeprecate /_watcher endpoints We deprecated these awhile ago in favor of /_xpack/watcher endpoints. Yet, this is no longer the direction that we want to go in, instead we want to remove the /_xpack namespace. This commit undeprecates the /_watcher endpoint. --- .../watcher/rest/action/RestAckWatchAction.java | 16 ++++++++-------- .../rest/action/RestActivateWatchAction.java | 16 ++++++++-------- .../rest/action/RestDeleteWatchAction.java | 4 ++-- .../rest/action/RestExecuteWatchAction.java | 16 ++++++++-------- .../watcher/rest/action/RestGetWatchAction.java | 4 ++-- .../watcher/rest/action/RestPutWatchAction.java | 8 ++++---- .../rest/action/RestWatchServiceAction.java | 9 +++++++-- .../rest/action/RestWatcherStatsAction.java | 8 ++++---- 8 files changed, 43 insertions(+), 38 deletions(-) diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java index 491d3ca9077bc..26898a6aa9a3b 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java @@ -38,14 +38,14 @@ public class RestAckWatchAction extends WatcherRestHandler { public RestAckWatchAction(Settings settings, RestController controller) { super(settings); // @deprecated Remove deprecations in 6.0 - controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_ack", this, - POST, "/_watcher/watch/{id}/_ack", deprecationLogger); - controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}/_ack", this, - PUT, "/_watcher/watch/{id}/_ack", deprecationLogger); - controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_ack/{actions}", this, - POST, "/_watcher/watch/{id}/_ack/{actions}", deprecationLogger); - controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}/_ack/{actions}", this, - PUT, "/_watcher/watch/{id}/_ack/{actions}", deprecationLogger); + controller.registerHandler(POST, URI_BASE + "/watch/{id}/_ack", this); + controller.registerHandler(POST, "/_watcher/watch/{id}/_ack", this); + controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_ack", this); + controller.registerHandler(PUT, "/_watcher/watch/{id}/_ack", this); + controller.registerHandler(POST, URI_BASE + "/watch/{id}/_ack/{actions}", this); + controller.registerHandler(POST, "/_watcher/watch/{id}/_ack/{actions}", this); + controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_ack/{actions}", this); + controller.registerHandler(PUT, "/_watcher/watch/{id}/_ack/{actions}", this); // @deprecated The following can be totally dropped in 6.0 // Note: we deprecated "/{actions}/_ack" totally; so we don't replace it with a matching _xpack variant diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java index 5afd0976eb9a5..3f1ace469f56f 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java @@ -41,14 +41,14 @@ public RestActivateWatchAction(Settings settings, RestController controller) { final DeactivateRestHandler deactivateRestHandler = new DeactivateRestHandler(settings); // @deprecated Remove deprecations in 6.0 - controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_activate", this, - POST, "/_watcher/watch/{id}/_activate", deprecationLogger); - controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}/_activate", this, - PUT, "/_watcher/watch/{id}/_activate", deprecationLogger); - controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler, - POST, "/_watcher/watch/{id}/_deactivate", deprecationLogger); - controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler, - PUT, "/_watcher/watch/{id}/_deactivate", deprecationLogger); + controller.registerHandler(POST, URI_BASE + "/watch/{id}/_activate", this); + controller.registerHandler(POST, "/_watcher/watch/{id}/_activate", this); + controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_activate", this); + controller.registerHandler(PUT, "/_watcher/watch/{id}/_activate", this); + controller.registerHandler(POST, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler); + controller.registerHandler(POST, "/_watcher/watch/{id}/_deactivate", deactivateRestHandler); + controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_deactivate", deactivateRestHandler); + controller.registerHandler(PUT, "/_watcher/watch/{id}/_deactivate", deactivateRestHandler); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java index f087f24791414..6c880fdb6a85d 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java @@ -34,8 +34,8 @@ public class RestDeleteWatchAction extends WatcherRestHandler { public RestDeleteWatchAction(Settings settings, RestController controller) { super(settings); // @deprecated Remove deprecations in 6.0 - controller.registerWithDeprecatedHandler(DELETE, URI_BASE + "/watch/{id}", this, - DELETE, "/_watcher/watch/{id}", deprecationLogger); + controller.registerHandler(DELETE, URI_BASE + "/watch/{id}", this); + controller.registerHandler(DELETE, "/_watcher/watch/{id}", this); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java index f32d62cd2b128..4894975a333ef 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java @@ -57,14 +57,14 @@ public RestExecuteWatchAction(Settings settings, RestController controller) { super(settings); // @deprecated Remove deprecations in 6.0 - controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}/_execute", this, - POST, "/_watcher/watch/{id}/_execute", deprecationLogger); - controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}/_execute", this, - PUT, "/_watcher/watch/{id}/_execute", deprecationLogger); - controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/_execute", this, - POST, "/_watcher/watch/_execute", deprecationLogger); - controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/_execute", this, - PUT, "/_watcher/watch/_execute", deprecationLogger); + controller.registerHandler(POST, URI_BASE + "/watch/{id}/_execute", this); + controller.registerHandler(POST, "/_watcher/watch/{id}/_execute", this); + controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_execute", this); + controller.registerHandler(PUT, "/_watcher/watch/{id}/_execute", this); + controller.registerHandler(POST, URI_BASE + "/watch/_execute", this); + controller.registerHandler(POST, "/_watcher/watch/_execute", this); + controller.registerHandler(PUT, URI_BASE + "/watch/_execute", this); + controller.registerHandler(PUT, "/_watcher/watch/_execute", this); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java index a50096c713933..336d0df34c22a 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java @@ -35,8 +35,8 @@ public RestGetWatchAction(Settings settings, RestController controller) { super(settings); // @deprecated Remove deprecations in 6.0 - controller.registerWithDeprecatedHandler(GET, URI_BASE + "/watch/{id}", this, - GET, "/_watcher/watch/{id}", deprecationLogger); + controller.registerHandler(GET, URI_BASE + "/watch/{id}", this); + controller.registerHandler(GET, "/_watcher/watch/{id}", this); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java index 814c8aed962b1..4cee8600bb3ff 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java @@ -41,10 +41,10 @@ public RestPutWatchAction(Settings settings, RestController controller) { super(settings); // @deprecated Remove deprecations in 6.0 - controller.registerWithDeprecatedHandler(POST, URI_BASE + "/watch/{id}", this, - POST, "/_watcher/watch/{id}", deprecationLogger); - controller.registerWithDeprecatedHandler(PUT, URI_BASE + "/watch/{id}", this, - PUT, "/_watcher/watch/{id}", deprecationLogger); + controller.registerHandler(POST, URI_BASE + "/watch/{id}", this); + controller.registerHandler(POST, "/_watcher/watch/{id}", this); + controller.registerHandler(PUT, URI_BASE + "/watch/{id}", this); + controller.registerHandler(PUT, "/_watcher/watch/{id}", this); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java index ce30cb7a43c93..938717a56979a 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java @@ -30,12 +30,17 @@ public RestWatchServiceAction(Settings settings, RestController controller) { // @deprecated Remove in 6.0 // NOTE: we switched from PUT in 2.x to POST in 5.x + // NOTE: We added back the old URL with the new VERB (POST) since we are deprecating _xpack/* URIs in 7.0 controller.registerWithDeprecatedHandler(POST, URI_BASE + "/_restart", this, PUT, "/_watcher/_restart", deprecationLogger); + StartRestHandler startRestHandler = new StartRestHandler(settings); controller.registerWithDeprecatedHandler(POST, URI_BASE + "/_start", - new StartRestHandler(settings), PUT, "/_watcher/_start", deprecationLogger); + startRestHandler, PUT, "/_watcher/_start", deprecationLogger); + controller.registerHandler(POST, "/_watcher/_start", startRestHandler); + StopRestHandler stopRestHandler = new StopRestHandler(settings); controller.registerWithDeprecatedHandler(POST, URI_BASE + "/_stop", - new StopRestHandler(settings), PUT, "/_watcher/_stop", deprecationLogger); + stopRestHandler, PUT, "/_watcher/_stop", deprecationLogger); + controller.registerHandler(POST, "/_watcher/_stop", stopRestHandler); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java index dd84dcb1d086b..d7a7879f7e38d 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java @@ -31,10 +31,10 @@ public RestWatcherStatsAction(Settings settings, RestController controller) { super(settings); // @deprecated Remove deprecations in 6.0 - controller.registerWithDeprecatedHandler(GET, URI_BASE + "/stats", this, - GET, "/_watcher/stats", deprecationLogger); - controller.registerWithDeprecatedHandler(GET, URI_BASE + "/stats/{metric}", this, - GET, "/_watcher/stats/{metric}", deprecationLogger); + controller.registerHandler(GET, URI_BASE + "/stats", this); + controller.registerHandler(GET, "/_watcher/stats", this); + controller.registerHandler(GET, URI_BASE + "/stats/{metric}", this); + controller.registerHandler(GET, "/_watcher/stats/{metric}", this); } @Override From 70e7e17465efc87e196ac86ffe23694976b6b078 Mon Sep 17 00:00:00 2001 From: Michael Basnight Date: Fri, 7 Dec 2018 11:53:12 -0600 Subject: [PATCH 2/2] Cleanup comments --- .../xpack/watcher/rest/action/RestAckWatchAction.java | 2 +- .../xpack/watcher/rest/action/RestActivateWatchAction.java | 1 - .../xpack/watcher/rest/action/RestDeleteWatchAction.java | 2 +- .../xpack/watcher/rest/action/RestExecuteWatchAction.java | 1 - .../xpack/watcher/rest/action/RestGetWatchAction.java | 1 - .../xpack/watcher/rest/action/RestPutWatchAction.java | 1 - .../xpack/watcher/rest/action/RestWatchServiceAction.java | 1 - .../xpack/watcher/rest/action/RestWatcherStatsAction.java | 1 - 8 files changed, 2 insertions(+), 8 deletions(-) diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java index 26898a6aa9a3b..2384e321c523c 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestAckWatchAction.java @@ -37,7 +37,7 @@ public class RestAckWatchAction extends WatcherRestHandler { public RestAckWatchAction(Settings settings, RestController controller) { super(settings); - // @deprecated Remove deprecations in 6.0 + controller.registerHandler(POST, URI_BASE + "/watch/{id}/_ack", this); controller.registerHandler(POST, "/_watcher/watch/{id}/_ack", this); controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_ack", this); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java index 3f1ace469f56f..027398f2664f8 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestActivateWatchAction.java @@ -40,7 +40,6 @@ public RestActivateWatchAction(Settings settings, RestController controller) { final DeactivateRestHandler deactivateRestHandler = new DeactivateRestHandler(settings); - // @deprecated Remove deprecations in 6.0 controller.registerHandler(POST, URI_BASE + "/watch/{id}/_activate", this); controller.registerHandler(POST, "/_watcher/watch/{id}/_activate", this); controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_activate", this); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java index 6c880fdb6a85d..05abdba4f5068 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestDeleteWatchAction.java @@ -33,7 +33,7 @@ public class RestDeleteWatchAction extends WatcherRestHandler { public RestDeleteWatchAction(Settings settings, RestController controller) { super(settings); - // @deprecated Remove deprecations in 6.0 + controller.registerHandler(DELETE, URI_BASE + "/watch/{id}", this); controller.registerHandler(DELETE, "/_watcher/watch/{id}", this); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java index 4894975a333ef..a198eb458b18f 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestExecuteWatchAction.java @@ -56,7 +56,6 @@ public class RestExecuteWatchAction extends WatcherRestHandler implements RestRe public RestExecuteWatchAction(Settings settings, RestController controller) { super(settings); - // @deprecated Remove deprecations in 6.0 controller.registerHandler(POST, URI_BASE + "/watch/{id}/_execute", this); controller.registerHandler(POST, "/_watcher/watch/{id}/_execute", this); controller.registerHandler(PUT, URI_BASE + "/watch/{id}/_execute", this); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java index 336d0df34c22a..c0e4b325fb384 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestGetWatchAction.java @@ -34,7 +34,6 @@ public class RestGetWatchAction extends WatcherRestHandler { public RestGetWatchAction(Settings settings, RestController controller) { super(settings); - // @deprecated Remove deprecations in 6.0 controller.registerHandler(GET, URI_BASE + "/watch/{id}", this); controller.registerHandler(GET, "/_watcher/watch/{id}", this); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java index 4cee8600bb3ff..409298daecdf3 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestPutWatchAction.java @@ -40,7 +40,6 @@ public class RestPutWatchAction extends WatcherRestHandler implements RestReques public RestPutWatchAction(Settings settings, RestController controller) { super(settings); - // @deprecated Remove deprecations in 6.0 controller.registerHandler(POST, URI_BASE + "/watch/{id}", this); controller.registerHandler(POST, "/_watcher/watch/{id}", this); controller.registerHandler(PUT, URI_BASE + "/watch/{id}", this); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java index 938717a56979a..483d10cba3e3a 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatchServiceAction.java @@ -28,7 +28,6 @@ public class RestWatchServiceAction extends WatcherRestHandler { public RestWatchServiceAction(Settings settings, RestController controller) { super(settings); - // @deprecated Remove in 6.0 // NOTE: we switched from PUT in 2.x to POST in 5.x // NOTE: We added back the old URL with the new VERB (POST) since we are deprecating _xpack/* URIs in 7.0 controller.registerWithDeprecatedHandler(POST, URI_BASE + "/_restart", this, diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java index d7a7879f7e38d..5cff5da1518a2 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java @@ -30,7 +30,6 @@ public class RestWatcherStatsAction extends WatcherRestHandler { public RestWatcherStatsAction(Settings settings, RestController controller) { super(settings); - // @deprecated Remove deprecations in 6.0 controller.registerHandler(GET, URI_BASE + "/stats", this); controller.registerHandler(GET, "/_watcher/stats", this); controller.registerHandler(GET, URI_BASE + "/stats/{metric}", this);