@@ -27,11 +27,18 @@ public class MLConfig implements ToXContentObject, Writeable {
2727
2828 public static final String TYPE_FIELD = "type" ;
2929
30+ public static final String CONFIG_TYPE_FIELD = "config_type" ;
31+
3032 public static final String CONFIGURATION_FIELD = "configuration" ;
3133
34+ public static final String ML_CONFIGURATION_FIELD = "ml_configuration" ;
35+
3236 public static final String CREATE_TIME_FIELD = "create_time" ;
3337 public static final String LAST_UPDATE_TIME_FIELD = "last_update_time" ;
3438
39+ public static final String LAST_UPDATED_TIME_FIELD = "last_updated_time" ;
40+
41+
3542 @ Setter
3643 private String type ;
3744
@@ -78,10 +85,10 @@ public void writeTo(StreamOutput out) throws IOException {
7885 public XContentBuilder toXContent (XContentBuilder xContentBuilder , Params params ) throws IOException {
7986 XContentBuilder builder = xContentBuilder .startObject ();
8087 if (type != null ) {
81- builder .field (TYPE_FIELD , type );
88+ builder .field (CONFIG_TYPE_FIELD , type );
8289 }
8390 if (configuration != null ) {
84- builder .field (CONFIGURATION_FIELD , configuration );
91+ builder .field (ML_CONFIGURATION_FIELD , configuration );
8592 }
8693 if (createTime != null ) {
8794 builder .field (CREATE_TIME_FIELD , createTime .toEpochMilli ());
@@ -99,9 +106,12 @@ public static MLConfig fromStream(StreamInput in) throws IOException {
99106
100107 public static MLConfig parse (XContentParser parser ) throws IOException {
101108 String type = null ;
109+ String configType = null ;
102110 Configuration configuration = null ;
111+ Configuration mlConfiguration = null ;
103112 Instant createTime = null ;
104113 Instant lastUpdateTime = null ;
114+ Instant lastUpdatedTime = null ;
105115
106116 ensureExpectedToken (XContentParser .Token .START_OBJECT , parser .currentToken (), parser );
107117 while (parser .nextToken () != XContentParser .Token .END_OBJECT ) {
@@ -112,25 +122,34 @@ public static MLConfig parse(XContentParser parser) throws IOException {
112122 case TYPE_FIELD :
113123 type = parser .text ();
114124 break ;
125+ case CONFIG_TYPE_FIELD :
126+ configType = parser .text ();
127+ break ;
115128 case CONFIGURATION_FIELD :
116129 configuration = Configuration .parse (parser );
117130 break ;
131+ case ML_CONFIGURATION_FIELD :
132+ mlConfiguration = Configuration .parse (parser );
133+ break ;
118134 case CREATE_TIME_FIELD :
119135 createTime = Instant .ofEpochMilli (parser .longValue ());
120136 break ;
121137 case LAST_UPDATE_TIME_FIELD :
122138 lastUpdateTime = Instant .ofEpochMilli (parser .longValue ());
123139 break ;
140+ case LAST_UPDATED_TIME_FIELD :
141+ lastUpdatedTime = Instant .ofEpochMilli (parser .longValue ());
142+ break ;
124143 default :
125144 parser .skipChildren ();
126145 break ;
127146 }
128147 }
129148 return MLConfig .builder ()
130- .type (type )
131- .configuration (configuration )
149+ .type (configType == null ? type : configType )
150+ .configuration (mlConfiguration == null ? configuration : mlConfiguration )
132151 .createTime (createTime )
133- .lastUpdateTime (lastUpdateTime )
152+ .lastUpdateTime (lastUpdatedTime == null ? lastUpdateTime : lastUpdatedTime )
134153 .build ();
135154 }
136155}
0 commit comments