activate-watch.asciidoc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --
  2. :api: activate-watch
  3. :request: ActivateWatchRequest
  4. :response: ActivateWatchResponse
  5. --
  6. [role="xpack"]
  7. [id="{upid}-{api}"]
  8. === Activate watch API
  9. [id="{upid}-{api}-request"]
  10. ==== Execution
  11. A watch can be activated as follows:
  12. ["source","java",subs="attributes,callouts,macros"]
  13. --------------------------------------------------
  14. include-tagged::{doc-tests-file}[{api}-request]
  15. --------------------------------------------------
  16. [id="{upid}-{api}-response"]
  17. ==== Response
  18. The returned +{response}+ contains the new status of the activated watch.
  19. ["source","java",subs="attributes,callouts,macros"]
  20. --------------------------------------------------
  21. include-tagged::{doc-tests-file}[{api}-response]
  22. --------------------------------------------------
  23. <1> `watchStatus` contains status of the watch
  24. [id="{upid}-{api}-request-async"]
  25. ==== Asynchronous execution
  26. This request can be executed asynchronously:
  27. ["source","java",subs="attributes,callouts,macros"]
  28. --------------------------------------------------
  29. include-tagged::{doc-tests-file}[{api}-request-async]
  30. --------------------------------------------------
  31. <1> The +{request}+ to execute and the `ActionListener` to use when
  32. the execution completes
  33. The asynchronous method does not block and returns immediately. Once it is
  34. completed the `ActionListener` is called back using the `onResponse` method
  35. if the execution successfully completed or using the `onFailure` method if
  36. it failed.
  37. A typical listener for +{response}+ looks like:
  38. ["source","java",subs="attributes,callouts,macros"]
  39. --------------------------------------------------
  40. include-tagged::{doc-tests-file}[{api}-request-listener]
  41. --------------------------------------------------
  42. <1> Called when the execution is successfully completed. The response is
  43. provided as an argument
  44. <2> Called in case of failure. The raised exception is provided as an argument