forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML][Data Frame] Add update transform api endpoint (elastic#45154)
This adds the ability to `_update` stored data frame transforms. All mutable fields are applied when the next checkpoint starts. The exception being `description`. This PR contains all that is necessary for this addition: * HLRC * Docs * Server side
- Loading branch information
Showing
36 changed files
with
2,903 additions
and
88 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
103 changes: 103 additions & 0 deletions
103
...vel/src/main/java/org/elasticsearch/client/dataframe/UpdateDataFrameTransformRequest.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,103 @@ | ||
/* | ||
* 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.dataframe; | ||
|
||
import org.elasticsearch.client.Validatable; | ||
import org.elasticsearch.client.ValidationException; | ||
import org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfigUpdate; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
public class UpdateDataFrameTransformRequest implements ToXContentObject, Validatable { | ||
|
||
private final DataFrameTransformConfigUpdate update; | ||
private final String id; | ||
private Boolean deferValidation; | ||
|
||
public UpdateDataFrameTransformRequest(DataFrameTransformConfigUpdate update, String id) { | ||
this.update = update; | ||
this.id = id; | ||
} | ||
|
||
public DataFrameTransformConfigUpdate getUpdate() { | ||
return update; | ||
} | ||
|
||
public Boolean getDeferValidation() { | ||
return deferValidation; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* Indicates if deferrable validations should be skipped until the transform starts | ||
* | ||
* @param deferValidation {@code true} will cause validations to be deferred | ||
*/ | ||
public void setDeferValidation(boolean deferValidation) { | ||
this.deferValidation = deferValidation; | ||
} | ||
|
||
@Override | ||
public Optional<ValidationException> validate() { | ||
ValidationException validationException = new ValidationException(); | ||
if (update == null) { | ||
validationException.addValidationError("put requires a non-null data frame config update object"); | ||
} | ||
if (id == null) { | ||
validationException.addValidationError("data frame transform id cannot be null"); | ||
} | ||
if (validationException.validationErrors().isEmpty()) { | ||
return Optional.empty(); | ||
} else { | ||
return Optional.of(validationException); | ||
} | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
return update.toXContent(builder, params); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(update, deferValidation, id); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
UpdateDataFrameTransformRequest other = (UpdateDataFrameTransformRequest) obj; | ||
return Objects.equals(update, other.update) | ||
&& Objects.equals(id, other.id) | ||
&& Objects.equals(deferValidation, other.deferValidation); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...el/src/main/java/org/elasticsearch/client/dataframe/UpdateDataFrameTransformResponse.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,61 @@ | ||
/* | ||
* 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.dataframe; | ||
|
||
import org.elasticsearch.client.dataframe.transforms.DataFrameTransformConfig; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.util.Objects; | ||
|
||
public class UpdateDataFrameTransformResponse { | ||
|
||
public static UpdateDataFrameTransformResponse fromXContent(final XContentParser parser) { | ||
return new UpdateDataFrameTransformResponse(DataFrameTransformConfig.PARSER.apply(parser, null)); | ||
} | ||
|
||
private DataFrameTransformConfig transformConfiguration; | ||
|
||
public UpdateDataFrameTransformResponse(DataFrameTransformConfig transformConfiguration) { | ||
this.transformConfiguration = transformConfiguration; | ||
} | ||
|
||
public DataFrameTransformConfig getTransformConfiguration() { | ||
return transformConfiguration; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(transformConfiguration); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (this == other) { | ||
return true; | ||
} | ||
|
||
if (other == null || getClass() != other.getClass()) { | ||
return false; | ||
} | ||
|
||
final UpdateDataFrameTransformResponse that = (UpdateDataFrameTransformResponse) other; | ||
return Objects.equals(this.transformConfiguration, that.transformConfiguration); | ||
} | ||
} |
Oops, something went wrong.