diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java index 0c0efb241f9..e8383b9ba74 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java @@ -140,45 +140,45 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { public void testCreateJob() throws Exception { RestHighLevelClient client = highLevelClient(); - //tag::x-pack-ml-put-job-detector + // tag::put-job-detector Detector.Builder detectorBuilder = new Detector.Builder() .setFunction("sum") // <1> .setFieldName("total") // <2> .setDetectorDescription("Sum of total"); // <3> - //end::x-pack-ml-put-job-detector + // end::put-job-detector - //tag::x-pack-ml-put-job-analysis-config + // tag::put-job-analysis-config List detectors = Collections.singletonList(detectorBuilder.build()); // <1> AnalysisConfig.Builder analysisConfigBuilder = new AnalysisConfig.Builder(detectors) // <2> .setBucketSpan(TimeValue.timeValueMinutes(10)); // <3> - //end::x-pack-ml-put-job-analysis-config + // end::put-job-analysis-config - //tag::x-pack-ml-put-job-data-description + // tag::put-job-data-description DataDescription.Builder dataDescriptionBuilder = new DataDescription.Builder() .setTimeField("timestamp"); // <1> - //end::x-pack-ml-put-job-data-description + // end::put-job-data-description { String id = "job_1"; - //tag::x-pack-ml-put-job-config + // tag::put-job-config Job.Builder jobBuilder = new Job.Builder(id) // <1> .setAnalysisConfig(analysisConfigBuilder) // <2> .setDataDescription(dataDescriptionBuilder) // <3> .setDescription("Total sum of requests"); // <4> - //end::x-pack-ml-put-job-config + // end::put-job-config - //tag::x-pack-ml-put-job-request + // tag::put-job-request PutJobRequest request = new PutJobRequest(jobBuilder.build()); // <1> - //end::x-pack-ml-put-job-request + // end::put-job-request - //tag::x-pack-ml-put-job-execute + // tag::put-job-execute PutJobResponse response = client.machineLearning().putJob(request, RequestOptions.DEFAULT); - //end::x-pack-ml-put-job-execute + // end::put-job-execute - //tag::x-pack-ml-put-job-response + // tag::put-job-response Date createTime = response.getResponse().getCreateTime(); // <1> - //end::x-pack-ml-put-job-response + // end::put-job-response assertThat(createTime.getTime(), greaterThan(0L)); } { @@ -189,7 +189,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { .setDescription("Total sum of requests"); PutJobRequest request = new PutJobRequest(jobBuilder.build()); - // tag::x-pack-ml-put-job-execute-listener + // tag::put-job-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(PutJobResponse response) { @@ -201,15 +201,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-put-job-execute-listener + // end::put-job-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-put-job-execute-async + // tag::put-job-execute-async client.machineLearning().putJobAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-put-job-execute-async + // end::put-job-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -225,17 +225,19 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().putJob(new PutJobRequest(secondJob), RequestOptions.DEFAULT); { - //tag::x-pack-ml-get-job-request + // tag::get-job-request GetJobRequest request = new GetJobRequest("get-machine-learning-job1", "get-machine-learning-job*"); // <1> request.setAllowNoJobs(true); // <2> - //end::x-pack-ml-get-job-request + // end::get-job-request - //tag::x-pack-ml-get-job-execute + // tag::get-job-execute GetJobResponse response = client.machineLearning().getJob(request, RequestOptions.DEFAULT); + // end::get-job-execute + + // tag::get-job-response long numberOfJobs = response.count(); // <1> List jobs = response.jobs(); // <2> - //end::x-pack-ml-get-job-execute - + // end::get-job-response assertEquals(2, response.count()); assertThat(response.jobs(), hasSize(2)); assertThat(response.jobs().stream().map(Job::getId).collect(Collectors.toList()), @@ -244,7 +246,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { { GetJobRequest request = new GetJobRequest("get-machine-learning-job1", "get-machine-learning-job*"); - // tag::x-pack-ml-get-job-listener + // tag::get-job-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(GetJobResponse response) { @@ -256,15 +258,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-get-job-listener + // end::get-job-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-get-job-execute-async + // tag::get-job-execute-async client.machineLearning().getJobAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-get-job-execute-async + // end::get-job-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -282,32 +284,32 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().putJob(new PutJobRequest(secondJob), RequestOptions.DEFAULT); { - //tag::x-pack-delete-ml-job-request + //tag::delete-job-request DeleteJobRequest deleteJobRequest = new DeleteJobRequest("my-first-machine-learning-job"); // <1> - //end::x-pack-delete-ml-job-request + //end::delete-job-request - //tag::x-pack-delete-ml-job-request-force + //tag::delete-job-request-force deleteJobRequest.setForce(false); // <1> - //end::x-pack-delete-ml-job-request-force + //end::delete-job-request-force - //tag::x-pack-delete-ml-job-request-wait-for-completion + //tag::delete-job-request-wait-for-completion deleteJobRequest.setWaitForCompletion(true); // <1> - //end::x-pack-delete-ml-job-request-wait-for-completion + //end::delete-job-request-wait-for-completion - //tag::x-pack-delete-ml-job-execute + //tag::delete-job-execute DeleteJobResponse deleteJobResponse = client.machineLearning().deleteJob(deleteJobRequest, RequestOptions.DEFAULT); - //end::x-pack-delete-ml-job-execute + //end::delete-job-execute - //tag::x-pack-delete-ml-job-response + //tag::delete-job-response Boolean isAcknowledged = deleteJobResponse.getAcknowledged(); // <1> TaskId task = deleteJobResponse.getTask(); // <2> - //end::x-pack-delete-ml-job-response + //end::delete-job-response assertTrue(isAcknowledged); assertNull(task); } { - //tag::x-pack-delete-ml-job-request-listener + //tag::delete-job-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(DeleteJobResponse deleteJobResponse) { @@ -319,16 +321,16 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - //end::x-pack-delete-ml-job-request-listener + // end::delete-job-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - //tag::x-pack-delete-ml-job-request-async DeleteJobRequest deleteJobRequest = new DeleteJobRequest("my-second-machine-learning-job"); + // tag::delete-job-execute-async client.machineLearning().deleteJobAsync(deleteJobRequest, RequestOptions.DEFAULT, listener); // <1> - //end::x-pack-delete-ml-job-request-async + // end::delete-job-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -344,19 +346,21 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().putJob(new PutJobRequest(secondJob), RequestOptions.DEFAULT); { - //tag::x-pack-ml-open-job-request + // tag::open-job-request OpenJobRequest openJobRequest = new OpenJobRequest("opening-my-first-machine-learning-job"); // <1> openJobRequest.setTimeout(TimeValue.timeValueMinutes(10)); // <2> - //end::x-pack-ml-open-job-request + // end::open-job-request - //tag::x-pack-ml-open-job-execute + // tag::open-job-execute OpenJobResponse openJobResponse = client.machineLearning().openJob(openJobRequest, RequestOptions.DEFAULT); - boolean isOpened = openJobResponse.isOpened(); // <1> - //end::x-pack-ml-open-job-execute + // end::open-job-execute + // tag::open-job-response + boolean isOpened = openJobResponse.isOpened(); // <1> + // end::open-job-response } { - //tag::x-pack-ml-open-job-listener + // tag::open-job-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(OpenJobResponse openJobResponse) { @@ -368,15 +372,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - //end::x-pack-ml-open-job-listener + // end::open-job-execute-listener OpenJobRequest openJobRequest = new OpenJobRequest("opening-my-second-machine-learning-job"); // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-open-job-execute-async + // tag::open-job-execute-async client.machineLearning().openJobAsync(openJobRequest, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-open-job-execute-async + // end::open-job-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -390,17 +394,20 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT); client.machineLearning().openJob(new OpenJobRequest(job.getId()), RequestOptions.DEFAULT); - //tag::x-pack-ml-close-job-request + // tag::close-job-request CloseJobRequest closeJobRequest = new CloseJobRequest("closing-my-first-machine-learning-job", "otherjobs*"); // <1> closeJobRequest.setForce(false); // <2> closeJobRequest.setAllowNoJobs(true); // <3> closeJobRequest.setTimeout(TimeValue.timeValueMinutes(10)); // <4> - //end::x-pack-ml-close-job-request + // end::close-job-request - //tag::x-pack-ml-close-job-execute + // tag::close-job-execute CloseJobResponse closeJobResponse = client.machineLearning().closeJob(closeJobRequest, RequestOptions.DEFAULT); + // end::close-job-execute + + // tag::close-job-response boolean isClosed = closeJobResponse.isClosed(); // <1> - //end::x-pack-ml-close-job-execute + // end::close-job-response } { @@ -408,7 +415,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().putJob(new PutJobRequest(job), RequestOptions.DEFAULT); client.machineLearning().openJob(new OpenJobRequest(job.getId()), RequestOptions.DEFAULT); - //tag::x-pack-ml-close-job-listener + // tag::close-job-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(CloseJobResponse closeJobResponse) { @@ -420,16 +427,16 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - //end::x-pack-ml-close-job-listener + // end::close-job-execute-listener CloseJobRequest closeJobRequest = new CloseJobRequest("closing-my-second-machine-learning-job"); // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-close-job-execute-async + // tag::close-job-execute-async client.machineLearning().closeJobAsync(closeJobRequest, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-close-job-execute-async + // end::close-job-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -458,13 +465,13 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { Map customSettings = new HashMap<>(); customSettings.put("custom-setting-1", "custom-value"); - //tag::x-pack-ml-update-job-detector-options + // tag::update-job-detector-options JobUpdate.DetectorUpdate detectorUpdate = new JobUpdate.DetectorUpdate(0, // <1> "detector description", // <2> detectionRules); // <3> - //end::x-pack-ml-update-job-detector-options + // end::update-job-detector-options - //tag::x-pack-ml-update-job-options + // tag::update-job-options JobUpdate update = new JobUpdate.Builder(jobId) // <1> .setDescription("My description") // <2> .setAnalysisLimits(new AnalysisLimits(1000L, null)) // <3> @@ -478,24 +485,25 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { .setCustomSettings(customSettings) // <11> .setRenormalizationWindowDays(3L) // <12> .build(); - //end::x-pack-ml-update-job-options + // end::update-job-options - //tag::x-pack-ml-update-job-request + // tag::update-job-request UpdateJobRequest updateJobRequest = new UpdateJobRequest(update); // <1> - //end::x-pack-ml-update-job-request + // end::update-job-request - //tag::x-pack-ml-update-job-execute + // tag::update-job-execute PutJobResponse updateJobResponse = client.machineLearning().updateJob(updateJobRequest, RequestOptions.DEFAULT); - //end::x-pack-ml-update-job-execute - //tag::x-pack-ml-update-job-response + // end::update-job-execute + + // tag::update-job-response Job updatedJob = updateJobResponse.getResponse(); // <1> - //end::x-pack-ml-update-job-response + // end::update-job-response assertEquals(update.getDescription(), updatedJob.getDescription()); } { - //tag::x-pack-ml-update-job-listener + // tag::update-job-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(PutJobResponse updateJobResponse) { @@ -507,16 +515,16 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - //end::x-pack-ml-update-job-listener + // end::update-job-execute-listener UpdateJobRequest updateJobRequest = new UpdateJobRequest(new JobUpdate.Builder(jobId).build()); // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-update-job-execute-async + // tag::update-job-execute-async client.machineLearning().updateJobAsync(updateJobRequest, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-update-job-execute-async + // end::update-job-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -533,56 +541,56 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { String id = "datafeed-1"; - //tag::x-pack-ml-create-datafeed-config + // tag::put-datafeed-config DatafeedConfig.Builder datafeedBuilder = new DatafeedConfig.Builder(id, jobId) // <1> .setIndices("index_1", "index_2"); // <2> - //end::x-pack-ml-create-datafeed-config + // end::put-datafeed-config AggregatorFactories.Builder aggs = AggregatorFactories.builder(); - //tag::x-pack-ml-create-datafeed-config-set-aggregations + // tag::put-datafeed-config-set-aggregations datafeedBuilder.setAggregations(aggs); // <1> - //end::x-pack-ml-create-datafeed-config-set-aggregations + // end::put-datafeed-config-set-aggregations // Clearing aggregation to avoid complex validation rules datafeedBuilder.setAggregations((String) null); - //tag::x-pack-ml-create-datafeed-config-set-chunking-config + // tag::put-datafeed-config-set-chunking-config datafeedBuilder.setChunkingConfig(ChunkingConfig.newAuto()); // <1> - //end::x-pack-ml-create-datafeed-config-set-chunking-config + // end::put-datafeed-config-set-chunking-config - //tag::x-pack-ml-create-datafeed-config-set-frequency + // tag::put-datafeed-config-set-frequency datafeedBuilder.setFrequency(TimeValue.timeValueSeconds(30)); // <1> - //end::x-pack-ml-create-datafeed-config-set-frequency + // end::put-datafeed-config-set-frequency - //tag::x-pack-ml-create-datafeed-config-set-query + // tag::put-datafeed-config-set-query datafeedBuilder.setQuery(QueryBuilders.matchAllQuery()); // <1> - //end::x-pack-ml-create-datafeed-config-set-query + // end::put-datafeed-config-set-query - //tag::x-pack-ml-create-datafeed-config-set-query-delay + // tag::put-datafeed-config-set-query-delay datafeedBuilder.setQueryDelay(TimeValue.timeValueMinutes(1)); // <1> - //end::x-pack-ml-create-datafeed-config-set-query-delay + // end::put-datafeed-config-set-query-delay List scriptFields = Collections.emptyList(); - //tag::x-pack-ml-create-datafeed-config-set-script-fields + // tag::put-datafeed-config-set-script-fields datafeedBuilder.setScriptFields(scriptFields); // <1> - //end::x-pack-ml-create-datafeed-config-set-script-fields + // end::put-datafeed-config-set-script-fields - //tag::x-pack-ml-create-datafeed-config-set-scroll-size + // tag::put-datafeed-config-set-scroll-size datafeedBuilder.setScrollSize(1000); // <1> - //end::x-pack-ml-create-datafeed-config-set-scroll-size + // end::put-datafeed-config-set-scroll-size - //tag::x-pack-ml-put-datafeed-request + // tag::put-datafeed-request PutDatafeedRequest request = new PutDatafeedRequest(datafeedBuilder.build()); // <1> - //end::x-pack-ml-put-datafeed-request + // end::put-datafeed-request - //tag::x-pack-ml-put-datafeed-execute + // tag::put-datafeed-execute PutDatafeedResponse response = client.machineLearning().putDatafeed(request, RequestOptions.DEFAULT); - //end::x-pack-ml-put-datafeed-execute + // end::put-datafeed-execute - //tag::x-pack-ml-put-datafeed-response + // tag::put-datafeed-response DatafeedConfig datafeed = response.getResponse(); // <1> - //end::x-pack-ml-put-datafeed-response + // end::put-datafeed-response assertThat(datafeed.getId(), equalTo("datafeed-1")); } { @@ -596,7 +604,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { DatafeedConfig datafeed = new DatafeedConfig.Builder(id, jobId).setIndices("index_1", "index_2").build(); PutDatafeedRequest request = new PutDatafeedRequest(datafeed); - // tag::x-pack-ml-put-datafeed-execute-listener + // tag::put-datafeed-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(PutDatafeedResponse response) { @@ -608,15 +616,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-put-datafeed-execute-listener + // end::put-datafeed-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-put-datafeed-execute-async + // tag::put-datafeed-execute-async client.machineLearning().putDatafeedAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-put-datafeed-execute-async + // end::put-datafeed-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -632,16 +640,19 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); { - //tag::x-pack-ml-get-datafeed-request + // tag::get-datafeed-request GetDatafeedRequest request = new GetDatafeedRequest(datafeedId); // <1> request.setAllowNoDatafeeds(true); // <2> - //end::x-pack-ml-get-datafeed-request + // end::get-datafeed-request - //tag::x-pack-ml-get-datafeed-execute + // tag::get-datafeed-execute GetDatafeedResponse response = client.machineLearning().getDatafeed(request, RequestOptions.DEFAULT); + // end::get-datafeed-execute + + // tag::get-datafeed-response long numberOfDatafeeds = response.count(); // <1> List datafeeds = response.datafeeds(); // <2> - //end::x-pack-ml-get-datafeed-execute + // end::get-datafeed-response assertEquals(1, numberOfDatafeeds); assertEquals(1, datafeeds.size()); @@ -649,7 +660,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { { GetDatafeedRequest request = new GetDatafeedRequest(datafeedId); - // tag::x-pack-ml-get-datafeed-listener + // tag::get-datafeed-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(GetDatafeedResponse response) { @@ -661,15 +672,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-get-datafeed-listener + // end::get-datafeed-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-get-datafeed-execute-async + // tag::get-datafeed-execute-async client.machineLearning().getDatafeedAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-get-datafeed-execute-async + // end::get-datafeed-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -687,23 +698,26 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); { - //tag::x-pack-delete-ml-datafeed-request + // tag::delete-datafeed-request DeleteDatafeedRequest deleteDatafeedRequest = new DeleteDatafeedRequest(datafeedId); deleteDatafeedRequest.setForce(false); // <1> - AcknowledgedResponse deleteDatafeedResponse = client.machineLearning().deleteDatafeed( - deleteDatafeedRequest, RequestOptions.DEFAULT); - //end::x-pack-delete-ml-datafeed-request + // end::delete-datafeed-request - //tag::x-pack-delete-ml-datafeed-response + // tag::delete-datafeed-execute + AcknowledgedResponse deleteDatafeedResponse = client.machineLearning().deleteDatafeed( + deleteDatafeedRequest, RequestOptions.DEFAULT); + // end::delete-datafeed-execute + + // tag::delete-datafeed-response boolean isAcknowledged = deleteDatafeedResponse.isAcknowledged(); // <1> - //end::x-pack-delete-ml-datafeed-response + // end::delete-datafeed-response } // Recreate datafeed to allow second deletion client.machineLearning().putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); { - //tag::x-pack-delete-ml-datafeed-request-listener + // tag::delete-datafeed-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(AcknowledgedResponse acknowledgedResponse) { @@ -715,16 +729,17 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - //end::x-pack-delete-ml-datafeed-request-listener + // end::delete-datafeed-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - //tag::x-pack-delete-ml-datafeed-request-async DeleteDatafeedRequest deleteDatafeedRequest = new DeleteDatafeedRequest(datafeedId); + + // tag::delete-datafeed-execute-async client.machineLearning().deleteDatafeedAsync(deleteDatafeedRequest, RequestOptions.DEFAULT, listener); // <1> - //end::x-pack-delete-ml-datafeed-request-async + // end::delete-datafeed-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -746,18 +761,18 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { .build(); client.machineLearning().putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); { - //tag::preview-datafeed-request + // tag::preview-datafeed-request PreviewDatafeedRequest request = new PreviewDatafeedRequest(datafeedId); // <1> - //end::preview-datafeed-request + // end::preview-datafeed-request - //tag::preview-datafeed-execute + // tag::preview-datafeed-execute PreviewDatafeedResponse response = client.machineLearning().previewDatafeed(request, RequestOptions.DEFAULT); - //end::preview-datafeed-execute + // end::preview-datafeed-execute - //tag::preview-datafeed-response + // tag::preview-datafeed-response BytesReference rawPreview = response.getPreview(); // <1> List> semiParsedPreview = response.getDataList(); // <2> - //end::preview-datafeed-response + // end::preview-datafeed-response assertTrue(semiParsedPreview.isEmpty()); } @@ -807,27 +822,29 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().putDatafeed(new PutDatafeedRequest(datafeed), RequestOptions.DEFAULT); client.machineLearning().openJob(new OpenJobRequest(job.getId()), RequestOptions.DEFAULT); { - //tag::x-pack-ml-start-datafeed-request + // tag::start-datafeed-request StartDatafeedRequest request = new StartDatafeedRequest(datafeedId); // <1> - //end::x-pack-ml-start-datafeed-request + // end::start-datafeed-request - //tag::x-pack-ml-start-datafeed-request-options + // tag::start-datafeed-request-options request.setEnd("2018-08-21T00:00:00Z"); // <1> request.setStart("2018-08-20T00:00:00Z"); // <2> request.setTimeout(TimeValue.timeValueMinutes(10)); // <3> - //end::x-pack-ml-start-datafeed-request-options + // end::start-datafeed-request-options - //tag::x-pack-ml-start-datafeed-execute + // tag::start-datafeed-execute StartDatafeedResponse response = client.machineLearning().startDatafeed(request, RequestOptions.DEFAULT); + // end::start-datafeed-execute + // tag::start-datafeed-response boolean started = response.isStarted(); // <1> - //end::x-pack-ml-start-datafeed-execute + // end::start-datafeed-response assertTrue(started); } { StartDatafeedRequest request = new StartDatafeedRequest(datafeedId); - // tag::x-pack-ml-start-datafeed-listener + // tag::start-datafeed-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(StartDatafeedResponse response) { @@ -839,15 +856,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-start-datafeed-listener + // end::start-datafeed-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-start-datafeed-execute-async + // tag::start-datafeed-execute-async client.machineLearning().startDatafeedAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-start-datafeed-execute-async + // end::start-datafeed-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -857,28 +874,30 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { RestHighLevelClient client = highLevelClient(); { - //tag::x-pack-ml-stop-datafeed-request + // tag::stop-datafeed-request StopDatafeedRequest request = new StopDatafeedRequest("datafeed_id1", "datafeed_id*"); // <1> - //end::x-pack-ml-stop-datafeed-request + // end::stop-datafeed-request request = StopDatafeedRequest.stopAllDatafeedsRequest(); - //tag::x-pack-ml-stop-datafeed-request-options + // tag::stop-datafeed-request-options request.setAllowNoDatafeeds(true); // <1> request.setForce(true); // <2> request.setTimeout(TimeValue.timeValueMinutes(10)); // <3> - //end::x-pack-ml-stop-datafeed-request-options + // end::stop-datafeed-request-options - //tag::x-pack-ml-stop-datafeed-execute + // tag::stop-datafeed-execute StopDatafeedResponse response = client.machineLearning().stopDatafeed(request, RequestOptions.DEFAULT); + // end::stop-datafeed-execute + // tag::stop-datafeed-response boolean stopped = response.isStopped(); // <1> - //end::x-pack-ml-stop-datafeed-execute + // end::stop-datafeed-response assertTrue(stopped); } { StopDatafeedRequest request = StopDatafeedRequest.stopAllDatafeedsRequest(); - // tag::x-pack-ml-stop-datafeed-listener + // tag::stop-datafeed-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(StopDatafeedResponse response) { @@ -890,15 +909,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-stop-datafeed-listener + // end::stop-datafeed-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-stop-datafeed-execute-async + // tag::stop-datafeed-execute-async client.machineLearning().stopDatafeedAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-stop-datafeed-execute-async + // end::stop-datafeed-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -931,20 +950,20 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().putDatafeed(new PutDatafeedRequest(secondDatafeed), RequestOptions.DEFAULT); { - //tag::x-pack-ml-get-datafeed-stats-request + //tag::get-datafeed-stats-request GetDatafeedStatsRequest request = new GetDatafeedStatsRequest("get-machine-learning-datafeed-stats1-feed", "get-machine-learning-datafeed*"); // <1> request.setAllowNoDatafeeds(true); // <2> - //end::x-pack-ml-get-datafeed-stats-request + //end::get-datafeed-stats-request - //tag::x-pack-ml-get-datafeed-stats-execute + //tag::get-datafeed-stats-execute GetDatafeedStatsResponse response = client.machineLearning().getDatafeedStats(request, RequestOptions.DEFAULT); - //end::x-pack-ml-get-datafeed-stats-execute + //end::get-datafeed-stats-execute - //tag::x-pack-ml-get-datafeed-stats-response + //tag::get-datafeed-stats-response long numberOfDatafeedStats = response.count(); // <1> List datafeedStats = response.datafeedStats(); // <2> - //end::x-pack-ml-get-datafeed-stats-response + //end::get-datafeed-stats-response assertEquals(2, response.count()); assertThat(response.datafeedStats(), hasSize(2)); @@ -954,7 +973,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { { GetDatafeedStatsRequest request = new GetDatafeedStatsRequest("*"); - // tag::x-pack-ml-get-datafeed-stats-listener + // tag::get-datafeed-stats-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(GetDatafeedStatsResponse response) { @@ -966,15 +985,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-get-datafeed-stats-listener + // end::get-datafeed-stats-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-get-datafeed-stats-execute-async + // tag::get-datafeed-stats-execute-async client.machineLearning().getDatafeedStatsAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-get-datafeed-stats-execute-async + // end::get-datafeed-stats-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -995,66 +1014,66 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.index(indexRequest, RequestOptions.DEFAULT); { - // tag::x-pack-ml-get-buckets-request + // tag::get-buckets-request GetBucketsRequest request = new GetBucketsRequest(jobId); // <1> - // end::x-pack-ml-get-buckets-request + // end::get-buckets-request - // tag::x-pack-ml-get-buckets-timestamp + // tag::get-buckets-timestamp request.setTimestamp("2018-08-17T00:00:00Z"); // <1> - // end::x-pack-ml-get-buckets-timestamp + // end::get-buckets-timestamp // Set timestamp to null as it is incompatible with other args request.setTimestamp(null); - // tag::x-pack-ml-get-buckets-anomaly-score + // tag::get-buckets-anomaly-score request.setAnomalyScore(75.0); // <1> - // end::x-pack-ml-get-buckets-anomaly-score + // end::get-buckets-anomaly-score - // tag::x-pack-ml-get-buckets-desc + // tag::get-buckets-desc request.setDescending(true); // <1> - // end::x-pack-ml-get-buckets-desc + // end::get-buckets-desc - // tag::x-pack-ml-get-buckets-end + // tag::get-buckets-end request.setEnd("2018-08-21T00:00:00Z"); // <1> - // end::x-pack-ml-get-buckets-end + // end::get-buckets-end - // tag::x-pack-ml-get-buckets-exclude-interim + // tag::get-buckets-exclude-interim request.setExcludeInterim(true); // <1> - // end::x-pack-ml-get-buckets-exclude-interim + // end::get-buckets-exclude-interim - // tag::x-pack-ml-get-buckets-expand + // tag::get-buckets-expand request.setExpand(true); // <1> - // end::x-pack-ml-get-buckets-expand + // end::get-buckets-expand - // tag::x-pack-ml-get-buckets-page + // tag::get-buckets-page request.setPageParams(new PageParams(100, 200)); // <1> - // end::x-pack-ml-get-buckets-page + // end::get-buckets-page // Set page params back to null so the response contains the bucket we indexed request.setPageParams(null); - // tag::x-pack-ml-get-buckets-sort + // tag::get-buckets-sort request.setSort("anomaly_score"); // <1> - // end::x-pack-ml-get-buckets-sort + // end::get-buckets-sort - // tag::x-pack-ml-get-buckets-start + // tag::get-buckets-start request.setStart("2018-08-01T00:00:00Z"); // <1> - // end::x-pack-ml-get-buckets-start + // end::get-buckets-start - // tag::x-pack-ml-get-buckets-execute + // tag::get-buckets-execute GetBucketsResponse response = client.machineLearning().getBuckets(request, RequestOptions.DEFAULT); - // end::x-pack-ml-get-buckets-execute + // end::get-buckets-execute - // tag::x-pack-ml-get-buckets-response + // tag::get-buckets-response long count = response.count(); // <1> List buckets = response.buckets(); // <2> - // end::x-pack-ml-get-buckets-response + // end::get-buckets-response assertEquals(1, buckets.size()); } { GetBucketsRequest request = new GetBucketsRequest(jobId); - // tag::x-pack-ml-get-buckets-listener + // tag::get-buckets-execute-listener ActionListener listener = new ActionListener() { @Override @@ -1067,15 +1086,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-get-buckets-listener + // end::get-buckets-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-get-buckets-execute-async + // tag::get-buckets-execute-async client.machineLearning().getBucketsAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-get-buckets-execute-async + // end::get-buckets-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1093,30 +1112,30 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().openJob(new OpenJobRequest(secondJob.getId()), RequestOptions.DEFAULT); { - //tag::x-pack-ml-flush-job-request + // tag::flush-job-request FlushJobRequest flushJobRequest = new FlushJobRequest("flushing-my-first-machine-learning-job"); // <1> - //end::x-pack-ml-flush-job-request + // end::flush-job-request - //tag::x-pack-ml-flush-job-request-options + // tag::flush-job-request-options flushJobRequest.setCalcInterim(true); // <1> flushJobRequest.setAdvanceTime("2018-08-31T16:35:07+00:00"); // <2> flushJobRequest.setStart("2018-08-31T16:35:17+00:00"); // <3> flushJobRequest.setEnd("2018-08-31T16:35:27+00:00"); // <4> flushJobRequest.setSkipTime("2018-08-31T16:35:00+00:00"); // <5> - //end::x-pack-ml-flush-job-request-options + // end::flush-job-request-options - //tag::x-pack-ml-flush-job-execute + // tag::flush-job-execute FlushJobResponse flushJobResponse = client.machineLearning().flushJob(flushJobRequest, RequestOptions.DEFAULT); - //end::x-pack-ml-flush-job-execute + // end::flush-job-execute - //tag::x-pack-ml-flush-job-response + // tag::flush-job-response boolean isFlushed = flushJobResponse.isFlushed(); // <1> Date lastFinalizedBucketEnd = flushJobResponse.getLastFinalizedBucketEnd(); // <2> - //end::x-pack-ml-flush-job-response + // end::flush-job-response } { - //tag::x-pack-ml-flush-job-listener + // tag::flush-job-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(FlushJobResponse FlushJobResponse) { @@ -1128,16 +1147,16 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - //end::x-pack-ml-flush-job-listener + // end::flush-job-execute-listener FlushJobRequest flushJobRequest = new FlushJobRequest("flushing-my-second-machine-learning-job"); // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-flush-job-execute-async + // tag::flush-job-execute-async client.machineLearning().flushJobAsync(flushJobRequest, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-flush-job-execute-async + // end::flush-job-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1174,27 +1193,27 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { }, 30, TimeUnit.SECONDS); { - //tag::x-pack-ml-delete-forecast-request + // tag::delete-forecast-request DeleteForecastRequest deleteForecastRequest = new DeleteForecastRequest("deleting-forecast-for-job"); // <1> - //end::x-pack-ml-delete-forecast-request + // end::delete-forecast-request - //tag::x-pack-ml-delete-forecast-request-options + // tag::delete-forecast-request-options deleteForecastRequest.setForecastIds(forecastId); // <1> deleteForecastRequest.timeout("30s"); // <2> deleteForecastRequest.setAllowNoForecasts(true); // <3> - //end::x-pack-ml-delete-forecast-request-options + // end::delete-forecast-request-options - //tag::x-pack-ml-delete-forecast-execute + // tag::delete-forecast-execute AcknowledgedResponse deleteForecastResponse = client.machineLearning().deleteForecast(deleteForecastRequest, RequestOptions.DEFAULT); - //end::x-pack-ml-delete-forecast-execute + // end::delete-forecast-execute - //tag::x-pack-ml-delete-forecast-response + // tag::delete-forecast-response boolean isAcknowledged = deleteForecastResponse.isAcknowledged(); // <1> - //end::x-pack-ml-delete-forecast-response + // end::delete-forecast-response } { - //tag::x-pack-ml-delete-forecast-listener + // tag::delete-forecast-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(AcknowledgedResponse DeleteForecastResponse) { @@ -1206,7 +1225,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - //end::x-pack-ml-delete-forecast-listener + // end::delete-forecast-execute-listener DeleteForecastRequest deleteForecastRequest = DeleteForecastRequest.deleteAllForecasts(job.getId()); deleteForecastRequest.setAllowNoForecasts(true); @@ -1214,9 +1233,9 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-delete-forecast-execute-async + // tag::delete-forecast-execute-async client.machineLearning().deleteForecastAsync(deleteForecastRequest, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-delete-forecast-execute-async + // end::delete-forecast-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1232,19 +1251,19 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().putJob(new PutJobRequest(secondJob), RequestOptions.DEFAULT); { - //tag::x-pack-ml-get-job-stats-request + // tag::get-job-stats-request GetJobStatsRequest request = new GetJobStatsRequest("get-machine-learning-job-stats1", "get-machine-learning-job-*"); // <1> request.setAllowNoJobs(true); // <2> - //end::x-pack-ml-get-job-stats-request + // end::get-job-stats-request - //tag::x-pack-ml-get-job-stats-execute + // tag::get-job-stats-execute GetJobStatsResponse response = client.machineLearning().getJobStats(request, RequestOptions.DEFAULT); - //end::x-pack-ml-get-job-stats-execute + // end::get-job-stats-execute - //tag::x-pack-ml-get-job-stats-response + // tag::get-job-stats-response long numberOfJobStats = response.count(); // <1> List jobStats = response.jobStats(); // <2> - //end::x-pack-ml-get-job-stats-response + // end::get-job-stats-response assertEquals(2, response.count()); assertThat(response.jobStats(), hasSize(2)); @@ -1254,7 +1273,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { { GetJobStatsRequest request = new GetJobStatsRequest("get-machine-learning-job-stats1", "get-machine-learning-job-*"); - // tag::x-pack-ml-get-job-stats-listener + // tag::get-job-stats-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(GetJobStatsResponse response) { @@ -1266,15 +1285,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-get-job-stats-listener + // end::get-job-stats-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-get-job-stats-execute-async + // tag::get-job-stats-execute-async client.machineLearning().getJobStatsAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-get-job-stats-execute-async + // end::get-job-stats-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1299,28 +1318,28 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().flushJob(new FlushJobRequest(job.getId()), RequestOptions.DEFAULT); { - //tag::x-pack-ml-forecast-job-request + // tag::forecast-job-request ForecastJobRequest forecastJobRequest = new ForecastJobRequest("forecasting-my-first-machine-learning-job"); // <1> - //end::x-pack-ml-forecast-job-request + // end::forecast-job-request - //tag::x-pack-ml-forecast-job-request-options + // tag::forecast-job-request-options forecastJobRequest.setExpiresIn(TimeValue.timeValueHours(48)); // <1> forecastJobRequest.setDuration(TimeValue.timeValueHours(24)); // <2> - //end::x-pack-ml-forecast-job-request-options + // end::forecast-job-request-options - //tag::x-pack-ml-forecast-job-execute + // tag::forecast-job-execute ForecastJobResponse forecastJobResponse = client.machineLearning().forecastJob(forecastJobRequest, RequestOptions.DEFAULT); - //end::x-pack-ml-forecast-job-execute + // end::forecast-job-execute - //tag::x-pack-ml-forecast-job-response + // tag::forecast-job-response boolean isAcknowledged = forecastJobResponse.isAcknowledged(); // <1> String forecastId = forecastJobResponse.getForecastId(); // <2> - //end::x-pack-ml-forecast-job-response + // end::forecast-job-response assertTrue(isAcknowledged); assertNotNull(forecastId); } { - //tag::x-pack-ml-forecast-job-listener + // tag::forecast-job-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(ForecastJobResponse forecastJobResponse) { @@ -1332,16 +1351,16 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - //end::x-pack-ml-forecast-job-listener + // end::forecast-job-execute-listener ForecastJobRequest forecastJobRequest = new ForecastJobRequest("forecasting-my-first-machine-learning-job"); // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-forecast-job-execute-async + // tag::forecast-job-execute-async client.machineLearning().forecastJobAsync(forecastJobRequest, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-forecast-job-execute-async + // end::forecast-job-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1377,42 +1396,42 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.bulk(bulkRequest, RequestOptions.DEFAULT); { - // tag::x-pack-ml-get-overall-buckets-request + // tag::get-overall-buckets-request GetOverallBucketsRequest request = new GetOverallBucketsRequest(jobId1, jobId2); // <1> - // end::x-pack-ml-get-overall-buckets-request + // end::get-overall-buckets-request - // tag::x-pack-ml-get-overall-buckets-bucket-span + // tag::get-overall-buckets-bucket-span request.setBucketSpan(TimeValue.timeValueHours(24)); // <1> - // end::x-pack-ml-get-overall-buckets-bucket-span + // end::get-overall-buckets-bucket-span - // tag::x-pack-ml-get-overall-buckets-end + // tag::get-overall-buckets-end request.setEnd("2018-08-21T00:00:00Z"); // <1> - // end::x-pack-ml-get-overall-buckets-end + // end::get-overall-buckets-end - // tag::x-pack-ml-get-overall-buckets-exclude-interim + // tag::get-overall-buckets-exclude-interim request.setExcludeInterim(true); // <1> - // end::x-pack-ml-get-overall-buckets-exclude-interim + // end::get-overall-buckets-exclude-interim - // tag::x-pack-ml-get-overall-buckets-overall-score + // tag::get-overall-buckets-overall-score request.setOverallScore(75.0); // <1> - // end::x-pack-ml-get-overall-buckets-overall-score + // end::get-overall-buckets-overall-score - // tag::x-pack-ml-get-overall-buckets-start + // tag::get-overall-buckets-start request.setStart("2018-08-01T00:00:00Z"); // <1> - // end::x-pack-ml-get-overall-buckets-start + // end::get-overall-buckets-start - // tag::x-pack-ml-get-overall-buckets-top-n + // tag::get-overall-buckets-top-n request.setTopN(2); // <1> - // end::x-pack-ml-get-overall-buckets-top-n + // end::get-overall-buckets-top-n - // tag::x-pack-ml-get-overall-buckets-execute + // tag::get-overall-buckets-execute GetOverallBucketsResponse response = client.machineLearning().getOverallBuckets(request, RequestOptions.DEFAULT); - // end::x-pack-ml-get-overall-buckets-execute + // end::get-overall-buckets-execute - // tag::x-pack-ml-get-overall-buckets-response + // tag::get-overall-buckets-response long count = response.count(); // <1> List overallBuckets = response.overallBuckets(); // <2> - // end::x-pack-ml-get-overall-buckets-response + // end::get-overall-buckets-response assertEquals(1, overallBuckets.size()); assertThat(overallBuckets.get(0).getOverallScore(), is(closeTo(80.0, 0.001))); @@ -1421,7 +1440,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { { GetOverallBucketsRequest request = new GetOverallBucketsRequest(jobId1, jobId2); - // tag::x-pack-ml-get-overall-buckets-listener + // tag::get-overall-buckets-execute-listener ActionListener listener = new ActionListener() { @Override @@ -1434,15 +1453,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-get-overall-buckets-listener + // end::get-overall-buckets-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-get-overall-buckets-execute-async + // tag::get-overall-buckets-execute-async client.machineLearning().getOverallBucketsAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-get-overall-buckets-execute-async + // end::get-overall-buckets-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1463,55 +1482,55 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.index(indexRequest, RequestOptions.DEFAULT); { - // tag::x-pack-ml-get-records-request + // tag::get-records-request GetRecordsRequest request = new GetRecordsRequest(jobId); // <1> - // end::x-pack-ml-get-records-request + // end::get-records-request - // tag::x-pack-ml-get-records-desc + // tag::get-records-desc request.setDescending(true); // <1> - // end::x-pack-ml-get-records-desc + // end::get-records-desc - // tag::x-pack-ml-get-records-end + // tag::get-records-end request.setEnd("2018-08-21T00:00:00Z"); // <1> - // end::x-pack-ml-get-records-end + // end::get-records-end - // tag::x-pack-ml-get-records-exclude-interim + // tag::get-records-exclude-interim request.setExcludeInterim(true); // <1> - // end::x-pack-ml-get-records-exclude-interim + // end::get-records-exclude-interim - // tag::x-pack-ml-get-records-page + // tag::get-records-page request.setPageParams(new PageParams(100, 200)); // <1> - // end::x-pack-ml-get-records-page + // end::get-records-page // Set page params back to null so the response contains the record we indexed request.setPageParams(null); - // tag::x-pack-ml-get-records-record-score + // tag::get-records-record-score request.setRecordScore(75.0); // <1> - // end::x-pack-ml-get-records-record-score + // end::get-records-record-score - // tag::x-pack-ml-get-records-sort + // tag::get-records-sort request.setSort("probability"); // <1> - // end::x-pack-ml-get-records-sort + // end::get-records-sort - // tag::x-pack-ml-get-records-start + // tag::get-records-start request.setStart("2018-08-01T00:00:00Z"); // <1> - // end::x-pack-ml-get-records-start + // end::get-records-start - // tag::x-pack-ml-get-records-execute + // tag::get-records-execute GetRecordsResponse response = client.machineLearning().getRecords(request, RequestOptions.DEFAULT); - // end::x-pack-ml-get-records-execute + // end::get-records-execute - // tag::x-pack-ml-get-records-response + // tag::get-records-response long count = response.count(); // <1> List records = response.records(); // <2> - // end::x-pack-ml-get-records-response + // end::get-records-response assertEquals(1, records.size()); } { GetRecordsRequest request = new GetRecordsRequest(jobId); - // tag::x-pack-ml-get-records-listener + // tag::get-records-execute-listener ActionListener listener = new ActionListener() { @Override @@ -1524,15 +1543,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-get-records-listener + // end::get-records-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-get-records-execute-async + // tag::get-records-execute-async client.machineLearning().getRecordsAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-get-records-execute-async + // end::get-records-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1546,35 +1565,35 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.machineLearning().openJob(new OpenJobRequest(job.getId()), RequestOptions.DEFAULT); { - //tag::x-pack-ml-post-data-request + // tag::post-data-request PostDataRequest.JsonBuilder jsonBuilder = new PostDataRequest.JsonBuilder(); // <1> Map mapData = new HashMap<>(); mapData.put("total", 109); jsonBuilder.addDoc(mapData); // <2> jsonBuilder.addDoc("{\"total\":1000}"); // <3> PostDataRequest postDataRequest = new PostDataRequest("test-post-data", jsonBuilder); // <4> - //end::x-pack-ml-post-data-request + // end::post-data-request - //tag::x-pack-ml-post-data-request-options + // tag::post-data-request-options postDataRequest.setResetStart("2018-08-31T16:35:07+00:00"); // <1> postDataRequest.setResetEnd("2018-08-31T16:35:17+00:00"); // <2> - //end::x-pack-ml-post-data-request-options + // end::post-data-request-options postDataRequest.setResetEnd(null); postDataRequest.setResetStart(null); - //tag::x-pack-ml-post-data-execute + // tag::post-data-execute PostDataResponse postDataResponse = client.machineLearning().postData(postDataRequest, RequestOptions.DEFAULT); - //end::x-pack-ml-post-data-execute + // end::post-data-execute - //tag::x-pack-ml-post-data-response + // tag::post-data-response DataCounts dataCounts = postDataResponse.getDataCounts(); // <1> - //end::x-pack-ml-post-data-response + // end::post-data-response assertEquals(2, dataCounts.getInputRecordCount()); } { - //tag::x-pack-ml-post-data-listener + // tag::post-data-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(PostDataResponse postDataResponse) { @@ -1586,7 +1605,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - //end::x-pack-ml-post-data-listener + // end::post-data-execute-listener PostDataRequest.JsonBuilder jsonBuilder = new PostDataRequest.JsonBuilder(); Map mapData = new HashMap<>(); mapData.put("total", 109); @@ -1597,9 +1616,9 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-post-data-execute-async + // tag::post-data-execute-async client.machineLearning().postDataAsync(postDataRequest, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-post-data-execute-async + // end::post-data-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1621,55 +1640,55 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.index(indexRequest, RequestOptions.DEFAULT); { - // tag::x-pack-ml-get-influencers-request + // tag::get-influencers-request GetInfluencersRequest request = new GetInfluencersRequest(jobId); // <1> - // end::x-pack-ml-get-influencers-request + // end::get-influencers-request - // tag::x-pack-ml-get-influencers-desc + // tag::get-influencers-desc request.setDescending(true); // <1> - // end::x-pack-ml-get-influencers-desc + // end::get-influencers-desc - // tag::x-pack-ml-get-influencers-end + // tag::get-influencers-end request.setEnd("2018-08-21T00:00:00Z"); // <1> - // end::x-pack-ml-get-influencers-end + // end::get-influencers-end - // tag::x-pack-ml-get-influencers-exclude-interim + // tag::get-influencers-exclude-interim request.setExcludeInterim(true); // <1> - // end::x-pack-ml-get-influencers-exclude-interim + // end::get-influencers-exclude-interim - // tag::x-pack-ml-get-influencers-influencer-score + // tag::get-influencers-influencer-score request.setInfluencerScore(75.0); // <1> - // end::x-pack-ml-get-influencers-influencer-score + // end::get-influencers-influencer-score - // tag::x-pack-ml-get-influencers-page + // tag::get-influencers-page request.setPageParams(new PageParams(100, 200)); // <1> - // end::x-pack-ml-get-influencers-page + // end::get-influencers-page // Set page params back to null so the response contains the influencer we indexed request.setPageParams(null); - // tag::x-pack-ml-get-influencers-sort + // tag::get-influencers-sort request.setSort("probability"); // <1> - // end::x-pack-ml-get-influencers-sort + // end::get-influencers-sort - // tag::x-pack-ml-get-influencers-start + // tag::get-influencers-start request.setStart("2018-08-01T00:00:00Z"); // <1> - // end::x-pack-ml-get-influencers-start + // end::get-influencers-start - // tag::x-pack-ml-get-influencers-execute + // tag::get-influencers-execute GetInfluencersResponse response = client.machineLearning().getInfluencers(request, RequestOptions.DEFAULT); - // end::x-pack-ml-get-influencers-execute + // end::get-influencers-execute - // tag::x-pack-ml-get-influencers-response + // tag::get-influencers-response long count = response.count(); // <1> List influencers = response.influencers(); // <2> - // end::x-pack-ml-get-influencers-response + // end::get-influencers-response assertEquals(1, influencers.size()); } { GetInfluencersRequest request = new GetInfluencersRequest(jobId); - // tag::x-pack-ml-get-influencers-listener + // tag::get-influencers-execute-listener ActionListener listener = new ActionListener() { @Override @@ -1682,15 +1701,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-get-influencers-listener + // end::get-influencers-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-get-influencers-execute-async + // tag::get-influencers-execute-async client.machineLearning().getInfluencersAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-get-influencers-execute-async + // end::get-influencers-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1711,35 +1730,35 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { client.index(indexRequest, RequestOptions.DEFAULT); { - // tag::x-pack-ml-get-categories-request + // tag::get-categories-request GetCategoriesRequest request = new GetCategoriesRequest(jobId); // <1> - // end::x-pack-ml-get-categories-request + // end::get-categories-request - // tag::x-pack-ml-get-categories-category-id + // tag::get-categories-category-id request.setCategoryId(1L); // <1> - // end::x-pack-ml-get-categories-category-id + // end::get-categories-category-id - // tag::x-pack-ml-get-categories-page + // tag::get-categories-page request.setPageParams(new PageParams(100, 200)); // <1> - // end::x-pack-ml-get-categories-page + // end::get-categories-page // Set page params back to null so the response contains the category we indexed request.setPageParams(null); - // tag::x-pack-ml-get-categories-execute + // tag::get-categories-execute GetCategoriesResponse response = client.machineLearning().getCategories(request, RequestOptions.DEFAULT); - // end::x-pack-ml-get-categories-execute + // end::get-categories-execute - // tag::x-pack-ml-get-categories-response + // tag::get-categories-response long count = response.count(); // <1> List categories = response.categories(); // <2> - // end::x-pack-ml-get-categories-response + // end::get-categories-response assertEquals(1, categories.size()); } { GetCategoriesRequest request = new GetCategoriesRequest(jobId); - // tag::x-pack-ml-get-categories-listener + // tag::get-categories-execute-listener ActionListener listener = new ActionListener() { @Override @@ -1752,15 +1771,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-get-categories-listener + // end::get-categories-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-get-categories-execute-async + // tag::get-categories-execute-async client.machineLearning().getCategoriesAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-get-categories-execute-async + // end::get-categories-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1769,21 +1788,21 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { public void testPutCalendar() throws IOException, InterruptedException { RestHighLevelClient client = highLevelClient(); - //tag::x-pack-ml-put-calendar-request + // tag::put-calendar-request Calendar calendar = new Calendar("public_holidays", Collections.singletonList("job_1"), "A calendar for public holidays"); PutCalendarRequest request = new PutCalendarRequest(calendar); // <1> - //end::x-pack-ml-put-calendar-request + // end::put-calendar-request - //tag::x-pack-ml-put-calendar-execution + // tag::put-calendar-execute PutCalendarResponse response = client.machineLearning().putCalendar(request, RequestOptions.DEFAULT); - //end::x-pack-ml-put-calendar-execution + // end::put-calendar-execute - //tag::x-pack-ml-put-calendar-response + // tag::put-calendar-response Calendar newCalendar = response.getCalendar(); // <1> - //end::x-pack-ml-put-calendar-response + // end::put-calendar-response assertThat(newCalendar.getId(), equalTo("public_holidays")); - // tag::x-pack-ml-put-calendar-listener + // tag::put-calendar-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(PutCalendarResponse response) { @@ -1795,15 +1814,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-put-calendar-listener + // end::put-calendar-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-put-calendar-execute-async + // tag::put-calendar-execute-async client.machineLearning().putCalendarAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-put-calendar-execute-async + // end::put-calendar-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1815,35 +1834,35 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { PutCalendarRequest putRequest = new PutCalendarRequest(calendar); client.machineLearning().putCalendar(putRequest, RequestOptions.DEFAULT); { - //tag::x-pack-ml-get-calendars-request + // tag::get-calendars-request GetCalendarsRequest request = new GetCalendarsRequest(); // <1> - //end::x-pack-ml-get-calendars-request + // end::get-calendars-request - //tag::x-pack-ml-get-calendars-id + // tag::get-calendars-id request.setCalendarId("holidays"); // <1> - //end::x-pack-ml-get-calendars-id + // end::get-calendars-id - //tag::x-pack-ml-get-calendars-page + // tag::get-calendars-page request.setPageParams(new PageParams(10, 20)); // <1> - //end::x-pack-ml-get-calendars-page + // end::get-calendars-page // reset page params request.setPageParams(null); - //tag::x-pack-ml-get-calendars-execution + // tag::get-calendars-execute GetCalendarsResponse response = client.machineLearning().getCalendars(request, RequestOptions.DEFAULT); - //end::x-pack-ml-get-calendars-execution + // end::get-calendars-execute - // tag::x-pack-ml-get-calendars-response + // tag::get-calendars-response long count = response.count(); // <1> List calendars = response.calendars(); // <2> - // end::x-pack-ml-get-calendars-response + // end::get-calendars-response assertEquals(1, calendars.size()); } { GetCalendarsRequest request = new GetCalendarsRequest("holidays"); - // tag::x-pack-ml-get-calendars-listener + // tag::get-calendars-execute-listener ActionListener listener = new ActionListener() { @Override @@ -1856,15 +1875,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-get-calendars-listener + // end::get-calendars-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-get-calendars-execute-async + // tag::get-calendars-execute-async client.machineLearning().getCalendarsAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-get-calendars-execute-async + // end::get-calendars-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } @@ -1877,21 +1896,21 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { PutCalendarRequest putCalendarRequest = new PutCalendarRequest(calendar); client.machineLearning().putCalendar(putCalendarRequest, RequestOptions.DEFAULT); - //tag::x-pack-ml-delete-calendar-request + // tag::delete-calendar-request DeleteCalendarRequest request = new DeleteCalendarRequest("holidays"); // <1> - //end::x-pack-ml-delete-calendar-request + // end::delete-calendar-request - //tag::x-pack-ml-delete-calendar-execute + // tag::delete-calendar-execute AcknowledgedResponse response = client.machineLearning().deleteCalendar(request, RequestOptions.DEFAULT); - //end::x-pack-ml-delete-calendar-execute + // end::delete-calendar-execute - //tag::x-pack-ml-delete-calendar-response + // tag::delete-calendar-response boolean isAcknowledged = response.isAcknowledged(); // <1> - //end::x-pack-ml-delete-calendar-response + // end::delete-calendar-response assertTrue(isAcknowledged); - // tag::x-pack-ml-delete-calendar-listener + // tag::delete-calendar-execute-listener ActionListener listener = new ActionListener() { @Override public void onResponse(AcknowledgedResponse response) { @@ -1903,15 +1922,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase { // <2> } }; - // end::x-pack-ml-delete-calendar-listener + // end::delete-calendar-execute-listener // Replace the empty listener by a blocking listener in test final CountDownLatch latch = new CountDownLatch(1); listener = new LatchedActionListener<>(listener, latch); - // tag::x-pack-ml-delete-calendar-execute-async + // tag::delete-calendar-execute-async client.machineLearning().deleteCalendarAsync(request, RequestOptions.DEFAULT, listener); // <1> - // end::x-pack-ml-delete-calendar-execute-async + // end::delete-calendar-execute-async assertTrue(latch.await(30L, TimeUnit.SECONDS)); } diff --git a/docs/java-rest/high-level/ml/close-job.asciidoc b/docs/java-rest/high-level/ml/close-job.asciidoc index edadb9f40a2..8a38b498629 100644 --- a/docs/java-rest/high-level/ml/close-job.asciidoc +++ b/docs/java-rest/high-level/ml/close-job.asciidoc @@ -1,18 +1,23 @@ -[[java-rest-high-x-pack-ml-close-job]] +-- +:api: close-job +:request: CloseJobRequest +:response: CloseJobResponse +-- +[id="{upid}-{api}"] === Close Job API The Close Job API provides the ability to close {ml} jobs in the cluster. -It accepts a `CloseJobRequest` object and responds -with a `CloseJobResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-close-job-request]] +[id="{upid}-{api}-request"] ==== Close Job Request -A `CloseJobRequest` object gets created with an existing non-null `jobId`. +A +{request}+ object gets created with an existing non-null `jobId`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-close-job-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing existing job IDs <2> Optionally used to close a failed job, or to forcefully close a job @@ -22,38 +27,14 @@ which has not responded to its initial close request. <4> Optionally setting the `timeout` value for how long the execution should wait for the job to be closed. -[[java-rest-high-x-pack-ml-close-job-execution]] -==== Execution - -The request can be executed through the `MachineLearningClient` contained -in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method. +[id="{upid}-{api}-response"] +==== Close Job Response ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-close-job-execute] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- -<1> `isClosed()` from the `CloseJobResponse` indicates if the job was successfully +<1> `isClosed()` from the +{response}+ indicates if the job was successfully closed or not. -[[java-rest-high-x-pack-ml-close-job-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-close-job-execute-async] --------------------------------------------------- -<1> The `CloseJobRequest` 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 `CloseJobResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-close-job-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs +include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/ml/delete-calendar.asciidoc b/docs/java-rest/high-level/ml/delete-calendar.asciidoc index 8f25576a96f..e7d5318a465 100644 --- a/docs/java-rest/high-level/ml/delete-calendar.asciidoc +++ b/docs/java-rest/high-level/ml/delete-calendar.asciidoc @@ -1,59 +1,33 @@ -[[java-rest-high-x-pack-ml-delete-calendar]] +-- +:api: delete-calendar +:request: DeleteCalendarRequest +:response: AcknowledgedResponse +-- +[id="{upid}-{api}"] === Delete Calendar API Delete a {ml} calendar. -The API accepts a `DeleteCalendarRequest` and responds -with a `AcknowledgedResponse` object. +The API accepts a +{request}+ and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-delete-calendar-request]] +[id="{upid}-{api}-request"] ==== Delete Calendar Request A `DeleteCalendar` object requires a non-null `calendarId`. ["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-calendar-request] +include-tagged::{doc-tests-file}[{api}-request] --------------------------------------------------- <1> Constructing a new request referencing an existing Calendar -[[java-rest-high-x-pack-ml-delete-calendar-response]] +[id="{upid}-{api}-response"] ==== Delete Calendar Response -The returned `AcknowledgedResponse` object indicates the acknowledgement of the request: +The returned +{response}+ object indicates the acknowledgement of the request: ["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-calendar-response] +include-tagged::{doc-tests-file}[{api}-response] --------------------------------------------------- <1> `isAcknowledged` was the deletion request acknowledged or not -[[java-rest-high-x-pack-ml-delete-calendar-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-delete-calendar-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-delete-calendar-async]] -==== Delete Calendar Asynchronously - -This request can also be made asynchronously. -["source","java",subs="attributes,callouts,macros"] ---------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-calendar-execute-async] ---------------------------------------------------- -<1> The `DeleteCalendarRequest` to execute and the `ActionListener` to alert on completion or error. - -The deletion request returns immediately. Once the request is completed, the `ActionListener` is -called back using the `onResponse` or `onFailure`. The latter indicates some failure occurred when -making the request. - -A typical listener for a `DeleteCalendarRequest` could be defined as follows: - -["source","java",subs="attributes,callouts,macros"] ---------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-calendar-listener] ---------------------------------------------------- -<1> The action to be taken when it is completed -<2> What to do when a failure occurs +include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/ml/delete-datafeed.asciidoc b/docs/java-rest/high-level/ml/delete-datafeed.asciidoc index 68741651b33..02bfafd7951 100644 --- a/docs/java-rest/high-level/ml/delete-datafeed.asciidoc +++ b/docs/java-rest/high-level/ml/delete-datafeed.asciidoc @@ -1,49 +1,32 @@ -[[java-rest-high-x-pack-ml-delete-datafeed]] +-- +:api: delete-datafeed +:request: DeleteDatafeedRequest +:response: AcknowledgedResponse +-- +[id="{upid}-delete-datafeed"] === Delete Datafeed API -[[java-rest-high-x-pack-machine-learning-delete-datafeed-request]] +[id="{upid}-{api}-request"] ==== Delete Datafeed Request -A `DeleteDatafeedRequest` object requires a non-null `datafeedId` and can optionally set `force`. -Can be executed as follows: +A +{request}+ object requires a non-null `datafeedId` and can optionally set `force`. ["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-datafeed-request] +include-tagged::{doc-tests-file}[{api}-request] --------------------------------------------------- <1> Use to forcefully delete a started datafeed; this method is quicker than stopping and deleting the datafeed. Defaults to `false`. -[[java-rest-high-x-pack-machine-learning-delete-datafeed-response]] +include::../execution.asciidoc[] + +[id="{upid}-{api}-response"] ==== Delete Datafeed Response -The returned `AcknowledgedResponse` object indicates the acknowledgement of the request: +The returned +{response}+ object indicates the acknowledgement of the request: ["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-datafeed-response] +include-tagged::{doc-tests-file}[{api}-response] --------------------------------------------------- <1> `isAcknowledged` was the deletion request acknowledged or not - -[[java-rest-high-x-pack-machine-learning-delete-datafeed-async]] -==== Delete Datafeed Asynchronously - -This request can also be made asynchronously. -["source","java",subs="attributes,callouts,macros"] ---------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-datafeed-request-async] ---------------------------------------------------- -<1> The `DeleteDatafeedRequest` to execute and the `ActionListener` to alert on completion or error. - -The deletion request returns immediately. Once the request is completed, the `ActionListener` is -called back using the `onResponse` or `onFailure`. The latter indicates some failure occurred when -making the request. - -A typical listener for a `DeleteDatafeedRequest` could be defined as follows: - -["source","java",subs="attributes,callouts,macros"] ---------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-datafeed-request-listener] ---------------------------------------------------- -<1> The action to be taken when it is completed -<2> What to do when a failure occurs diff --git a/docs/java-rest/high-level/ml/delete-forecast.asciidoc b/docs/java-rest/high-level/ml/delete-forecast.asciidoc index 09aa5c734ff..961254b4815 100644 --- a/docs/java-rest/high-level/ml/delete-forecast.asciidoc +++ b/docs/java-rest/high-level/ml/delete-forecast.asciidoc @@ -1,20 +1,25 @@ -[[java-rest-high-x-pack-ml-delete-forecast]] +-- +:api: delete-forecast +:request: DeleteForecastRequest +:response: AcknowledgedResponse +-- +[id="{upid}-{api}"] === Delete Forecast API The Delete Forecast API provides the ability to delete a {ml} job's forecast in the cluster. -It accepts a `DeleteForecastRequest` object and responds -with an `AcknowledgedResponse` object. +It accepts a +{request}+ object and responds +with an +{response}+ object. -[[java-rest-high-x-pack-ml-delete-forecast-request]] +[id="{upid}-{api}-request"] ==== Delete Forecast Request -A `DeleteForecastRequest` object gets created with an existing non-null `jobId`. +A +{request}+ object gets created with an existing non-null `jobId`. All other fields are optional for the request. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-forecast-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing an existing `jobId` @@ -24,55 +29,23 @@ The following arguments are optional. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-forecast-request-options] +include-tagged::{doc-tests-file}[{api}-request-options] -------------------------------------------------- <1> Sets the specific forecastIds to delete, can be set to `_all` to indicate ALL forecasts for the given `jobId` <2> Set the timeout for the request to respond, default is 30 seconds <3> Set the `allow_no_forecasts` option. When `true` no error will be returned if an `_all` -request finds no forecasts. It defaults to `true` +request finds no forecasts. It defaults to `true` -[[java-rest-high-x-pack-ml-delete-forecast-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-delete-forecast-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-delete-forecast-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-delete-forecast-execute-async] --------------------------------------------------- -<1> The `DeleteForecastRequest` 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 `AcknowledgedResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-forecast-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-delete-forecast-response]] +[id="{upid}-{api}-response"] ==== Delete Forecast Response -An `AcknowledgedResponse` contains an acknowledgement of the forecast(s) deletion +An +{response}+ contains an acknowledgement of the forecast(s) deletion ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-delete-forecast-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> `isAcknowledged()` indicates if the forecast was successfully deleted or not. + +include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/ml/delete-job.asciidoc b/docs/java-rest/high-level/ml/delete-job.asciidoc index 7cdc4149b23..a8c6b276dd4 100644 --- a/docs/java-rest/high-level/ml/delete-job.asciidoc +++ b/docs/java-rest/high-level/ml/delete-job.asciidoc @@ -1,14 +1,19 @@ -[[java-rest-high-x-pack-ml-delete-job]] +-- +:api: delete-job +:request: DeleteJobRequest +:response: AcknowledgedResponse +-- +[id="{upid}-{api}"] === Delete Job API -[[java-rest-high-x-pack-machine-learning-delete-job-request]] +[id="{upid}-{api}-request"] ==== Delete Job Request -A `DeleteJobRequest` object requires a non-null `jobId`. +A +{request}+ object requires a non-null `jobId` and can optionally set `force`. ["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request] +include-tagged::{doc-tests-file}[{api}-request] --------------------------------------------------- <1> Constructing a new request referencing an existing `jobId` @@ -18,7 +23,7 @@ The following arguments are optional: ["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request-force] +include-tagged::{doc-tests-file}[{api}-request-force] --------------------------------------------------- <1> Use to forcefully delete an opened job; this method is quicker than closing and deleting the job. @@ -26,55 +31,23 @@ Defaults to `false`. ["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request-wait-for-completion] +include-tagged::{doc-tests-file}[{api}-request-wait-for-completion] --------------------------------------------------- <1> Use to set whether the request should wait until the operation has completed before returning. Defaults to `true`. -[[java-rest-high-x-pack-machine-learning-delete-job-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-delete-ml-job-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-machine-learning-delete-job-response]] +[id="{upid}-{api}-response"] ==== Delete Job Response -The returned `DeleteJobResponse` object contains the acknowledgement of the -job deletion or the deletion task depending on whether the request was set -to wait for completion: +The returned +{response}+ object indicates the acknowledgement of the job deletion or +the deletion task depending on whether the request was set to wait for completion: ["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-response] +include-tagged::{doc-tests-file}[{api}-response] --------------------------------------------------- <1> whether was job deletion was acknowledged or not; will be `null` when set not to wait for completion <2> the id of the job deletion task; will be `null` when set to wait for completion -[[java-rest-high-x-pack-machine-learning-delete-job-async]] -==== Delete Job Asynchronously - -This request can also be made asynchronously. -["source","java",subs="attributes,callouts,macros"] ---------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request-async] ---------------------------------------------------- -<1> The `DeleteJobRequest` to execute and the `ActionListener` to alert on completion or error. - -The deletion request returns immediately. Once the request is completed, the `ActionListener` is -called back using the `onResponse` or `onFailure`. The latter indicates some failure occurred when -making the request. - -A typical listener for a `DeleteJobRequest` could be defined as follows: - -["source","java",subs="attributes,callouts,macros"] ---------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request-listener] ---------------------------------------------------- -<1> The action to be taken when it is completed -<2> What to do when a failure occurs +include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/ml/flush-job.asciidoc b/docs/java-rest/high-level/ml/flush-job.asciidoc index 1f815bba0d5..e721d48d4d1 100644 --- a/docs/java-rest/high-level/ml/flush-job.asciidoc +++ b/docs/java-rest/high-level/ml/flush-job.asciidoc @@ -1,20 +1,25 @@ -[[java-rest-high-x-pack-ml-flush-job]] +-- +:api: flush-job +:request: FlushJobRequest +:response: FlushJobResponse +-- +[id="{upid}-{api}"] === Flush Job API The Flush Job API provides the ability to flush a {ml} job's datafeed in the cluster. -It accepts a `FlushJobRequest` object and responds -with a `FlushJobResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-flush-job-request]] +[id="{upid}-{api}-request"] ==== Flush Job Request -A `FlushJobRequest` object gets created with an existing non-null `jobId`. +A +{request}+ object gets created with an existing non-null `jobId`. All other fields are optional for the request. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-flush-job-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing an existing `jobId` @@ -24,7 +29,7 @@ The following arguments are optional. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-flush-job-request-options] +include-tagged::{doc-tests-file}[{api}-request-options] -------------------------------------------------- <1> Set request to calculate the interim results <2> Set the advanced time to flush to the particular time value @@ -34,50 +39,18 @@ to calculate the interim results (requires `calc_interim` to be `true`) to calculate interim results (requires `calc_interim` to be `true`) <5> Set the skip time to skip a particular time value -[[java-rest-high-x-pack-ml-flush-job-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-flush-job-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-flush-job-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-flush-job-execute-async] --------------------------------------------------- -<1> The `FlushJobRequest` 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 `FlushJobResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-flush-job-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-flush-job-response]] +[id="{upid}-{api}-response"] ==== Flush Job Response -A `FlushJobResponse` contains an acknowledgement and an optional end date for the +A +{response}+ contains an acknowledgement and an optional end date for the last finalized bucket ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-flush-job-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> `isFlushed()` indicates if the job was successfully flushed or not. <2> `getLastFinalizedBucketEnd()` provides the timestamp -(in milliseconds-since-the-epoch) of the end of the last bucket that was processed. \ No newline at end of file +(in milliseconds-since-the-epoch) of the end of the last bucket that was processed. + +include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/ml/forecast-job.asciidoc b/docs/java-rest/high-level/ml/forecast-job.asciidoc index 88bd5fdb532..48d899d6814 100644 --- a/docs/java-rest/high-level/ml/forecast-job.asciidoc +++ b/docs/java-rest/high-level/ml/forecast-job.asciidoc @@ -1,20 +1,25 @@ -[[java-rest-high-x-pack-ml-forecast-job]] +-- +:api: forecast-job +:request: ForecastJobRequest +:response: ForecastJobResponse +-- +[id="{upid}-{api}"] === Forecast Job API The Forecast Job API provides the ability to forecast a {ml} job's behavior based on historical data. -It accepts a `ForecastJobRequest` object and responds -with a `ForecastJobResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-forecast-job-request]] +[id="{upid}-{api}-request"] ==== Forecast Job Request -A `ForecastJobRequest` object gets created with an existing non-null `jobId`. +A +{request}+ object gets created with an existing non-null `jobId`. All other fields are optional for the request. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-forecast-job-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing an existing `jobId` @@ -24,53 +29,21 @@ The following arguments are optional. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-forecast-job-request-options] +include-tagged::{doc-tests-file}[{api}-request-options] -------------------------------------------------- <1> Set when the forecast for the job should expire <2> Set how far into the future should the forecast predict -[[java-rest-high-x-pack-ml-forecast-job-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-forecast-job-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-forecast-job-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-forecast-job-execute-async] --------------------------------------------------- -<1> The `ForecastJobRequest` 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 `ForecastJobResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-forecast-job-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-forecast-job-response]] +[id="{upid}-{api}-response"] ==== Forecast Job Response -A `ForecastJobResponse` contains an acknowledgement and the forecast ID +A +{response}+ contains an acknowledgement and the forecast ID ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-forecast-job-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> `isAcknowledged()` indicates if the forecast was successful -<2> `getForecastId()` provides the ID of the forecast that was created \ No newline at end of file +<2> `getForecastId()` provides the ID of the forecast that was created + +include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/ml/get-buckets.asciidoc b/docs/java-rest/high-level/ml/get-buckets.asciidoc index f77b368a495..f150695befe 100644 --- a/docs/java-rest/high-level/ml/get-buckets.asciidoc +++ b/docs/java-rest/high-level/ml/get-buckets.asciidoc @@ -1,18 +1,23 @@ -[[java-rest-high-x-pack-ml-get-buckets]] +-- +:api: get-buckets +:request: GetBucketsRequest +:response: GetBucketsResponse +-- +[id="{upid}-{api}"] === Get Buckets API The Get Buckets API retrieves one or more bucket results. -It accepts a `GetBucketsRequest` object and responds -with a `GetBucketsResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-get-buckets-request]] +[id="{upid}-{api}-request"] ==== Get Buckets Request -A `GetBucketsRequest` object gets created with an existing non-null `jobId`. +A +{request}+ object gets created with an existing non-null `jobId`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing an existing `jobId` @@ -21,105 +26,69 @@ The following arguments are optional: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-timestamp] +include-tagged::{doc-tests-file}[{api}-timestamp] -------------------------------------------------- <1> The timestamp of the bucket to get. Otherwise it will return all buckets. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-anomaly-score] +include-tagged::{doc-tests-file}[{api}-anomaly-score] -------------------------------------------------- <1> Buckets with anomaly scores greater or equal than this value will be returned. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-desc] +include-tagged::{doc-tests-file}[{api}-desc] -------------------------------------------------- <1> If `true`, the buckets are sorted in descending order. Defaults to `false`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-end] +include-tagged::{doc-tests-file}[{api}-end] -------------------------------------------------- <1> Buckets with timestamps earlier than this time will be returned. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-exclude-interim] +include-tagged::{doc-tests-file}[{api}-exclude-interim] -------------------------------------------------- <1> If `true`, interim results will be excluded. Defaults to `false`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-expand] +include-tagged::{doc-tests-file}[{api}-expand] -------------------------------------------------- <1> If `true`, buckets will include their anomaly records. Defaults to `false`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-page] +include-tagged::{doc-tests-file}[{api}-page] -------------------------------------------------- <1> The page parameters `from` and `size`. `from` specifies the number of buckets to skip. `size` specifies the maximum number of buckets to get. Defaults to `0` and `100` respectively. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-sort] +include-tagged::{doc-tests-file}[{api}-sort] -------------------------------------------------- <1> The field to sort buckets on. Defaults to `timestamp`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-start] +include-tagged::{doc-tests-file}[{api}-start] -------------------------------------------------- <1> Buckets with timestamps on or after this time will be returned. -[[java-rest-high-x-pack-ml-get-buckets-execution]] -==== Execution +include::../execution.asciidoc[] -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-buckets-execute] --------------------------------------------------- - - -[[java-rest-high-x-pack-ml-get-buckets-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-buckets-execute-async] --------------------------------------------------- -<1> The `GetBucketsRequest` to execute and the `ActionListener` to use when -the execution completes - -The asynchronous method does not block and returns immediately. Once it is -completed the `ActionListener` is called back with the `onResponse` method -if the execution is successful or the `onFailure` method if the execution -failed. - -A typical listener for `GetBucketsResponse` looks like: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-get-buckets-response]] +[id="{upid}-{api}-response"] ==== Get Buckets Response -The returned `GetBucketsResponse` contains the requested buckets: +The returned +{response}+ contains the requested buckets: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-buckets-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> The count of buckets that were matched <2> The buckets retrieved \ No newline at end of file diff --git a/docs/java-rest/high-level/ml/get-calendars.asciidoc b/docs/java-rest/high-level/ml/get-calendars.asciidoc index d9247758a46..7c78612e064 100644 --- a/docs/java-rest/high-level/ml/get-calendars.asciidoc +++ b/docs/java-rest/high-level/ml/get-calendars.asciidoc @@ -1,83 +1,53 @@ -[[java-rest-high-x-pack-ml-get-calendars]] +-- +:api: get-calendars +:request: GetCalendarsRequest +:response: GetCalendarsResponse +-- +[id="{upid}-{api}"] === Get Calendars API Retrieves one or more calendar objects. -It accepts a `GetCalendarsRequest` and responds -with a `GetCalendarsResponse` object. +It accepts a +{request}+ and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-get-calendars-request]] +[id="{upid}-{api}-request"] ==== Get Calendars Request -By default a `GetCalendarsRequest` with no calendar Id set will return all +By default a +{request}+ with no calendar Id set will return all calendars. Using the literal `_all` also returns all calendars. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-calendars-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request for all calendars - ==== Optional Arguments The following arguments are optional: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-calendars-id] +include-tagged::{doc-tests-file}[{api}-id] -------------------------------------------------- <1> Construct a request for the single calendar `holidays` ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-calendars-page] +include-tagged::{doc-tests-file}[{api}-page] -------------------------------------------------- <1> The page parameters `from` and `size`. `from` specifies the number of calendars to skip. `size` specifies the maximum number of calendars to get. Defaults to `0` and `100` respectively. -[[java-rest-high-x-pack-ml-get-calendars-execution]] -==== Execution -The request can be executed through the `MachineLearningClient` contained -in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method. +include::../execution.asciidoc[] -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-calendars-execution] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-get-calendars-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-calendars-execute-async] --------------------------------------------------- -<1> The `GetCalendarsRequest` to execute and the `ActionListener` to use when -the execution completes - -The asynchronous method does not block and returns immediately. Once it is -completed the `ActionListener` is called back with the `onResponse` method -if the execution is successful or the `onFailure` method if the execution -failed. - -A typical listener for `GetCalendarsResponse` looks like: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-calendars-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-get-calendars-response]] +[id="{upid}-{api}-response"] ==== Get calendars Response -The returned `GetCalendarsResponse` contains the requested calendars: +The returned +{response}+ contains the requested calendars: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-calendars-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> The count of calendars that were matched <2> The calendars retrieved \ No newline at end of file diff --git a/docs/java-rest/high-level/ml/get-categories.asciidoc b/docs/java-rest/high-level/ml/get-categories.asciidoc index 2a5988a5cc6..0aa0c7696cc 100644 --- a/docs/java-rest/high-level/ml/get-categories.asciidoc +++ b/docs/java-rest/high-level/ml/get-categories.asciidoc @@ -1,18 +1,23 @@ -[[java-rest-high-x-pack-ml-get-categories]] +-- +:api: get-categories +:request: GetCategoriesRequest +:response: GetCategoriesResponse +-- +[id="{upid}-{api}"] === Get Categories API The Get Categories API retrieves one or more category results. -It accepts a `GetCategoriesRequest` object and responds -with a `GetCategoriesResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-get-categories-request]] +[id="{upid}-{api}-request"] ==== Get Categories Request -A `GetCategoriesRequest` object gets created with an existing non-null `jobId`. +A +{request}+ object gets created with an existing non-null `jobId`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-categories-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing an existing `jobId` @@ -21,63 +26,27 @@ The following arguments are optional: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-categories-category-id] +include-tagged::{doc-tests-file}[{api}-category-id] -------------------------------------------------- <1> The id of the category to get. Otherwise it will return all categories. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-categories-page] +include-tagged::{doc-tests-file}[{api}-page] -------------------------------------------------- <1> The page parameters `from` and `size`. `from` specifies the number of categories to skip. `size` specifies the maximum number of categories to get. Defaults to `0` and `100` respectively. -[[java-rest-high-x-pack-ml-get-categories-execution]] -==== Execution +include::../execution.asciidoc[] -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-categories-execute] --------------------------------------------------- - - -[[java-rest-high-x-pack-ml-get-categories-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-categories-execute-async] --------------------------------------------------- -<1> The `GetCategoriesRequest` to execute and the `ActionListener` to use when -the execution completes - -The asynchronous method does not block and returns immediately. Once it is -completed the `ActionListener` is called back with the `onResponse` method -if the execution is successful or the `onFailure` method if the execution -failed. - -A typical listener for `GetCategoriesResponse` looks like: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-categories-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-get-categories-response]] +[id="{upid}-{api}-response"] ==== Get Categories Response -The returned `GetCategoriesResponse` contains the requested categories: +The returned +{response}+ contains the requested categories: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-categories-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> The count of categories that were matched <2> The categories retrieved \ No newline at end of file diff --git a/docs/java-rest/high-level/ml/get-datafeed-stats.asciidoc b/docs/java-rest/high-level/ml/get-datafeed-stats.asciidoc index 89002a1cce3..47486669dfc 100644 --- a/docs/java-rest/high-level/ml/get-datafeed-stats.asciidoc +++ b/docs/java-rest/high-level/ml/get-datafeed-stats.asciidoc @@ -1,67 +1,40 @@ -[[java-rest-high-x-pack-ml-get-datafeed-stats]] +-- +:api: get-datafeed-stats +:request: GetDatafeedStatsRequest +:response: GetDatafeedStatsResponse +-- +[id="{upid}-{api}"] === Get Datafeed Stats API The Get Datafeed Stats API provides the ability to get any number of {ml} datafeed's statistics in the cluster. -It accepts a `GetDatafeedStatsRequest` object and responds -with a `GetDatafeedStatsResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-get-datafeed-stats-request]] +[id="{upid}-{api}-request"] ==== Get Datafeed Stats Request -A `GetDatafeedStatsRequest` object can have any number of `datafeedId` +A +{request}+ object can have any number of `datafeedId` entries. However, they all must be non-null. An empty list is the same as requesting statistics for all datafeeds. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-stats-request] +include-tagged::{doc-tests-file}[{api}-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-stats-execution]] -==== Execution +include::../execution.asciidoc[] -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-stats-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-get-datafeed-stats-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-stats-execute-async] --------------------------------------------------- -<1> The `GetDatafeedStatsRequest` 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 `GetDatafeedStatsResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-stats-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-get-datafeed-stats-response]] +[id="{upid}-{api}-response"] ==== Get Datafeed Stats Response -The returned `GetDatafeedStatsResponse` contains the requested datafeed statistics: +The returned +{response}+ contains the requested datafeed statistics: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-stats-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> `count()` indicates the number of datafeeds statistics found <2> `datafeedStats()` is the collection of {ml} `DatafeedStats` objects found \ No newline at end of file diff --git a/docs/java-rest/high-level/ml/get-datafeed.asciidoc b/docs/java-rest/high-level/ml/get-datafeed.asciidoc index 8e5f0664c61..b624a84c86c 100644 --- a/docs/java-rest/high-level/ml/get-datafeed.asciidoc +++ b/docs/java-rest/high-level/ml/get-datafeed.asciidoc @@ -1,56 +1,37 @@ -[[java-rest-high-x-pack-ml-get-datafeed]] +-- +:api: get-datafeed +:request: GetDatafeedRequest +:response: GetDatafeedResponse +-- +[id="{upid}-{api}"] === 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. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-get-datafeed-request]] +[id="{upid}-{api}-request"] ==== Get Datafeed Request -A `GetDatafeedRequest` object gets can have any number of `datafeedId` entries. +A +{request}+ 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] +include-tagged::{doc-tests-file}[{api}-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. +[id="{upid}-{api}-response"] +==== Get Datafeed Response ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-datafeed-execute] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <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 +include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/ml/get-influencers.asciidoc b/docs/java-rest/high-level/ml/get-influencers.asciidoc index 8b1ba061bcb..6167a62e5a3 100644 --- a/docs/java-rest/high-level/ml/get-influencers.asciidoc +++ b/docs/java-rest/high-level/ml/get-influencers.asciidoc @@ -1,18 +1,23 @@ -[[java-rest-high-x-pack-ml-get-influencers]] +-- +:api: get-influencers +:request: GetInfluencersRequest +:response: GetInfluencersResponse +-- +[id="{upid}-{api}"] === Get Influencers API The Get Influencers API retrieves one or more influencer results. -It accepts a `GetInfluencersRequest` object and responds -with a `GetInfluencersResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-get-influencers-request]] +[id="{upid}-{api}-request"] ==== Get Influencers Request -A `GetInfluencersRequest` object gets created with an existing non-null `jobId`. +A +{request}+ object gets created with an existing non-null `jobId`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-influencers-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing an existing `jobId` @@ -21,92 +26,57 @@ The following arguments are optional: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-influencers-desc] +include-tagged::{doc-tests-file}[{api}-desc] -------------------------------------------------- <1> If `true`, the influencers are sorted in descending order. Defaults to `false`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-influencers-end] +include-tagged::{doc-tests-file}[{api}-end] -------------------------------------------------- <1> Influencers with timestamps earlier than this time will be returned. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-influencers-exclude-interim] +include-tagged::{doc-tests-file}[{api}-exclude-interim] -------------------------------------------------- <1> If `true`, interim results will be excluded. Defaults to `false`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-influencers-influencer-score] +include-tagged::{doc-tests-file}[{api}-influencer-score] -------------------------------------------------- <1> Influencers with influencer_score greater or equal than this value will be returned. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-influencers-page] +include-tagged::{doc-tests-file}[{api}-page] -------------------------------------------------- <1> The page parameters `from` and `size`. `from` specifies the number of influencers to skip. `size` specifies the maximum number of influencers to get. Defaults to `0` and `100` respectively. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-influencers-sort] +include-tagged::{doc-tests-file}[{api}-sort] -------------------------------------------------- <1> The field to sort influencers on. Defaults to `influencer_score`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-influencers-start] +include-tagged::{doc-tests-file}[{api}-start] -------------------------------------------------- <1> Influencers with timestamps on or after this time will be returned. -[[java-rest-high-x-pack-ml-get-influencers-execution]] -==== Execution +include::../execution.asciidoc[] -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-influencers-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-get-influencers-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-influencers-execute-async] --------------------------------------------------- -<1> The `GetInfluencersRequest` to execute and the `ActionListener` to use when -the execution completes - -The asynchronous method does not block and returns immediately. Once it is -completed the `ActionListener` is called back with the `onResponse` method -if the execution is successful or the `onFailure` method if the execution -failed. - -A typical listener for `GetInfluencersResponse` looks like: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-influencers-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-get-influencers-response]] +[id="{upid}-{api}-response"] ==== Get Influencers Response -The returned `GetInfluencersResponse` contains the requested influencers: +The returned +{response}+ contains the requested influencers: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-influencers-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> The count of influencers that were matched <2> The influencers retrieved \ No newline at end of file diff --git a/docs/java-rest/high-level/ml/get-job-stats.asciidoc b/docs/java-rest/high-level/ml/get-job-stats.asciidoc index 90f7794ae76..afea6f1a104 100644 --- a/docs/java-rest/high-level/ml/get-job-stats.asciidoc +++ b/docs/java-rest/high-level/ml/get-job-stats.asciidoc @@ -1,12 +1,17 @@ -[[java-rest-high-x-pack-ml-get-job-stats]] +-- +:api: get-job-stats +:request: GetJobStatsRequest +:response: GetJobStatsResponse +-- +[id="{upid}-{api}"] === Get Job Stats API The Get Job Stats API provides the ability to get any number of {ml} job's statistics in the cluster. -It accepts a `GetJobStatsRequest` object and responds -with a `GetJobStatsResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-get-job-stats-request]] +[id="{upid}-{api}-request"] ==== Get Job Stats Request A `GetJobsStatsRequest` object can have any number of `jobId` @@ -15,53 +20,21 @@ requesting statistics for all jobs. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-job-stats-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing existing `jobIds`, can contain wildcards <2> Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) -[[java-rest-high-x-pack-ml-get-job-stats-execution]] -==== Execution +include::../execution.asciidoc[] -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-job-stats-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-get-job-stats-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-job-stats-execute-async] --------------------------------------------------- -<1> The `GetJobsStatsRequest` 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 `GetJobsStatsResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-job-stats-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-get-job-stats-response]] +[id="{upid}-{api}-response"] ==== Get Job Stats Response -The returned `GetJobStatsResponse` contains the requested job statistics: +The returned +{response}+ contains the requested job statistics: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-job-stats-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> `getCount()` indicates the number of jobs statistics found <2> `getJobStats()` is the collection of {ml} `JobStats` objects found \ No newline at end of file diff --git a/docs/java-rest/high-level/ml/get-job.asciidoc b/docs/java-rest/high-level/ml/get-job.asciidoc index 4ecf70e8e65..f2e740897de 100644 --- a/docs/java-rest/high-level/ml/get-job.asciidoc +++ b/docs/java-rest/high-level/ml/get-job.asciidoc @@ -1,57 +1,38 @@ -[[java-rest-high-x-pack-ml-get-job]] +-- +:api: get-job +:request: GetJobRequest +:response: GetJobResponse +-- +[id="{upid}-{api}"] === Get Job API The Get Job API provides the ability to get {ml} jobs in the cluster. -It accepts a `GetJobRequest` object and responds -with a `GetJobResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-get-job-request]] +[id="{upid}-{api}-request"] ==== Get Job Request -A `GetJobRequest` object gets can have any number of `jobId` or `groupName` +A +{request}+ object gets can have any number of `jobId` or `groupName` entries. However, they all must be non-null. An empty list is the same as requesting for all jobs. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-job-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing existing `jobIds`, can contain wildcards <2> Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) -[[java-rest-high-x-pack-ml-get-job-execution]] -==== Execution - -The request can be executed through the `MachineLearningClient` contained -in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method. +[id="{upid}-{api}-response"] +==== Get Job Response ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-job-execute] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- -<1> `getCount()` from the `GetJobResponse` indicates the number of jobs found +<1> `getCount()` from the +{response}+ indicates the number of jobs found <2> `getJobs()` is the collection of {ml} `Job` objects found -[[java-rest-high-x-pack-ml-get-job-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-job-execute-async] --------------------------------------------------- -<1> The `GetJobRequest` 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 `GetJobResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-job-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs +include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/ml/get-overall-buckets.asciidoc b/docs/java-rest/high-level/ml/get-overall-buckets.asciidoc index 1e299dc2721..c3a2f4f250e 100644 --- a/docs/java-rest/high-level/ml/get-overall-buckets.asciidoc +++ b/docs/java-rest/high-level/ml/get-overall-buckets.asciidoc @@ -1,19 +1,24 @@ -[[java-rest-high-x-pack-ml-get-overall-buckets]] +-- +:api: get-overall-buckets +:request: GetOverallBucketsRequest +:response: GetOverallBucketsResponse +-- +[id="{upid}-{api}"] === Get Overall Buckets API The Get Overall Buckets API retrieves overall bucket results that summarize the bucket results of multiple jobs. -It accepts a `GetOverallBucketsRequest` object and responds -with a `GetOverallBucketsResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-get-overall-buckets-request]] +[id="{upid}-{api}-request"] ==== Get Overall Buckets Request -A `GetOverallBucketsRequest` object gets created with one or more `jobId`. +A +{request}+ object gets created with one or more `jobId`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-overall-buckets-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing job IDs `jobId1` and `jobId2`. @@ -22,86 +27,51 @@ The following arguments are optional: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-overall-buckets-bucket-span] +include-tagged::{doc-tests-file}[{api}-bucket-span] -------------------------------------------------- <1> The span of the overall buckets. Must be greater or equal to the jobs' largest `bucket_span`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-overall-buckets-end] +include-tagged::{doc-tests-file}[{api}-end] -------------------------------------------------- <1> Overall buckets with timestamps earlier than this time will be returned. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-overall-buckets-exclude-interim] +include-tagged::{doc-tests-file}[{api}-exclude-interim] -------------------------------------------------- <1> If `true`, interim results will be excluded. Overall buckets are interim if any of the job buckets within the overall bucket interval are interim. Defaults to `false`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-overall-buckets-overall-score] +include-tagged::{doc-tests-file}[{api}-overall-score] -------------------------------------------------- <1> Overall buckets with overall scores greater or equal than this value will be returned. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-overall-buckets-start] +include-tagged::{doc-tests-file}[{api}-start] -------------------------------------------------- <1> Overall buckets with timestamps on or after this time will be returned. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-overall-buckets-top-n] +include-tagged::{doc-tests-file}[{api}-top-n] -------------------------------------------------- <1> The number of top job bucket scores to be used in the `overall_score` calculation. Defaults to `1`. -[[java-rest-high-x-pack-ml-get-overall-buckets-execution]] -==== Execution +include::../execution.asciidoc[] -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-overall-buckets-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-get-overall-buckets-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-overall-buckets-execute-async] --------------------------------------------------- -<1> The `GetOverallBucketsRequest` to execute and the `ActionListener` to use when -the execution completes - -The asynchronous method does not block and returns immediately. Once it is -completed the `ActionListener` is called back with the `onResponse` method -if the execution is successful or the `onFailure` method if the execution -failed. - -A typical listener for `GetBucketsResponse` looks like: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-overall-buckets-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-get-overall-buckets-response]] +[id="{upid}-{api}-response"] ==== Get Overall Buckets Response -The returned `GetOverallBucketsResponse` contains the requested buckets: +The returned +{response}+ contains the requested buckets: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-overall-buckets-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> The count of overall buckets that were matched <2> The overall buckets retrieved \ No newline at end of file diff --git a/docs/java-rest/high-level/ml/get-records.asciidoc b/docs/java-rest/high-level/ml/get-records.asciidoc index 7b8e6b13131..7543463c30b 100644 --- a/docs/java-rest/high-level/ml/get-records.asciidoc +++ b/docs/java-rest/high-level/ml/get-records.asciidoc @@ -1,18 +1,23 @@ -[[java-rest-high-x-pack-ml-get-records]] +-- +:api: get-records +:request: GetRecordsRequest +:response: GetRecordsResponse +-- +[id="{upid}-{api}"] === Get Records API The Get Records API retrieves one or more record results. -It accepts a `GetRecordsRequest` object and responds -with a `GetRecordsResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-get-records-request]] +[id="{upid}-{api}-request"] ==== Get Records Request -A `GetRecordsRequest` object gets created with an existing non-null `jobId`. +A +{request}+ object gets created with an existing non-null `jobId`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-records-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing an existing `jobId` @@ -21,93 +26,57 @@ The following arguments are optional: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-records-desc] +include-tagged::{doc-tests-file}[{api}-desc] -------------------------------------------------- <1> If `true`, the records are sorted in descending order. Defaults to `false`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-records-end] +include-tagged::{doc-tests-file}[{api}-end] -------------------------------------------------- <1> Records with timestamps earlier than this time will be returned. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-records-exclude-interim] +include-tagged::{doc-tests-file}[{api}-exclude-interim] -------------------------------------------------- <1> If `true`, interim results will be excluded. Defaults to `false`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-records-page] +include-tagged::{doc-tests-file}[{api}-page] -------------------------------------------------- <1> The page parameters `from` and `size`. `from` specifies the number of records to skip. `size` specifies the maximum number of records to get. Defaults to `0` and `100` respectively. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-records-record-score] +include-tagged::{doc-tests-file}[{api}-record-score] -------------------------------------------------- <1> Records with record_score greater or equal than this value will be returned. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-records-sort] +include-tagged::{doc-tests-file}[{api}-sort] -------------------------------------------------- <1> The field to sort records on. Defaults to `record_score`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-records-start] +include-tagged::{doc-tests-file}[{api}-start] -------------------------------------------------- <1> Records with timestamps on or after this time will be returned. -[[java-rest-high-x-pack-ml-get-records-execution]] -==== Execution +include::../execution.asciidoc[] -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-records-execute] --------------------------------------------------- - - -[[java-rest-high-x-pack-ml-get-records-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-records-execute-async] --------------------------------------------------- -<1> The `GetRecordsRequest` to execute and the `ActionListener` to use when -the execution completes - -The asynchronous method does not block and returns immediately. Once it is -completed the `ActionListener` is called back with the `onResponse` method -if the execution is successful or the `onFailure` method if the execution -failed. - -A typical listener for `GetRecordsResponse` looks like: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-records-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-get-records-response]] +[id="{upid}-{api}-response"] ==== Get Records Response -The returned `GetRecordsResponse` contains the requested records: +The returned +{response}+ contains the requested records: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-get-records-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> The count of records that were matched <2> The records retrieved \ No newline at end of file diff --git a/docs/java-rest/high-level/ml/open-job.asciidoc b/docs/java-rest/high-level/ml/open-job.asciidoc index be6a518df19..9b3ec11a7cc 100644 --- a/docs/java-rest/high-level/ml/open-job.asciidoc +++ b/docs/java-rest/high-level/ml/open-job.asciidoc @@ -1,55 +1,36 @@ -[[java-rest-high-x-pack-ml-open-job]] +-- +:api: open-job +:request: OpenJobRequest +:response: OpenJobResponse +-- +[id="{upid}-{api}"] === Open Job API The Open Job API provides the ability to open {ml} jobs in the cluster. -It accepts a `OpenJobRequest` object and responds -with a `OpenJobResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-open-job-request]] +[id="{upid}-{api}-request"] ==== Open Job Request -An `OpenJobRequest` object gets created with an existing non-null `jobId`. +An +{request}+ object gets created with an existing non-null `jobId`. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-open-job-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing an existing `jobId` <2> Optionally setting the `timeout` value for how long the execution should wait for the job to be opened. -[[java-rest-high-x-pack-ml-open-job-execution]] -==== Execution - -The request can be executed through the `MachineLearningClient` contained -in the `RestHighLevelClient` object, accessed via the `machineLearningClient()` method. +[id="{upid}-{api}-response"] +==== Open Job Response ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-open-job-execute] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- -<1> `isOpened()` from the `OpenJobResponse` indicates if the job was successfully +<1> `isOpened()` from the +{response}+ indicates if the job was successfully opened or not. -[[java-rest-high-x-pack-ml-open-job-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-open-job-execute-async] --------------------------------------------------- -<1> The `OpenJobRequest` 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 `OpenJobResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-open-job-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs +include::../execution.asciidoc[] \ No newline at end of file diff --git a/docs/java-rest/high-level/ml/post-data.asciidoc b/docs/java-rest/high-level/ml/post-data.asciidoc index 2c8ca8f18a3..fd51dc80696 100644 --- a/docs/java-rest/high-level/ml/post-data.asciidoc +++ b/docs/java-rest/high-level/ml/post-data.asciidoc @@ -1,27 +1,32 @@ -[[java-rest-high-x-pack-ml-post-data]] +-- +:api: post-data +:request: PostDataRequest +:response: PostDataResponse +-- +[id="{upid}-{api}"] === Post Data API The Post Data API provides the ability to post data to an open {ml} job in the cluster. -It accepts a `PostDataRequest` object and responds -with a `PostDataResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-post-data-request]] +[id="{upid}-{api}-request"] ==== Post Data Request -A `PostDataRequest` object gets created with an existing non-null `jobId` +A +{request}+ object gets created with an existing non-null `jobId` and the `XContentType` being sent. Individual docs can be added incrementally via the `PostDataRequest.JsonBuilder#addDoc` method. -These are then serialized and sent in bulk when passed to the `PostDataRequest`. +These are then serialized and sent in bulk when passed to the +{request}+. Alternatively, the serialized bulk content can be set manually, along with its `XContentType` -through one of the other `PostDataRequest` constructors. +through one of the other +{request}+ constructors. Only `XContentType.JSON` and `XContentType.SMILE` are supported. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-post-data-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Create a new `PostDataRequest.JsonBuilder` object for incrementally adding documents <2> Add a new document as a `Map` object @@ -34,53 +39,21 @@ The following arguments are optional. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-post-data-request-options] +include-tagged::{doc-tests-file}[{api}-request-options] -------------------------------------------------- <1> Set the start of the bucket resetting time <2> Set the end of the bucket resetting time -[[java-rest-high-x-pack-ml-post-data-execution]] -==== Execution +include::../execution.asciidoc[] -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-post-data-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-post-data-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-post-data-execute-async] --------------------------------------------------- -<1> The `PostDataRequest` 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 `PostDataResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-post-data-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-post-data-response]] +[id="{upid}-{api}-response"] ==== Post Data Response -A `PostDataResponse` contains current data processing statistics. +A +{response}+ contains current data processing statistics. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-post-data-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> `getDataCounts()` a `DataCounts` object containing the current data processing counts. diff --git a/docs/java-rest/high-level/ml/put-calendar.asciidoc b/docs/java-rest/high-level/ml/put-calendar.asciidoc index 5d163f37eb4..defd72e35a0 100644 --- a/docs/java-rest/high-level/ml/put-calendar.asciidoc +++ b/docs/java-rest/high-level/ml/put-calendar.asciidoc @@ -1,65 +1,35 @@ -[[java-rest-high-x-pack-ml-put-calendar]] +-- +:api: put-calendar +:request: PutCalendarRequest +:response: PutCalendarResponse +-- +[id="{upid}-{api}"] === Put Calendar API Creates a new {ml} calendar. -The API accepts a `PutCalendarRequest` and responds -with a `PutCalendarResponse` object. +The API accepts a +{request}+ and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-put-calendar-request]] +[id="{upid}-{api}-request"] ==== Put Calendar Request -A `PutCalendarRequest` is constructed with a Calendar object +A +{request}+ is constructed with a Calendar object ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-calendar-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Create a request with the given Calendar -[[java-rest-high-x-pack-ml-put-calendar-response]] +[id="{upid}-{api}-response"] ==== Put Calendar Response -The returned `PutCalendarResponse` contains the created Calendar: +The returned +{response}+ contains the created Calendar: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-calendar-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> The created Calendar -[[java-rest-high-x-pack-ml-put-calendar-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-put-calendar-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-put-calendar-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-put-calendar-execute-async] --------------------------------------------------- -<1> The `PutCalendarResquest` to execute and the `ActionListener` to use when -the execution completes - -The asynchronous method does not block and returns immediately. Once it is -completed the `ActionListener` is called back with the `onResponse` method -if the execution is successful or the `onFailure` method if the execution -failed. - -A typical listener for `PutCalendarResponse` looks like: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-calendar-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - +include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/ml/put-datafeed.asciidoc b/docs/java-rest/high-level/ml/put-datafeed.asciidoc index 86c9d631726..e9f66f0b61d 100644 --- a/docs/java-rest/high-level/ml/put-datafeed.asciidoc +++ b/docs/java-rest/high-level/ml/put-datafeed.asciidoc @@ -1,22 +1,27 @@ -[[java-rest-high-x-pack-ml-put-datafeed]] +-- +:api: put-datafeed +:request: PutDatafeedRequest +:response: PutDatafeedResponse +-- +[id="{upid}-{api}"] === Put Datafeed API The Put Datafeed API can be used to create a new {ml} datafeed -in the cluster. The API accepts a `PutDatafeedRequest` object -as a request and returns a `PutDatafeedResponse`. +in the cluster. The API accepts a +{request}+ object +as a request and returns a +{response}+. -[[java-rest-high-x-pack-ml-put-datafeed-request]] +[id="{upid}-{api}-request"] ==== Put Datafeed Request -A `PutDatafeedRequest` requires the following argument: +A +{request}+ requires the following argument: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-datafeed-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> The configuration of the {ml} datafeed to create -[[java-rest-high-x-pack-ml-put-datafeed-config]] +[id="{upid}-{api}-config"] ==== Datafeed Configuration The `DatafeedConfig` object contains all the details about the {ml} datafeed @@ -26,7 +31,7 @@ A `DatafeedConfig` requires the following arguments: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-create-datafeed-config] +include-tagged::{doc-tests-file}[{api}-config] -------------------------------------------------- <1> The datafeed ID and the job ID <2> The indices that contain the data to retrieve and feed into the job @@ -36,89 +41,52 @@ The following arguments are optional: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-create-datafeed-config-set-chunking-config] +include-tagged::{doc-tests-file}[{api}-config-set-chunking-config] -------------------------------------------------- <1> Specifies how data searches are split into time chunks. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-create-datafeed-config-set-frequency] +include-tagged::{doc-tests-file}[{api}-config-set-frequency] -------------------------------------------------- <1> The interval at which scheduled queries are made while the datafeed runs in real time. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-create-datafeed-config-set-query] +include-tagged::{doc-tests-file}[{api}-config-set-query] -------------------------------------------------- <1> A query to filter the search results by. Defaults to the `match_all` query. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-create-datafeed-config-set-query-delay] +include-tagged::{doc-tests-file}[{api}-config-set-query-delay] -------------------------------------------------- <1> The time interval behind real time that data is queried. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-create-datafeed-config-set-script-fields] +include-tagged::{doc-tests-file}[{api}-config-set-script-fields] -------------------------------------------------- <1> Allows the use of script fields. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-create-datafeed-config-set-scroll-size] +include-tagged::{doc-tests-file}[{api}-config-set-scroll-size] -------------------------------------------------- <1> The `size` parameter used in the searches. -[[java-rest-high-x-pack-ml-put-datafeed-execution]] -==== Execution +include::../execution.asciidoc[] -The Put Datafeed API can be executed through a `MachineLearningClient` -instance. Such an instance can be retrieved from a `RestHighLevelClient` -using the `machineLearning()` method: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-datafeed-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-put-datafeed-response]] +[id="{upid}-{api}-response"] ==== Response -The returned `PutDatafeedResponse` returns the full representation of +The returned +{response}+ returns the full representation of the new {ml} datafeed if it has been successfully created. This will contain the creation time and other fields initialized using default values: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-datafeed-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> The created datafeed - -[[java-rest-high-x-pack-ml-put-datafeed-async]] -==== Asynchronous Execution - -This request can be executed asynchronously: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-datafeed-execute-async] --------------------------------------------------- -<1> The `PutDatafeedRequest` to execute and the `ActionListener` to use when -the execution completes - -The asynchronous method does not block and returns immediately. Once it is -completed the `ActionListener` is called back using the `onResponse` method -if the execution successfully completed or using the `onFailure` method if -it failed. - -A typical listener for `PutDatafeedResponse` looks like: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-datafeed-execute-listener] --------------------------------------------------- -<1> Called when the execution is successfully completed. The response is -provided as an argument -<2> Called in case of failure. The raised exception is provided as an argument diff --git a/docs/java-rest/high-level/ml/put-job.asciidoc b/docs/java-rest/high-level/ml/put-job.asciidoc index 8c726d63b16..9934fc6b94a 100644 --- a/docs/java-rest/high-level/ml/put-job.asciidoc +++ b/docs/java-rest/high-level/ml/put-job.asciidoc @@ -1,22 +1,27 @@ -[[java-rest-high-x-pack-ml-put-job]] +-- +:api: put-job +:request: PutJobRequest +:response: PutJobResponse +-- +[id="{upid}-{api}"] === Put Job API The Put Job API can be used to create a new {ml} job -in the cluster. The API accepts a `PutJobRequest` object -as a request and returns a `PutJobResponse`. +in the cluster. The API accepts a +{request}+ object +as a request and returns a +{response}+. -[[java-rest-high-x-pack-ml-put-job-request]] +[id="{upid}-{api}-request"] ==== Put Job Request -A `PutJobRequest` requires the following argument: +A +{request}+ requires the following argument: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-job-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> The configuration of the {ml} job to create as a `Job` -[[java-rest-high-x-pack-ml-put-job-config]] +[id="{upid}-{api}-config"] ==== Job Configuration The `Job` object contains all the details about the {ml} job @@ -26,14 +31,14 @@ A `Job` requires the following arguments: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-job-config] +include-tagged::{doc-tests-file}[{api}-config] -------------------------------------------------- <1> The job ID <2> An analysis configuration <3> A data description <4> Optionally, a human-readable description -[[java-rest-high-x-pack-ml-put-job-analysis-config]] +[id="{upid}-{api}-analysis-config"] ==== Analysis Configuration The analysis configuration of the {ml} job is defined in the `AnalysisConfig`. @@ -64,7 +69,7 @@ An example of building a `Detector` instance is as follows: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-job-detector] +include-tagged::{doc-tests-file}[{api}-detector] -------------------------------------------------- <1> The function to use <2> The field to apply the function to @@ -74,13 +79,13 @@ Then the same configuration would be: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-job-analysis-config] +include-tagged::{doc-tests-file}[{api}-analysis-config] -------------------------------------------------- <1> Create a list of detectors <2> Pass the list of detectors to the analysis config builder constructor <3> The bucket span -[[java-rest-high-x-pack-ml-put-job-data-description]] +[id="{upid}-{api}-data-description"] ==== Data Description After defining the analysis config, the next thing to define is the @@ -103,59 +108,22 @@ configuration would be: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-job-data-description] +include-tagged::{doc-tests-file}[{api}-data-description] -------------------------------------------------- <1> The time field -[[java-rest-high-x-pack-ml-put-job-execution]] -==== Execution +include::../execution.asciidoc[] -The Put Job API can be executed through a `MachineLearningClient` -instance. Such an instance can be retrieved from a `RestHighLevelClient` -using the `machineLearning()` method: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-job-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-put-job-response]] +[id="{upid}-{api}-response"] ==== Response -The returned `PutJobResponse` returns the full representation of +The returned +{response}+ returns the full representation of the new {ml} job if it has been successfully created. This will contain the creation time and other fields initialized using default values: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-job-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> The creation time is a field that was not passed in the `Job` object in the request - -[[java-rest-high-x-pack-ml-put-job-async]] -==== Asynchronous Execution - -This request can be executed asynchronously: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-job-execute-async] --------------------------------------------------- -<1> The `PutJobRequest` to execute and the `ActionListener` to use when -the execution completes - -The asynchronous method does not block and returns immediately. Once it is -completed the `ActionListener` is called back using the `onResponse` method -if the execution successfully completed or using the `onFailure` method if -it failed. - -A typical listener for `PutJobResponse` looks like: - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-put-job-execute-listener] --------------------------------------------------- -<1> Called when the execution is successfully completed. The response is -provided as an argument -<2> Called in case of failure. The raised exception is provided as an argument diff --git a/docs/java-rest/high-level/ml/start-datafeed.asciidoc b/docs/java-rest/high-level/ml/start-datafeed.asciidoc index 6bef621562e..9c3b096634d 100644 --- a/docs/java-rest/high-level/ml/start-datafeed.asciidoc +++ b/docs/java-rest/high-level/ml/start-datafeed.asciidoc @@ -1,19 +1,24 @@ -[[java-rest-high-x-pack-ml-start-datafeed]] +-- +:api: start-datafeed +:request: StartDatafeedRequest +:response: StartDatafeedResponse +-- +[id="{upid}-{api}"] === Start Datafeed API The Start Datafeed API provides the ability to start a {ml} datafeed in the cluster. -It accepts a `StartDatafeedRequest` object and responds -with a `StartDatafeedResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-start-datafeed-request]] +[id="{upid}-{api}-request"] ==== Start Datafeed Request -A `StartDatafeedRequest` object is created referencing a non-null `datafeedId`. +A +{request}+ object is created referencing a non-null `datafeedId`. All other fields are optional for the request. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-start-datafeed-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing an existing `datafeedId` @@ -23,7 +28,7 @@ The following arguments are optional. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-start-datafeed-request-options] +include-tagged::{doc-tests-file}[{api}-request-options] -------------------------------------------------- <1> Set when the datafeed should end, the value is exclusive. May be an epoch seconds, epoch millis or an ISO 8601 string. @@ -35,37 +40,4 @@ If you do not specify a start time and the datafeed is associated with a new job the analysis starts from the earliest time for which data is available. <3> Set the timeout for the request -[[java-rest-high-x-pack-ml-start-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-start-datafeed-execute] --------------------------------------------------- -<1> Did the datafeed successfully start? - -[[java-rest-high-x-pack-ml-start-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-start-datafeed-execute-async] --------------------------------------------------- -<1> The `StartDatafeedRequest` 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 `StartDatafeedResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-start-datafeed-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs +include::../execution.asciidoc[] diff --git a/docs/java-rest/high-level/ml/stop-datafeed.asciidoc b/docs/java-rest/high-level/ml/stop-datafeed.asciidoc index 4e07d9a2e19..211d1c5ad7a 100644 --- a/docs/java-rest/high-level/ml/stop-datafeed.asciidoc +++ b/docs/java-rest/high-level/ml/stop-datafeed.asciidoc @@ -1,20 +1,25 @@ -[[java-rest-high-x-pack-ml-stop-datafeed]] +-- +:api: stop-datafeed +:request: StopDatafeedRequest +:response: StopDatafeedResponse +-- +[id="{upid}-{api}"] === Stop Datafeed API The Stop Datafeed API provides the ability to stop a {ml} datafeed in the cluster. -It accepts a `StopDatafeedRequest` object and responds -with a `StopDatafeedResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-stop-datafeed-request]] +[id="{upid}-{api}-request"] ==== Stop Datafeed Request -A `StopDatafeedRequest` object is created referencing any number of non-null `datafeedId` entries. +A +{request}+ object is created referencing any number of non-null `datafeedId` entries. Wildcards and `_all` are also accepted. All other fields are optional for the request. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-stop-datafeed-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing existing `datafeedId` entries. @@ -24,43 +29,10 @@ The following arguments are optional. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-stop-datafeed-request-options] +include-tagged::{doc-tests-file}[{api}-request-options] -------------------------------------------------- <1> Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string) <2> If true, the datafeed is stopped forcefully. <3> Controls the amount of time to wait until a datafeed stops. The default value is 20 seconds. -[[java-rest-high-x-pack-ml-stop-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-stop-datafeed-execute] --------------------------------------------------- -<1> Did the datafeed successfully stop? - -[[java-rest-high-x-pack-ml-stop-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-stop-datafeed-execute-async] --------------------------------------------------- -<1> The `StopDatafeedRequest` 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 `StopDatafeedResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-stop-datafeed-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs +include::../execution.asciidoc[] \ No newline at end of file diff --git a/docs/java-rest/high-level/ml/update-job.asciidoc b/docs/java-rest/high-level/ml/update-job.asciidoc index 3e1d1e2313b..90f9cf85c48 100644 --- a/docs/java-rest/high-level/ml/update-job.asciidoc +++ b/docs/java-rest/high-level/ml/update-job.asciidoc @@ -1,18 +1,23 @@ -[[java-rest-high-x-pack-ml-update-job]] +-- +:api: update-job +:request: UpdateJobRequest +:response: PutJobResponse +-- +[id="{upid}-{api}"] === Update Job API The Update Job API provides the ability to update a {ml} job. -It accepts a `UpdateJobRequest` object and responds -with a `PutJobResponse` object. +It accepts a +{request}+ object and responds +with a +{response}+ object. -[[java-rest-high-x-pack-ml-update-job-request]] +[id="{upid}-{api}-request"] ==== Update Job Request -An `UpdateJobRequest` object gets created with a `JobUpdate` object. +An +{request}+ object gets created with a `JobUpdate` object. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-request] +include-tagged::{doc-tests-file}[{api}-request] -------------------------------------------------- <1> Constructing a new request referencing a `JobUpdate` object @@ -23,7 +28,7 @@ job. An existing, non-null `jobId` must be referenced in its creation. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-options] +include-tagged::{doc-tests-file}[{api}-options] -------------------------------------------------- <1> Mandatory, non-null `jobId` referencing an existing {ml} job <2> Updated description @@ -41,53 +46,21 @@ include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-op Included with these options are specific optional `JobUpdate.DetectorUpdate` updates. ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-detector-options] +include-tagged::{doc-tests-file}[{api}-detector-options] -------------------------------------------------- <1> The index of the detector. `O` means unknown <2> The optional description of the detector <3> The `DetectionRule` rules that apply to this detector -[[java-rest-high-x-pack-ml-update-job-execution]] -==== Execution +include::../execution.asciidoc[] -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-update-job-execute] --------------------------------------------------- - -[[java-rest-high-x-pack-ml-update-job-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-update-job-execute-async] --------------------------------------------------- -<1> The `UpdateJobRequest` 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 `PutJobResponse` may -look like - -["source","java",subs="attributes,callouts,macros"] --------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-listener] --------------------------------------------------- -<1> `onResponse` is called back when the action is completed successfully -<2> `onFailure` is called back when some unexpected error occurs - -[[java-rest-high-x-pack-ml-update-job-response]] +[id="{upid}-{api}-response"] ==== Update Job Response -A `PutJobResponse` contains the updated `Job` object +A +{response}+ contains the updated `Job` object ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- -include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-ml-update-job-response] +include-tagged::{doc-tests-file}[{api}-response] -------------------------------------------------- <1> `getResponse()` returns the updated `Job` object