WARNING: Deprecated in 7.15.0.
The Java REST Client is deprecated in favor of the Java API Client.
Create or update watch APIedit
Executionedit
General information about the installed Watcher features can be retrieved
using the watcher()
method:
// you can also use the WatchSourceBuilder from org.elasticsearch.plugin:x-pack-core to create a watch programmatically BytesReference watch = new BytesArray("{ \n" + " \"trigger\": { \"schedule\": { \"interval\": \"10h\" } },\n" + " \"input\": { \"simple\": { \"foo\" : \"bar\" } },\n" + " \"actions\": { \"logme\": { \"logging\": { \"text\": \"{{ctx.payload}}\" } } }\n" + "}"); PutWatchRequest request = new PutWatchRequest("my_watch_id", watch, XContentType.JSON); request.setActive(false); PutWatchResponse response = client.watcher().putWatch(request, RequestOptions.DEFAULT);
Responseedit
The returned PutWatchResponse
contains created
, id
,
and version
information.
Asynchronous executionedit
This request can be executed asynchronously:
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 PutWatchResponse
looks like: