2020-07-23 12:42:33 -04:00
|
|
|
[discrete]
|
2017-03-28 17:23:01 -04:00
|
|
|
[[api-java-activate-watch]]
|
2019-09-30 13:18:50 -04:00
|
|
|
=== Activate watch API
|
2017-03-28 17:23:01 -04:00
|
|
|
|
2019-09-30 13:18:50 -04:00
|
|
|
A watch can be either <<watch-active-state,active or inactive>>. This API
|
2017-03-28 17:23:01 -04:00
|
|
|
enables you to activate a currently inactive watch.
|
|
|
|
|
|
|
|
The status of an inactive watch is returned with the watch definition
|
2019-09-30 13:18:50 -04:00
|
|
|
when you call the <<api-java-get-watch,get watch API>>:
|
2017-03-28 17:23:01 -04:00
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
GetWatchResponse getWatchResponse = watcherClient.prepareGetWatch("my-watch").get();
|
|
|
|
boolean active = getWatchResponse.getStatus().state().isActive();
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
The following snippet shows how you can activate a watch:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
--------------------------------------------------
|
|
|
|
ActivateWatchResponse activateResponse = watcherClient.prepareActivateWatch("my-watch", true).get();
|
|
|
|
boolean active = activateResponse.getStatus().state().isActive();
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
The new state of the watch is returned as part of its overall status.
|