activate-watch.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. [role="xpack"]
  2. [[watcher-api-activate-watch]]
  3. === Activate watch API
  4. ++++
  5. <titleabbrev>Activate watch</titleabbrev>
  6. ++++
  7. A watch can be either <<watch-active-state,active or inactive>>. This
  8. API enables you to activate a currently inactive watch.
  9. [[watcher-api-activate-watch-request]]
  10. ==== {api-request-title}
  11. `PUT _watcher/watch/<watch_id>/_activate`
  12. [[watcher-api-activate-watch-prereqs]]
  13. ==== {api-prereq-title}
  14. * You must have `manage_watcher` cluster privileges to use this API. For more
  15. information, see <<security-privileges>>.
  16. //[[watcher-api-activate-watch-desc]]
  17. //==== {api-description-title}
  18. [[watcher-api-activate-watch-path-params]]
  19. ==== {api-path-parms-title}
  20. `<watch_id>`::
  21. (Required, string) Identifier for the watch.
  22. //[[watcher-api-activate-watch-query-params]]
  23. //==== {api-query-parms-title}
  24. //[[watcher-api-activate-watch-request-body]]
  25. //==== {api-request-body-title}
  26. //[[watcher-api-activate-watch-response-body]]
  27. //==== {api-response-body-title}
  28. //[[watcher-api-activate-watch-response-codes]]
  29. //==== {api-response-codes-title}
  30. [[watcher-api-activate-watch-example]]
  31. ==== {api-examples-title}
  32. The status of an inactive watch is returned with the watch definition when you
  33. call the <<watcher-api-get-watch,get watch API>>:
  34. [source,console]
  35. --------------------------------------------------
  36. GET _watcher/watch/my_watch
  37. --------------------------------------------------
  38. // TEST[setup:my_inactive_watch]
  39. [source,console-result]
  40. --------------------------------------------------
  41. {
  42. "found": true,
  43. "_id": "my_watch",
  44. "_seq_no": 0,
  45. "_primary_term": 1,
  46. "_version": 1,
  47. "status": {
  48. "state" : {
  49. "active" : false,
  50. "timestamp" : "2015-08-20T12:21:32.734Z"
  51. },
  52. "actions": ...,
  53. "version": 1
  54. },
  55. "watch": ...
  56. }
  57. --------------------------------------------------
  58. // TESTRESPONSE[s/2015-08-20T12:21:32.734Z/$body.status.state.timestamp/]
  59. // TESTRESPONSE[s/"actions": \.\.\./"actions": "$body.status.actions"/]
  60. // TESTRESPONSE[s/"watch": \.\.\./"watch": "$body.watch"/]
  61. // TESTRESPONSE[s/"version": 1/"version": $body.status.version/]
  62. You can activate the watch by executing the following API call:
  63. [source,console]
  64. --------------------------------------------------
  65. PUT _watcher/watch/my_watch/_activate
  66. --------------------------------------------------
  67. // TEST[setup:my_inactive_watch]
  68. The new state of the watch is returned as part of its overall status:
  69. [source,console-result]
  70. --------------------------------------------------
  71. {
  72. "status": {
  73. "state" : {
  74. "active" : true,
  75. "timestamp" : "2015-09-04T08:39:46.816Z"
  76. },
  77. "actions": ...,
  78. "version": 1
  79. }
  80. }
  81. --------------------------------------------------
  82. // TESTRESPONSE[s/2015-09-04T08:39:46.816Z/$body.status.state.timestamp/]
  83. // TESTRESPONSE[s/"actions": \.\.\./"actions": "$body.status.actions"/]
  84. // TESTRESPONSE[s/"version": 1/"version": $body.status.version/]