delete-watch.asciidoc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. [[java-rest-high-x-pack-watcher-delete-watch]]
  2. === Delete Watch API
  3. [[java-rest-high-x-pack-watcher-delete-watch-execution]]
  4. ==== Execution
  5. A watch can be deleted as follows:
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/WatcherDocumentationIT.java[x-pack-delete-watch-execute]
  9. --------------------------------------------------
  10. [[java-rest-high-x-pack-watcher-delete-watch-response]]
  11. ==== Response
  12. The returned `DeleteWatchResponse` contains `found`, `id`,
  13. and `version` information.
  14. ["source","java",subs="attributes,callouts,macros"]
  15. --------------------------------------------------
  16. include-tagged::{doc-tests}/WatcherDocumentationIT.java[x-pack-put-watch-response]
  17. --------------------------------------------------
  18. <1> `_id` contains id of the watch
  19. <2> `found` is a boolean indicating whether the watch was found
  20. <3> `_version` returns the version of the deleted watch
  21. [[java-rest-high-x-pack-watcher-delete-watch-async]]
  22. ==== Asynchronous Execution
  23. This request can be executed asynchronously:
  24. ["source","java",subs="attributes,callouts,macros"]
  25. --------------------------------------------------
  26. include-tagged::{doc-tests}/WatcherDocumentationIT.java[x-pack-delete-watch-execute-async]
  27. --------------------------------------------------
  28. <1> The `DeleteWatchRequest` to execute and the `ActionListener` to use when
  29. the execution completes
  30. The asynchronous method does not block and returns immediately. Once it is
  31. completed the `ActionListener` is called back using the `onResponse` method
  32. if the execution successfully completed or using the `onFailure` method if
  33. it failed.
  34. A typical listener for `DeleteWatchResponse` looks like:
  35. ["source","java",subs="attributes,callouts,macros"]
  36. --------------------------------------------------
  37. include-tagged::{doc-tests}/WatcherDocumentationIT.java[x-pack-delete-watch-execute-listener]
  38. --------------------------------------------------
  39. <1> Called when the execution is successfully completed. The response is
  40. provided as an argument
  41. <2> Called in case of failure. The raised exception is provided as an argument