-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[HLRC][ML] Add ML delete model snapshot API #35537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
edsavage
merged 4 commits into
elastic:master
from
edsavage:feature/add-ml-delete-model-snapshot-to-hlrc
Nov 15, 2018
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
47de8e9
[HLRC][ML] Add ML delete model snapshot API
edsavage c9fca4a
Merge branch 'master' of github.com:elastic/elasticsearch into featur…
edsavage 776c670
Attending to review comments
edsavage 4617deb
Merge branch 'master' of github.com:elastic/elasticsearch into featur…
edsavage File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
87 changes: 87 additions & 0 deletions
87
...rest-high-level/src/main/java/org/elasticsearch/client/ml/DeleteModelSnapshotRequest.java
This file contains hidden or 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,87 @@ | ||
/* | ||
* 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.client.ml; | ||
|
||
import org.elasticsearch.action.ActionRequest; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Request to delete a Machine Learning Model Snapshot Job via its Job and Snapshot IDs | ||
*/ | ||
public class DeleteModelSnapshotRequest extends ActionRequest { | ||
|
||
private String jobId; | ||
private String snapshotId; | ||
|
||
public DeleteModelSnapshotRequest(String jobId, String snapshotId) { | ||
this.jobId = Objects.requireNonNull(jobId, "[job_id] must not be null"); | ||
this.snapshotId = Objects.requireNonNull(snapshotId, "[snapshot_id] must not be null"); | ||
} | ||
|
||
public String getJobId() { | ||
return jobId; | ||
} | ||
|
||
public String getSnapshotId() { | ||
return snapshotId; | ||
} | ||
|
||
/** | ||
* The jobId for which to delete a given snapshot | ||
* @param jobId unique jobId to delete snapshots from, must not be null | ||
*/ | ||
public void setJobId(String jobId) { | ||
this.jobId = Objects.requireNonNull(jobId, "[job_id] must not be null"); | ||
} | ||
|
||
/** | ||
* The snapshotId for which to delete a given snapshot | ||
* @param snapshotId unique snapshotId for a give job from which to delete snapshots, must not be null | ||
*/ | ||
public void setSnapshotId(String snapshotId) { | ||
this.snapshotId = Objects.requireNonNull(snapshotId, "[snapshot_id] must not be null"); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure these setters are necessary, there is only one constructor and it requires both parameters to be set anyways. |
||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(jobId, snapshotId); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
|
||
if (obj == null || obj.getClass() != getClass()) { | ||
return false; | ||
} | ||
|
||
DeleteModelSnapshotRequest other = (DeleteModelSnapshotRequest) obj; | ||
return Objects.equals(jobId, other.jobId) && Objects.equals(snapshotId, other.snapshotId); | ||
} | ||
|
||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
46 changes: 46 additions & 0 deletions
46
...high-level/src/test/java/org/elasticsearch/client/ml/DeleteModelSnapshotRequestTests.java
This file contains hidden or 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,46 @@ | ||
/* | ||
* 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.client.ml; | ||
|
||
import org.elasticsearch.test.ESTestCase; | ||
|
||
public class DeleteModelSnapshotRequestTests extends ESTestCase { | ||
|
||
public void test_WithNullJobId() { | ||
NullPointerException ex = expectThrows(NullPointerException.class, () -> | ||
new DeleteModelSnapshotRequest(null, randomAlphaOfLength(10))); | ||
assertEquals("[job_id] must not be null", ex.getMessage()); | ||
|
||
ex = expectThrows(NullPointerException.class, () -> createTestInstance().setJobId(null)); | ||
assertEquals("[job_id] must not be null", ex.getMessage()); | ||
} | ||
|
||
public void test_WithNullSnapshotId() { | ||
NullPointerException ex = expectThrows(NullPointerException.class, () | ||
-> new DeleteModelSnapshotRequest(randomAlphaOfLength(10), null)); | ||
assertEquals("[snapshot_id] must not be null", ex.getMessage()); | ||
|
||
ex = expectThrows(NullPointerException.class, () -> createTestInstance().setSnapshotId(null)); | ||
assertEquals("[snapshot_id] must not be null", ex.getMessage()); | ||
} | ||
|
||
private DeleteModelSnapshotRequest createTestInstance() { | ||
return new DeleteModelSnapshotRequest(randomAlphaOfLength(10), randomAlphaOfLength(10)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these should be
final