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