Delete watch APIedit


A watch can be deleted as follows:

DeleteWatchRequest request = new DeleteWatchRequest("my_watch_id");
DeleteWatchResponse response = client.watcher().deleteWatch(request, RequestOptions.DEFAULT);


The returned DeleteWatchResponse contains found, id, and version information.

String watchId = response.getId(); 
boolean isCreated = response.isCreated(); 
long version = response.getVersion(); 

_id contains id of the watch

found is a boolean indicating whether the watch was found

_version returns the version of the deleted watch

Asynchronous executionedit

This request can be executed asynchronously:

client.watcher().deleteWatchAsync(request, RequestOptions.DEFAULT, listener); 

The DeleteWatchRequest to execute and the ActionListener to use when the execution completes

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 DeleteWatchResponse looks like:

ActionListener<DeleteWatchResponse> listener = new ActionListener<DeleteWatchResponse>() {
    public void onResponse(DeleteWatchResponse response) {

    public void onFailure(Exception e) {

Called when the execution is successfully completed. The response is provided as an argument

Called in case of failure. The raised exception is provided as an argument