-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HLRC: adding machine learning delete job (#32820)
* HLRC: adding machine learning delete job * Fixing whitespace * Moving docs and tests around * Unifying ml asciidoc file naming convention
- Loading branch information
Showing
11 changed files
with
412 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
[[java-rest-high-x-pack-ml-delete-job]] | ||
=== Delete Job API | ||
|
||
[[java-rest-high-x-pack-machine-learning-delete-job-request]] | ||
==== Delete Job Request | ||
|
||
A `DeleteJobRequest` object requires a non-null `jobId` and can optionally set `force`. | ||
Can be executed as follows: | ||
|
||
["source","java",subs="attributes,callouts,macros"] | ||
--------------------------------------------------- | ||
include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request] | ||
--------------------------------------------------- | ||
<1> Use to forcefully delete an opened job; | ||
this method is quicker than closing and deleting the job. | ||
Defaults to `false` | ||
|
||
[[java-rest-high-x-pack-machine-learning-delete-job-response]] | ||
==== Delete Job Response | ||
|
||
The returned `DeleteJobResponse` object indicates the acknowledgement of the request: | ||
["source","java",subs="attributes,callouts,macros"] | ||
--------------------------------------------------- | ||
include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-response] | ||
--------------------------------------------------- | ||
<1> `isAcknowledged` was the deletion request acknowledged or not | ||
|
||
[[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/ml/DeleteJobRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.elasticsearch.protocol.xpack.ml; | ||
|
||
import org.elasticsearch.action.ActionRequest; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
|
||
import java.util.Objects; | ||
|
||
public class DeleteJobRequest extends ActionRequest { | ||
|
||
private String jobId; | ||
private boolean force; | ||
|
||
public DeleteJobRequest(String jobId) { | ||
this.jobId = Objects.requireNonNull(jobId, "[job_id] must not be null"); | ||
} | ||
|
||
public String getJobId() { | ||
return jobId; | ||
} | ||
|
||
public void setJobId(String jobId) { | ||
this.jobId = Objects.requireNonNull(jobId, "[job_id] must not be null"); | ||
} | ||
|
||
public boolean isForce() { | ||
return force; | ||
} | ||
|
||
public void setForce(boolean force) { | ||
this.force = force; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(jobId, force); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
|
||
if (obj == null || obj.getClass() != getClass()) { | ||
return false; | ||
} | ||
|
||
DeleteJobRequest other = (DeleteJobRequest) obj; | ||
return Objects.equals(jobId, other.jobId) && Objects.equals(force, other.force); | ||
} | ||
|
||
} |
Oops, something went wrong.