26 lines
997 B
Plaintext
26 lines
997 B
Plaintext
[float]
|
|
[[api-java-activate-watch]]
|
|
=== Activate Watch API
|
|
|
|
A watch can be either <<watch-active-state, active or inactive>>. This API
|
|
enables you to activate a currently inactive watch.
|
|
|
|
The status of an inactive watch is returned with the watch definition
|
|
when you call the <<api-java-get-watch, Get Watch API>>:
|
|
|
|
[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.
|