2017-06-27 20:16:51 -04:00
|
|
|
[role="xpack"]
|
2017-03-29 12:07:55 -04:00
|
|
|
[[watcher-api-activate-watch]]
|
|
|
|
=== Activate Watch API
|
|
|
|
|
2017-06-27 20:16:51 -04:00
|
|
|
A watch can be either
|
|
|
|
{xpack-ref}/how-watcher-works.html#watch-active-state[active or inactive]. This
|
|
|
|
API enables you to activate a currently inactive watch.
|
2017-03-29 12:07:55 -04:00
|
|
|
|
2017-09-14 16:01:47 -04:00
|
|
|
[float]
|
|
|
|
==== Request
|
|
|
|
|
|
|
|
`PUT _xpack/watcher/watch/<watch_id>/_activate`
|
|
|
|
|
|
|
|
[float]
|
|
|
|
==== Path Parameters
|
|
|
|
|
|
|
|
`watch_id` (required)::
|
|
|
|
(string) Identifier for the watch.
|
|
|
|
|
|
|
|
[float]
|
|
|
|
==== Authorization
|
|
|
|
|
|
|
|
You must have `manage_watcher` cluster privileges to use this API. For more
|
|
|
|
information, see {xpack-ref}/security-privileges.html[Security Privileges].
|
|
|
|
|
|
|
|
[float]
|
|
|
|
==== Examples
|
|
|
|
|
2017-03-29 12:07:55 -04:00
|
|
|
The status of an inactive watch is returned with the watch definition when you
|
|
|
|
call the <<watcher-api-get-watch, Get Watch API>>:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
GET _xpack/watcher/watch/my_watch
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[setup:my_inactive_watch]
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"found": true,
|
|
|
|
"_id": "my_watch",
|
2017-05-04 04:08:34 -04:00
|
|
|
"status": {
|
2017-03-29 12:07:55 -04:00
|
|
|
"state" : {
|
|
|
|
"active" : false,
|
|
|
|
"timestamp" : "2015-08-20T12:21:32.734Z"
|
|
|
|
},
|
|
|
|
"actions": ...,
|
|
|
|
"version": 1
|
|
|
|
},
|
|
|
|
"watch": ...
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2017-05-04 04:08:34 -04:00
|
|
|
// TESTRESPONSE[s/2015-08-20T12:21:32.734Z/$body.status.state.timestamp/]
|
|
|
|
// TESTRESPONSE[s/"actions": \.\.\./"actions": "$body.status.actions"/]
|
2017-03-29 12:07:55 -04:00
|
|
|
// TESTRESPONSE[s/"watch": \.\.\./"watch": "$body.watch"/]
|
2017-05-04 04:08:34 -04:00
|
|
|
// TESTRESPONSE[s/"version": 1/"version": $body.status.version/]
|
2017-03-29 12:07:55 -04:00
|
|
|
|
|
|
|
You can activate the watch by executing the following API call:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
PUT _xpack/watcher/watch/my_watch/_activate
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[setup:my_inactive_watch]
|
|
|
|
|
|
|
|
The new state of the watch is returned as part of its overall status:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2017-05-04 04:08:34 -04:00
|
|
|
"status": {
|
2017-03-29 12:07:55 -04:00
|
|
|
"state" : {
|
|
|
|
"active" : true,
|
|
|
|
"timestamp" : "2015-09-04T08:39:46.816Z"
|
|
|
|
},
|
|
|
|
"actions": ...,
|
|
|
|
"version": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2017-05-04 04:08:34 -04:00
|
|
|
// TESTRESPONSE[s/2015-09-04T08:39:46.816Z/$body.status.state.timestamp/]
|
|
|
|
// TESTRESPONSE[s/"actions": \.\.\./"actions": "$body.status.actions"/]
|
|
|
|
// TESTRESPONSE[s/"version": 1/"version": $body.status.version/]
|