26 lines
1.0 KiB
Plaintext
26 lines
1.0 KiB
Plaintext
|
[[api-java-deactivate-watch]]
|
||
|
==== Deactivate Watch API
|
||
|
|
||
|
A watch can be either <<watch-active-state, active or inactive>>. This API enables
|
||
|
you to deactivate a currently active watch.
|
||
|
|
||
|
The status of an active 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();
|
||
|
assert active;
|
||
|
--------------------------------------------------
|
||
|
|
||
|
You can deactivate the watch by executing the following API call:
|
||
|
|
||
|
[source,java]
|
||
|
--------------------------------------------------
|
||
|
ActivateWatchResponse activateResponse = watcherClient.prepareActivateWatch("my-watch", false).get();
|
||
|
boolean active = activateResponse.getStatus().state().isActive();
|
||
|
assert !active;
|
||
|
--------------------------------------------------
|
||
|
|
||
|
The new state of the watch is returned as part of its overall status.
|