delete-watch.asciidoc 2.1 KB

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