2323import org .elasticsearch .protocol .xpack .ml .CloseJobResponse ;
2424import org .elasticsearch .protocol .xpack .ml .DeleteJobRequest ;
2525import org .elasticsearch .protocol .xpack .ml .DeleteJobResponse ;
26+ import org .elasticsearch .protocol .xpack .ml .GetBucketsRequest ;
27+ import org .elasticsearch .protocol .xpack .ml .GetBucketsResponse ;
2628import org .elasticsearch .protocol .xpack .ml .GetJobRequest ;
2729import org .elasticsearch .protocol .xpack .ml .GetJobResponse ;
2830import org .elasticsearch .protocol .xpack .ml .OpenJobRequest ;
@@ -54,7 +56,7 @@ public final class MachineLearningClient {
5456 * For additional info
5557 * see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html">ML PUT job documentation</a>
5658 *
57- * @param request the PutJobRequest containing the {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} settings
59+ * @param request The PutJobRequest containing the {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} settings
5860 * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
5961 * @return PutJobResponse with enclosed {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} object
6062 * @throws IOException when there is a serialization issue sending the request or receiving the response
@@ -73,7 +75,7 @@ public PutJobResponse putJob(PutJobRequest request, RequestOptions options) thro
7375 * For additional info
7476 * see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html">ML PUT job documentation</a>
7577 *
76- * @param request the request containing the {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} settings
78+ * @param request The request containing the {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} settings
7779 * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
7880 * @param listener Listener to be notified upon request completion
7981 */
@@ -93,7 +95,7 @@ public void putJobAsync(PutJobRequest request, RequestOptions options, ActionLis
9395 * For additional info
9496 * see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html"></a>
9597 * </p>
96- * @param request {@link GetJobRequest} request containing a list of jobId(s) and additional options
98+ * @param request {@link GetJobRequest} Request containing a list of jobId(s) and additional options
9799 * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
98100 * @return {@link GetJobResponse} response object containing
99101 * the {@link org.elasticsearch.protocol.xpack.ml.job.config.Job} objects and the number of jobs found
@@ -114,7 +116,7 @@ public GetJobResponse getJob(GetJobRequest request, RequestOptions options) thro
114116 * For additional info
115117 * see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html"></a>
116118 * </p>
117- * @param request {@link GetJobRequest} request containing a list of jobId(s) and additional options
119+ * @param request {@link GetJobRequest} Request containing a list of jobId(s) and additional options
118120 * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
119121 * @param listener Listener to be notified with {@link GetJobResponse} upon request completion
120122 */
@@ -133,7 +135,7 @@ public void getJobAsync(GetJobRequest request, RequestOptions options, ActionLis
133135 * For additional info
134136 * see <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html">ML Delete Job documentation</a>
135137 * </p>
136- * @param request the request to delete the job
138+ * @param request The request to delete the job
137139 * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
138140 * @return action acknowledgement
139141 * @throws IOException when there is a serialization issue sending the request or receiving the response
@@ -152,7 +154,7 @@ public DeleteJobResponse deleteJob(DeleteJobRequest request, RequestOptions opti
152154 * For additional info
153155 * see <a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html">ML Delete Job documentation</a>
154156 * </p>
155- * @param request the request to delete the job
157+ * @param request The request to delete the job
156158 * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
157159 * @param listener Listener to be notified upon request completion
158160 */
@@ -176,7 +178,7 @@ public void deleteJobAsync(DeleteJobRequest request, RequestOptions options, Act
176178 * For additional info
177179 * see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html"></a>
178180 * </p>
179- * @param request request containing job_id and additional optional options
181+ * @param request Request containing job_id and additional optional options
180182 * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
181183 * @return response containing if the job was successfully opened or not.
182184 * @throws IOException when there is a serialization issue sending the request or receiving the response
@@ -199,7 +201,7 @@ public OpenJobResponse openJob(OpenJobRequest request, RequestOptions options) t
199201 * For additional info
200202 * see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html"></a>
201203 * </p>
202- * @param request request containing job_id and additional optional options
204+ * @param request Request containing job_id and additional optional options
203205 * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
204206 * @param listener Listener to be notified upon request completion
205207 */
@@ -217,7 +219,7 @@ public void openJobAsync(OpenJobRequest request, RequestOptions options, ActionL
217219 *
218220 * A closed job cannot receive data or perform analysis operations, but you can still explore and navigate results.
219221 *
220- * @param request request containing job_ids and additional options. See {@link CloseJobRequest}
222+ * @param request Request containing job_ids and additional options. See {@link CloseJobRequest}
221223 * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
222224 * @return response containing if the job was successfully closed or not.
223225 * @throws IOException when there is a serialization issue sending the request or receiving the response
@@ -235,7 +237,7 @@ public CloseJobResponse closeJob(CloseJobRequest request, RequestOptions options
235237 *
236238 * A closed job cannot receive data or perform analysis operations, but you can still explore and navigate results.
237239 *
238- * @param request request containing job_ids and additional options. See {@link CloseJobRequest}
240+ * @param request Request containing job_ids and additional options. See {@link CloseJobRequest}
239241 * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
240242 * @param listener Listener to be notified upon request completion
241243 */
@@ -247,4 +249,40 @@ public void closeJobAsync(CloseJobRequest request, RequestOptions options, Actio
247249 listener ,
248250 Collections .emptySet ());
249251 }
252+
253+ /**
254+ * Gets the buckets for a Machine Learning Job.
255+ * <p>
256+ * For additional info
257+ * see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html">ML GET buckets documentation</a>
258+ *
259+ * @param request The request
260+ * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
261+ */
262+ public GetBucketsResponse getBuckets (GetBucketsRequest request , RequestOptions options ) throws IOException {
263+ return restHighLevelClient .performRequestAndParseEntity (request ,
264+ MLRequestConverters ::getBuckets ,
265+ options ,
266+ GetBucketsResponse ::fromXContent ,
267+ Collections .emptySet ());
268+ }
269+
270+ /**
271+ * Gets the buckets for a Machine Learning Job, notifies listener once the requested buckets are retrieved.
272+ * <p>
273+ * For additional info
274+ * see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html">ML GET buckets documentation</a>
275+ *
276+ * @param request The request
277+ * @param options Additional request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
278+ * @param listener Listener to be notified upon request completion
279+ */
280+ public void getBucketsAsync (GetBucketsRequest request , RequestOptions options , ActionListener <GetBucketsResponse > listener ) {
281+ restHighLevelClient .performRequestAsyncAndParseEntity (request ,
282+ MLRequestConverters ::getBuckets ,
283+ options ,
284+ GetBucketsResponse ::fromXContent ,
285+ listener ,
286+ Collections .emptySet ());
287+ }
250288}
0 commit comments