123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- [role="xpack"]
- [[watcher-api-activate-watch]]
- === Activate watch API
- ++++
- <titleabbrev>Activate watch</titleabbrev>
- ++++
- .New API reference
- [sidebar]
- --
- For the most up-to-date API details, refer to {api-es}/group/endpoint-watcher[{watcher} APIs].
- --
- A watch can be either <<watch-active-state,active or inactive>>. This
- API enables you to activate a currently inactive watch.
- [[watcher-api-activate-watch-request]]
- ==== {api-request-title}
- `PUT _watcher/watch/<watch_id>/_activate`
- [[watcher-api-activate-watch-prereqs]]
- ==== {api-prereq-title}
- * You must have `manage_watcher` cluster privileges to use this API. For more
- information, see <<security-privileges>>.
- //[[watcher-api-activate-watch-desc]]
- //==== {api-description-title}
- [[watcher-api-activate-watch-path-params]]
- ==== {api-path-parms-title}
- `<watch_id>`::
- (Required, string) Identifier for the watch.
- //[[watcher-api-activate-watch-query-params]]
- //==== {api-query-parms-title}
- //[[watcher-api-activate-watch-request-body]]
- //==== {api-request-body-title}
- //[[watcher-api-activate-watch-response-body]]
- //==== {api-response-body-title}
- //[[watcher-api-activate-watch-response-codes]]
- //==== {api-response-codes-title}
- [[watcher-api-activate-watch-example]]
- ==== {api-examples-title}
- The status of an inactive watch is returned with the watch definition when you
- call the <<watcher-api-get-watch,get watch API>>:
- [source,console]
- --------------------------------------------------
- GET _watcher/watch/my_watch
- --------------------------------------------------
- // TEST[setup:my_inactive_watch]
- [source,console-result]
- --------------------------------------------------
- {
- "found": true,
- "_id": "my_watch",
- "_seq_no": 0,
- "_primary_term": 1,
- "_version": 1,
- "status": {
- "state" : {
- "active" : false,
- "timestamp" : "2015-08-20T12:21:32.734Z"
- },
- "actions": ...,
- "version": 1
- },
- "watch": ...
- }
- --------------------------------------------------
- // TESTRESPONSE[s/2015-08-20T12:21:32.734Z/$body.status.state.timestamp/]
- // TESTRESPONSE[s/"actions": \.\.\./"actions": "$body.status.actions"/]
- // TESTRESPONSE[s/"watch": \.\.\./"watch": "$body.watch"/]
- // TESTRESPONSE[s/"version": 1/"version": $body.status.version/]
- You can activate the watch by executing the following API call:
- [source,console]
- --------------------------------------------------
- PUT _watcher/watch/my_watch/_activate
- --------------------------------------------------
- // TEST[setup:my_inactive_watch]
- The new state of the watch is returned as part of its overall status:
- [source,console-result]
- --------------------------------------------------
- {
- "status": {
- "state" : {
- "active" : true,
- "timestamp" : "2015-09-04T08:39:46.816Z"
- },
- "actions": ...,
- "version": 1
- }
- }
- --------------------------------------------------
- // 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/]
|