@@ -48,6 +48,7 @@ public class TransformConfig implements ToXContentObject {
48
48
public static final ParseField FREQUENCY = new ParseField ("frequency" );
49
49
public static final ParseField DESCRIPTION = new ParseField ("description" );
50
50
public static final ParseField SYNC = new ParseField ("sync" );
51
+ public static final ParseField SETTINGS = new ParseField ("settings" );
51
52
public static final ParseField VERSION = new ParseField ("version" );
52
53
public static final ParseField CREATE_TIME = new ParseField ("create_time" );
53
54
// types of transforms
@@ -58,45 +59,61 @@ public class TransformConfig implements ToXContentObject {
58
59
private final DestConfig dest ;
59
60
private final TimeValue frequency ;
60
61
private final SyncConfig syncConfig ;
62
+ private final SettingsConfig settings ;
61
63
private final PivotConfig pivotConfig ;
62
64
private final String description ;
63
65
private final Version transformVersion ;
64
66
private final Instant createTime ;
65
67
66
- public static final ConstructingObjectParser <TransformConfig , Void > PARSER =
67
- new ConstructingObjectParser <>("transform" , true ,
68
- (args ) -> {
69
- String id = (String ) args [0 ];
70
- SourceConfig source = (SourceConfig ) args [1 ];
71
- DestConfig dest = (DestConfig ) args [2 ];
72
- TimeValue frequency = (TimeValue ) args [3 ];
73
- SyncConfig syncConfig = (SyncConfig ) args [4 ];
74
- PivotConfig pivotConfig = (PivotConfig ) args [5 ];
75
- String description = (String )args [6 ];
76
- Instant createTime = (Instant )args [7 ];
77
- String transformVersion = (String )args [8 ];
78
- return new TransformConfig (id ,
79
- source ,
80
- dest ,
81
- frequency ,
82
- syncConfig ,
83
- pivotConfig ,
84
- description ,
85
- createTime ,
86
- transformVersion );
87
- });
68
+ public static final ConstructingObjectParser <TransformConfig , Void > PARSER = new ConstructingObjectParser <>(
69
+ "transform" ,
70
+ true ,
71
+ (args ) -> {
72
+ String id = (String ) args [0 ];
73
+ SourceConfig source = (SourceConfig ) args [1 ];
74
+ DestConfig dest = (DestConfig ) args [2 ];
75
+ TimeValue frequency = (TimeValue ) args [3 ];
76
+ SyncConfig syncConfig = (SyncConfig ) args [4 ];
77
+ PivotConfig pivotConfig = (PivotConfig ) args [5 ];
78
+ String description = (String ) args [6 ];
79
+ SettingsConfig settings = (SettingsConfig ) args [7 ];
80
+ Instant createTime = (Instant ) args [8 ];
81
+ String transformVersion = (String ) args [9 ];
82
+ return new TransformConfig (
83
+ id ,
84
+ source ,
85
+ dest ,
86
+ frequency ,
87
+ syncConfig ,
88
+ pivotConfig ,
89
+ description ,
90
+ settings ,
91
+ createTime ,
92
+ transformVersion
93
+ );
94
+ }
95
+ );
88
96
89
97
static {
90
98
PARSER .declareString (constructorArg (), ID );
91
99
PARSER .declareObject (constructorArg (), (p , c ) -> SourceConfig .PARSER .apply (p , null ), SOURCE );
92
100
PARSER .declareObject (constructorArg (), (p , c ) -> DestConfig .PARSER .apply (p , null ), DEST );
93
- PARSER .declareField (optionalConstructorArg (), p -> TimeValue .parseTimeValue (p .text (), FREQUENCY .getPreferredName ()),
94
- FREQUENCY , ObjectParser .ValueType .STRING );
101
+ PARSER .declareField (
102
+ optionalConstructorArg (),
103
+ p -> TimeValue .parseTimeValue (p .text (), FREQUENCY .getPreferredName ()),
104
+ FREQUENCY ,
105
+ ObjectParser .ValueType .STRING
106
+ );
95
107
PARSER .declareObject (optionalConstructorArg (), (p , c ) -> parseSyncConfig (p ), SYNC );
96
108
PARSER .declareObject (optionalConstructorArg (), (p , c ) -> PivotConfig .fromXContent (p ), PIVOT_TRANSFORM );
97
109
PARSER .declareString (optionalConstructorArg (), DESCRIPTION );
98
- PARSER .declareField (optionalConstructorArg (),
99
- p -> TimeUtil .parseTimeFieldToInstant (p , CREATE_TIME .getPreferredName ()), CREATE_TIME , ObjectParser .ValueType .VALUE );
110
+ PARSER .declareObject (optionalConstructorArg (), (p , c ) -> SettingsConfig .fromXContent (p ), SETTINGS );
111
+ PARSER .declareField (
112
+ optionalConstructorArg (),
113
+ p -> TimeUtil .parseTimeFieldToInstant (p , CREATE_TIME .getPreferredName ()),
114
+ CREATE_TIME ,
115
+ ObjectParser .ValueType .VALUE
116
+ );
100
117
PARSER .declareString (optionalConstructorArg (), VERSION );
101
118
}
102
119
@@ -108,7 +125,6 @@ private static SyncConfig parseSyncConfig(XContentParser parser) throws IOExcept
108
125
return syncConfig ;
109
126
}
110
127
111
-
112
128
public static TransformConfig fromXContent (final XContentParser parser ) {
113
129
return PARSER .apply (parser , null );
114
130
}
@@ -125,25 +141,29 @@ public static TransformConfig fromXContent(final XContentParser parser) {
125
141
* @return A TransformConfig to preview, NOTE it will have a {@code null} id, destination and index.
126
142
*/
127
143
public static TransformConfig forPreview (final SourceConfig source , final PivotConfig pivotConfig ) {
128
- return new TransformConfig (null , source , null , null , null , pivotConfig , null , null , null );
144
+ return new TransformConfig (null , source , null , null , null , pivotConfig , null , null , null , null );
129
145
}
130
146
131
- TransformConfig (final String id ,
132
- final SourceConfig source ,
133
- final DestConfig dest ,
134
- final TimeValue frequency ,
135
- final SyncConfig syncConfig ,
136
- final PivotConfig pivotConfig ,
137
- final String description ,
138
- final Instant createTime ,
139
- final String version ) {
147
+ TransformConfig (
148
+ final String id ,
149
+ final SourceConfig source ,
150
+ final DestConfig dest ,
151
+ final TimeValue frequency ,
152
+ final SyncConfig syncConfig ,
153
+ final PivotConfig pivotConfig ,
154
+ final String description ,
155
+ final SettingsConfig settings ,
156
+ final Instant createTime ,
157
+ final String version
158
+ ) {
140
159
this .id = id ;
141
160
this .source = source ;
142
161
this .dest = dest ;
143
162
this .frequency = frequency ;
144
163
this .syncConfig = syncConfig ;
145
164
this .pivotConfig = pivotConfig ;
146
165
this .description = description ;
166
+ this .settings = settings ;
147
167
this .createTime = createTime == null ? null : Instant .ofEpochMilli (createTime .toEpochMilli ());
148
168
this .transformVersion = version == null ? null : Version .fromString (version );
149
169
}
@@ -185,6 +205,11 @@ public String getDescription() {
185
205
return description ;
186
206
}
187
207
208
+ @ Nullable
209
+ public SettingsConfig getSettings () {
210
+ return settings ;
211
+ }
212
+
188
213
@ Override
189
214
public XContentBuilder toXContent (final XContentBuilder builder , final Params params ) throws IOException {
190
215
builder .startObject ();
@@ -211,6 +236,9 @@ public XContentBuilder toXContent(final XContentBuilder builder, final Params pa
211
236
if (description != null ) {
212
237
builder .field (DESCRIPTION .getPreferredName (), description );
213
238
}
239
+ if (settings != null ) {
240
+ builder .field (SETTINGS .getPreferredName (), settings );
241
+ }
214
242
if (createTime != null ) {
215
243
builder .timeField (CREATE_TIME .getPreferredName (), CREATE_TIME .getPreferredName () + "_string" , createTime .toEpochMilli ());
216
244
}
@@ -240,13 +268,14 @@ public boolean equals(Object other) {
240
268
&& Objects .equals (this .description , that .description )
241
269
&& Objects .equals (this .syncConfig , that .syncConfig )
242
270
&& Objects .equals (this .transformVersion , that .transformVersion )
271
+ && Objects .equals (this .settings , that .settings )
243
272
&& Objects .equals (this .createTime , that .createTime )
244
273
&& Objects .equals (this .pivotConfig , that .pivotConfig );
245
274
}
246
275
247
276
@ Override
248
277
public int hashCode () {
249
- return Objects .hash (id , source , dest , frequency , syncConfig , pivotConfig , description );
278
+ return Objects .hash (id , source , dest , frequency , syncConfig , settings , createTime , transformVersion , pivotConfig , description );
250
279
}
251
280
252
281
@ Override
@@ -266,6 +295,7 @@ public static class Builder {
266
295
private TimeValue frequency ;
267
296
private SyncConfig syncConfig ;
268
297
private PivotConfig pivotConfig ;
298
+ private SettingsConfig settings ;
269
299
private String description ;
270
300
271
301
public Builder setId (String id ) {
@@ -303,8 +333,13 @@ public Builder setDescription(String description) {
303
333
return this ;
304
334
}
305
335
336
+ public Builder setSettings (SettingsConfig settings ) {
337
+ this .settings = settings ;
338
+ return this ;
339
+ }
340
+
306
341
public TransformConfig build () {
307
- return new TransformConfig (id , source , dest , frequency , syncConfig , pivotConfig , description , null , null );
342
+ return new TransformConfig (id , source , dest , frequency , syncConfig , pivotConfig , description , settings , null , null );
308
343
}
309
344
}
310
345
}
0 commit comments