Activate Watch API

Execution

A watch can be activated as follows:

ActivateWatchRequest request = new ActivateWatchRequest("my_watch_id");
ActivateWatchResponse response = client.watcher().activateWatch(request, RequestOptions.DEFAULT);

Response

The returned ActivateWatchResponse contains the new status of the activated watch.

WatchStatus watchStatus = response.getStatus(); 

watchStatus contains status of the watch

Asynchronous Execution

This request can be executed asynchronously:

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

The ActivateWatchRequest 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 ActivateWatchResponse looks like:

ActionListener<ActivateWatchResponse> listener = new ActionListener<ActivateWatchResponse>() {
    @Override
    public void onResponse(ActivateWatchResponse response) {
        
    }

    @Override
    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