| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 | --:api: execute-watch:request: ExecuteWatchRequest:response: ExecuteWatchResponse--[id="{upid}-{api}"]=== Execute Watch APIThe execute watch API allows clients to immediately execute a watch, eitherone that has been previously added via the{ref}/watcher-api-put-watch.html[Put Watch API] or inline as part of the request.[id="{upid}-{api}-request-by-id"]==== Execute by idSubmit the following request to execute a previously added watch:["source","java",subs="attributes,callouts,macros"]---------------------------------------------------include-tagged::{doc-tests-file}[x-pack-execute-watch-by-id]---------------------------------------------------<1> Alternative input for the watch to use in json format<2> Set the mode for action "action1" to SIMULATE<3> Record this execution in watcher history<4> Execute the watch regardless of the watch's condition<5> Set the trigger data for the watch in json format<6> Enable debug mode[id="{upid}-{api}-response-by-id"]==== Execute by id ResponseThe returned `Response` contains details of the execution:["source","java",subs="attributes,callouts,macros"]---------------------------------------------------include-tagged::{doc-tests-file}[x-pack-execute-watch-by-id-response]---------------------------------------------------<1> The record ID for this execution<2> The execution response as a java `Map`<3> Extract information from the response map using `ObjectPath`[id="{upid}-{api}-response-by-id-async"]==== Asynchronous execution by idThis request can be executed asynchronously:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[x-pack-execute-watch-by-id-execute-async]--------------------------------------------------<1> The `ExecuteWatchRequest` to execute and the `ActionListener` to use whenthe execution completesThe asynchronous method does not block and returns immediately. Once it iscompleted the `ActionListener` is called back using the `onResponse` methodif the execution successfully completed or using the `onFailure` method ifit failed.A typical listener for `ExecuteWatchResponse` looks like:["source","java",subs="attributes,callouts,macros"]--------------------------------------------------include-tagged::{doc-tests-file}[x-pack-execute-watch-by-id-execute-listener]--------------------------------------------------<1> Called when the execution is successfully completed. The response isprovided as an argument<2> Called in case of failure. The raised exception is provided as an argument[id="{upid}-{api}-request-inline"]==== Execute inlineSubmit the following request to execute a watch defined as part of the request:["source","java",subs="attributes,callouts,macros"]---------------------------------------------------include-tagged::{doc-tests-file}[x-pack-execute-watch-inline]---------------------------------------------------<1> Alternative input for the watch to use in json format<2> Set the mode for action "action1" to SIMULATE<3> Execute the watch regardless of the watch's condition<4> Set the trigger data for the watch in json format<5> Enable debug modeNote that inline watches cannot be recorded.The response format and asynchronous execution methods are the same as for theExecute Watch by ID API.
 |