OpenSearch/x-pack/docs/en/watcher/java/deactivate-watch.asciidoc
Lisa Cawley 0c3ee0b15c
[DOCS] Moves Watcher content into Elasticsearch book (#47147) (#47255)
Co-Authored-By: James Rodewig <james.rodewig@elastic.co>
2019-09-30 10:18:50 -07:00

26 lines
1000 B
Plaintext

[float]
[[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();
--------------------------------------------------
The following snippet shows how you can deactivate a watch:
[source,java]
--------------------------------------------------
ActivateWatchResponse activateResponse = watcherClient.prepareActivateWatch("my-watch", false).get();
boolean active = activateResponse.getStatus().state().isActive();
--------------------------------------------------
The new state of the watch is returned as part of its overall status.