@@ -42,6 +42,7 @@ data class Monitor(
42
42
val triggers : List <Trigger >,
43
43
val uiMetadata : Map <String , Any >,
44
44
val dataSources : DataSources = DataSources (),
45
+ val deleteQueryIndexInEveryRun : Boolean? = false ,
45
46
val owner : String? = " alerting"
46
47
) : ScheduledJob {
47
48
@@ -110,6 +111,7 @@ data class Monitor(
110
111
} else {
111
112
DataSources ()
112
113
},
114
+ deleteQueryIndexInEveryRun = sin.readOptionalBoolean(),
113
115
owner = sin.readOptionalString()
114
116
)
115
117
@@ -169,6 +171,7 @@ data class Monitor(
169
171
.optionalTimeField(LAST_UPDATE_TIME_FIELD , lastUpdateTime)
170
172
if (uiMetadata.isNotEmpty()) builder.field(UI_METADATA_FIELD , uiMetadata)
171
173
builder.field(DATA_SOURCES_FIELD , dataSources)
174
+ builder.field(DELETE_QUERY_INDEX_IN_EVERY_RUN_FIELD , deleteQueryIndexInEveryRun)
172
175
builder.field(OWNER_FIELD , owner)
173
176
if (params.paramAsBoolean(" with_type" , false )) builder.endObject()
174
177
return builder.endObject()
@@ -220,6 +223,7 @@ data class Monitor(
220
223
out .writeMap(uiMetadata)
221
224
out .writeBoolean(dataSources != null ) // for backward compatibility with pre-existing monitors which don't have datasources field
222
225
dataSources.writeTo(out )
226
+ out .writeOptionalBoolean(deleteQueryIndexInEveryRun)
223
227
out .writeOptionalString(owner)
224
228
}
225
229
@@ -240,6 +244,7 @@ data class Monitor(
240
244
const val UI_METADATA_FIELD = " ui_metadata"
241
245
const val DATA_SOURCES_FIELD = " data_sources"
242
246
const val ENABLED_TIME_FIELD = " enabled_time"
247
+ const val DELETE_QUERY_INDEX_IN_EVERY_RUN_FIELD = " delete_query_index_in_every_run"
243
248
const val OWNER_FIELD = " owner"
244
249
val MONITOR_TYPE_PATTERN = Pattern .compile(" [a-zA-Z0-9_]{5,25}" )
245
250
@@ -268,6 +273,7 @@ data class Monitor(
268
273
val triggers: MutableList <Trigger > = mutableListOf ()
269
274
val inputs: MutableList <Input > = mutableListOf ()
270
275
var dataSources = DataSources ()
276
+ var deleteQueryIndexInEveryRun = false
271
277
var owner = " alerting"
272
278
273
279
XContentParserUtils .ensureExpectedToken(XContentParser .Token .START_OBJECT , xcp.currentToken(), xcp)
@@ -321,6 +327,11 @@ data class Monitor(
321
327
} else {
322
328
DataSources .parse(xcp)
323
329
}
330
+ DELETE_QUERY_INDEX_IN_EVERY_RUN_FIELD -> deleteQueryIndexInEveryRun = if (xcp.currentToken() == XContentParser .Token .VALUE_NULL ) {
331
+ deleteQueryIndexInEveryRun
332
+ } else {
333
+ xcp.booleanValue()
334
+ }
324
335
OWNER_FIELD -> owner = if (xcp.currentToken() == XContentParser .Token .VALUE_NULL ) owner else xcp.text()
325
336
else -> {
326
337
xcp.skipChildren()
@@ -348,6 +359,7 @@ data class Monitor(
348
359
triggers.toList(),
349
360
uiMetadata,
350
361
dataSources,
362
+ deleteQueryIndexInEveryRun,
351
363
owner
352
364
)
353
365
}
0 commit comments