mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 07:37:19 -04:00
HLRC: execute watch API (#35868)
This change adds support for the execute watch API in the high level rest client
This commit is contained in:
parent
a264cb6ddb
commit
d2886e1c81
13 changed files with 948 additions and 20 deletions
|
@ -427,6 +427,7 @@ The Java High Level REST Client supports the following Watcher APIs:
|
|||
* <<java-rest-high-watcher-deactivate-watch>>
|
||||
* <<{upid}-ack-watch>>
|
||||
* <<{upid}-activate-watch>>
|
||||
* <<{upid}-execute-watch>>
|
||||
* <<{upid}-watcher-stats>>
|
||||
|
||||
include::watcher/start-watch-service.asciidoc[]
|
||||
|
@ -437,6 +438,7 @@ include::watcher/delete-watch.asciidoc[]
|
|||
include::watcher/ack-watch.asciidoc[]
|
||||
include::watcher/deactivate-watch.asciidoc[]
|
||||
include::watcher/activate-watch.asciidoc[]
|
||||
include::watcher/execute-watch.asciidoc[]
|
||||
include::watcher/watcher-stats.asciidoc[]
|
||||
|
||||
== Graph APIs
|
||||
|
|
88
docs/java-rest/high-level/watcher/execute-watch.asciidoc
Normal file
88
docs/java-rest/high-level/watcher/execute-watch.asciidoc
Normal file
|
@ -0,0 +1,88 @@
|
|||
--
|
||||
:api: execute-watch
|
||||
:request: ExecuteWatchRequest
|
||||
:response: ExecuteWatchResponse
|
||||
--
|
||||
[id="{upid}-{api}"]
|
||||
=== Execute Watch API
|
||||
|
||||
The execute watch API allows clients to immediately execute a watch, either
|
||||
one that has been previously added via the
|
||||
{ref}/put-watch.html[Put Watch API] or inline as part of the request.
|
||||
|
||||
[id="{upid}-{api}-request-by-id"]
|
||||
==== Execute by id
|
||||
|
||||
Submit 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 Response
|
||||
|
||||
The 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 id
|
||||
|
||||
This 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 when
|
||||
the execution completes
|
||||
|
||||
The asynchronous method does not block and returns immediately. Once it is
|
||||
completed the `ActionListener` is called back using the `onResponse` method
|
||||
if the execution successfully completed or using the `onFailure` method if
|
||||
it 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 is
|
||||
provided as an argument
|
||||
<2> Called in case of failure. The raised exception is provided as an argument
|
||||
|
||||
|
||||
[id="{upid}-{api}-request-inline"]
|
||||
==== Execute inline
|
||||
|
||||
Submit 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 mode
|
||||
|
||||
Note that inline watches cannot be recorded.
|
||||
|
||||
The response format and asynchronous execution methods are the same as for the
|
||||
Execute Watch by ID API.
|
Loading…
Add table
Add a link
Reference in a new issue