[HLRC][ML] Add ML get datafeed API to HLRC (#33715)

Relates #29827
This commit is contained in:
Dimitris Athanasiou 2018-09-16 11:54:55 +01:00 committed by GitHub
parent 73417bf09a
commit db40315afb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 736 additions and 97 deletions

View file

@ -0,0 +1,56 @@
[[java-rest-high-x-pack-ml-get-datafeed]]
=== Get Datafeed API
The Get Datafeed API provides the ability to get {ml} datafeeds in the cluster.
It accepts a `GetDatafeedRequest` object and responds
with a `GetDatafeedResponse` object.
[[java-rest-high-x-pack-ml-get-datafeed-request]]
==== Get Datafeed Request
A `GetDatafeedRequest` object gets can have any number of `datafeedId` entries.
However, they all must be non-null. An empty list is the same as requesting for all datafeeds.
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-request]
--------------------------------------------------
<1> Constructing a new request referencing existing `datafeedIds`, can contain wildcards
<2> Whether to ignore if a wildcard expression matches no datafeeds.
(This includes `_all` string or when no datafeeds have been specified)
[[java-rest-high-x-pack-ml-get-datafeed-execution]]
==== Execution
The request can be executed through the `MachineLearningClient` contained
in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method.
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-execute]
--------------------------------------------------
<1> The count of retrieved datafeeds
<2> The retrieved datafeeds
[[java-rest-high-x-pack-ml-get-datafeed-execution-async]]
==== Asynchronous Execution
The request can also be executed asynchronously:
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-execute-async]
--------------------------------------------------
<1> The `GetDatafeedRequest` to execute and the `ActionListener` to use when
the execution completes
The method does not block and returns immediately. The passed `ActionListener` is used
to notify the caller of completion. A typical `ActionListener` for `GetDatafeedResponse` may
look like
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-listener]
--------------------------------------------------
<1> `onResponse` is called back when the action is completed successfully
<2> `onFailure` is called back when some unexpected error occurs

View file

@ -221,6 +221,7 @@ The Java High Level REST Client supports the following Machine Learning APIs:
* <<java-rest-high-x-pack-ml-update-job>>
* <<java-rest-high-x-pack-ml-get-job-stats>>
* <<java-rest-high-x-pack-ml-put-datafeed>>
* <<java-rest-high-x-pack-ml-get-datafeed>>
* <<java-rest-high-x-pack-ml-delete-datafeed>>
* <<java-rest-high-x-pack-ml-forecast-job>>
* <<java-rest-high-x-pack-ml-delete-forecast>>
@ -240,6 +241,7 @@ include::ml/close-job.asciidoc[]
include::ml/update-job.asciidoc[]
include::ml/flush-job.asciidoc[]
include::ml/put-datafeed.asciidoc[]
include::ml/get-datafeed.asciidoc[]
include::ml/delete-datafeed.asciidoc[]
include::ml/get-job-stats.asciidoc[]
include::ml/forecast-job.asciidoc[]