Skip to content

Commit

Permalink
output only old fields in get config API (opensearch-project#2892) (o…
Browse files Browse the repository at this point in the history
…pensearch-project#2895)

Signed-off-by: Bhavana Ramaram <[email protected]>
(cherry picked from commit 5f61df1)

Co-authored-by: Bhavana Ramaram <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and rbhavna authored Sep 5, 2024
1 parent 224f8fc commit ad10cb4
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions common/src/main/java/org/opensearch/ml/common/MLConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,17 @@ public void writeTo(StreamOutput out) throws IOException {
@Override
public XContentBuilder toXContent(XContentBuilder xContentBuilder, Params params) throws IOException {
XContentBuilder builder = xContentBuilder.startObject();
if (type != null) {
builder.field(TYPE_FIELD, type);
if (configType != null || type != null) {
builder.field(TYPE_FIELD, configType == null ? type : configType);
}
if (configType != null) {
builder.field(CONFIG_TYPE_FIELD, configType);
}
if (configuration != null) {
builder.field(CONFIGURATION_FIELD, configuration);
}
if (mlConfiguration != null) {
builder.field(ML_CONFIGURATION_FIELD, mlConfiguration);
if (configuration != null || mlConfiguration != null) {
builder.field(CONFIGURATION_FIELD, mlConfiguration == null ? configuration : mlConfiguration);
}
if (createTime != null) {
builder.field(CREATE_TIME_FIELD, createTime.toEpochMilli());
}
if (lastUpdateTime != null) {
builder.field(LAST_UPDATE_TIME_FIELD, lastUpdateTime.toEpochMilli());
}
if (lastUpdatedTime != null) {
builder.field(LAST_UPDATED_TIME_FIELD, lastUpdatedTime.toEpochMilli());
if (lastUpdateTime != null || lastUpdatedTime != null) {
builder.field(LAST_UPDATE_TIME_FIELD, lastUpdatedTime == null ? lastUpdateTime.toEpochMilli() : lastUpdatedTime.toEpochMilli());
}
return builder.endObject();
}
Expand Down

0 comments on commit ad10cb4

Please sign in to comment.