activate-watch.asciidoc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. [role="xpack"]
  2. [[watcher-api-activate-watch]]
  3. === Activate Watch API
  4. A watch can be either
  5. {xpack-ref}/how-watcher-works.html#watch-active-state[active or inactive]. This
  6. API enables you to activate a currently inactive watch.
  7. [float]
  8. ==== Request
  9. `PUT _xpack/watcher/watch/<watch_id>/_activate`
  10. [float]
  11. ==== Path Parameters
  12. `watch_id` (required)::
  13. (string) Identifier for the watch.
  14. [float]
  15. ==== Authorization
  16. You must have `manage_watcher` cluster privileges to use this API. For more
  17. information, see {xpack-ref}/security-privileges.html[Security Privileges].
  18. [float]
  19. ==== Examples
  20. The status of an inactive watch is returned with the watch definition when you
  21. call the <<watcher-api-get-watch, Get Watch API>>:
  22. [source,js]
  23. --------------------------------------------------
  24. GET _xpack/watcher/watch/my_watch
  25. --------------------------------------------------
  26. // CONSOLE
  27. // TEST[setup:my_inactive_watch]
  28. [source,js]
  29. --------------------------------------------------
  30. {
  31. "found": true,
  32. "_id": "my_watch",
  33. "_version": 1,
  34. "status": {
  35. "state" : {
  36. "active" : false,
  37. "timestamp" : "2015-08-20T12:21:32.734Z"
  38. },
  39. "actions": ...,
  40. "version": 1
  41. },
  42. "watch": ...
  43. }
  44. --------------------------------------------------
  45. // TESTRESPONSE[s/2015-08-20T12:21:32.734Z/$body.status.state.timestamp/]
  46. // TESTRESPONSE[s/"actions": \.\.\./"actions": "$body.status.actions"/]
  47. // TESTRESPONSE[s/"watch": \.\.\./"watch": "$body.watch"/]
  48. // TESTRESPONSE[s/"version": 1/"version": $body.status.version/]
  49. You can activate the watch by executing the following API call:
  50. [source,js]
  51. --------------------------------------------------
  52. PUT _xpack/watcher/watch/my_watch/_activate
  53. --------------------------------------------------
  54. // CONSOLE
  55. // TEST[setup:my_inactive_watch]
  56. The new state of the watch is returned as part of its overall status:
  57. [source,js]
  58. --------------------------------------------------
  59. {
  60. "status": {
  61. "state" : {
  62. "active" : true,
  63. "timestamp" : "2015-09-04T08:39:46.816Z"
  64. },
  65. "actions": ...,
  66. "version": 1
  67. }
  68. }
  69. --------------------------------------------------
  70. // TESTRESPONSE[s/2015-09-04T08:39:46.816Z/$body.status.state.timestamp/]
  71. // TESTRESPONSE[s/"actions": \.\.\./"actions": "$body.status.actions"/]
  72. // TESTRESPONSE[s/"version": 1/"version": $body.status.version/]