get-datafeed.asciidoc 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. [[java-rest-high-x-pack-ml-get-datafeed]]
  2. === Get Datafeed API
  3. The Get Datafeed API provides the ability to get {ml} datafeeds in the cluster.
  4. It accepts a `GetDatafeedRequest` object and responds
  5. with a `GetDatafeedResponse` object.
  6. [[java-rest-high-x-pack-ml-get-datafeed-request]]
  7. ==== Get Datafeed Request
  8. A `GetDatafeedRequest` object gets can have any number of `datafeedId` entries.
  9. However, they all must be non-null. An empty list is the same as requesting for all datafeeds.
  10. ["source","java",subs="attributes,callouts,macros"]
  11. --------------------------------------------------
  12. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-request]
  13. --------------------------------------------------
  14. <1> Constructing a new request referencing existing `datafeedIds`, can contain wildcards
  15. <2> Whether to ignore if a wildcard expression matches no datafeeds.
  16. (This includes `_all` string or when no datafeeds have been specified)
  17. [[java-rest-high-x-pack-ml-get-datafeed-execution]]
  18. ==== Execution
  19. The request can be executed through the `MachineLearningClient` contained
  20. in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method.
  21. ["source","java",subs="attributes,callouts,macros"]
  22. --------------------------------------------------
  23. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-execute]
  24. --------------------------------------------------
  25. <1> The count of retrieved datafeeds
  26. <2> The retrieved datafeeds
  27. [[java-rest-high-x-pack-ml-get-datafeed-execution-async]]
  28. ==== Asynchronous Execution
  29. The request can also be executed asynchronously:
  30. ["source","java",subs="attributes,callouts,macros"]
  31. --------------------------------------------------
  32. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-execute-async]
  33. --------------------------------------------------
  34. <1> The `GetDatafeedRequest` to execute and the `ActionListener` to use when
  35. the execution completes
  36. The method does not block and returns immediately. The passed `ActionListener` is used
  37. to notify the caller of completion. A typical `ActionListener` for `GetDatafeedResponse` may
  38. look like
  39. ["source","java",subs="attributes,callouts,macros"]
  40. --------------------------------------------------
  41. include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-listener]
  42. --------------------------------------------------
  43. <1> `onResponse` is called back when the action is completed successfully
  44. <2> `onFailure` is called back when some unexpected error occurs