activate-watch.asciidoc 3.0 KB

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