Skip to content

Commit cb9d38b

Browse files
Monitor model changed to add an optional fanoutEnabled field (#758)
* Monitor model changed to add an optional fanoutEnabled field Signed-off-by: Riya Saxena <[email protected]> * Monitor model changed to add an optional fanoutEnabled field Signed-off-by: Riya Saxena <[email protected]> * move fanoutEnabled to docLevel input Signed-off-by: Riya Saxena <[email protected]> * move fanoutEnabled to docLevel input Signed-off-by: Riya Saxena <[email protected]> * move fanoutEnabled to docLevel input Signed-off-by: Riya Saxena <[email protected]> --------- Signed-off-by: Riya Saxena <[email protected]>
1 parent 197eb82 commit cb9d38b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/main/kotlin/org/opensearch/commons/alerting/model/DocLevelMonitorInput.kt

+14-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ import java.io.IOException
1414
data class DocLevelMonitorInput(
1515
val description: String = NO_DESCRIPTION,
1616
val indices: List<String>,
17-
val queries: List<DocLevelQuery>
17+
val queries: List<DocLevelQuery>,
18+
val fanoutEnabled: Boolean? = true
1819
) : Input {
1920

2021
@Throws(IOException::class)
2122
constructor(sin: StreamInput) : this(
2223
sin.readString(), // description
2324
sin.readStringList(), // indices
24-
sin.readList(::DocLevelQuery) // docLevelQueries
25+
sin.readList(::DocLevelQuery), // docLevelQueries
26+
sin.readOptionalBoolean() // fanoutEnabled
2527
)
2628

2729
override fun asTemplateArg(): Map<String, Any> {
@@ -41,6 +43,7 @@ data class DocLevelMonitorInput(
4143
out.writeString(description)
4244
out.writeStringCollection(indices)
4345
out.writeCollection(queries)
46+
out.writeOptionalBoolean(fanoutEnabled)
4447
}
4548

4649
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder {
@@ -49,6 +52,7 @@ data class DocLevelMonitorInput(
4952
.field(DESCRIPTION_FIELD, description)
5053
.field(INDICES_FIELD, indices.toTypedArray())
5154
.field(QUERIES_FIELD, queries.toTypedArray())
55+
.field(FANOUT_FIELD, fanoutEnabled)
5256
.endObject()
5357
.endObject()
5458
return builder
@@ -59,7 +63,7 @@ data class DocLevelMonitorInput(
5963
const val INDICES_FIELD = "indices"
6064
const val DOC_LEVEL_INPUT_FIELD = "doc_level_input"
6165
const val QUERIES_FIELD = "queries"
62-
66+
const val FANOUT_FIELD = "fan_out_enabled"
6367
const val NO_DESCRIPTION = ""
6468

6569
val XCONTENT_REGISTRY = NamedXContentRegistry.Entry(
@@ -74,6 +78,7 @@ data class DocLevelMonitorInput(
7478
var description: String = NO_DESCRIPTION
7579
val indices: MutableList<String> = mutableListOf()
7680
val docLevelQueries: MutableList<DocLevelQuery> = mutableListOf()
81+
var fanoutEnabled: Boolean? = true
7782

7883
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.currentToken(), xcp)
7984
while (xcp.nextToken() != XContentParser.Token.END_OBJECT) {
@@ -102,10 +107,15 @@ data class DocLevelMonitorInput(
102107
docLevelQueries.add(DocLevelQuery.parse(xcp))
103108
}
104109
}
110+
FANOUT_FIELD -> fanoutEnabled = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) {
111+
fanoutEnabled
112+
} else {
113+
xcp.booleanValue()
114+
}
105115
}
106116
}
107117

108-
return DocLevelMonitorInput(description = description, indices = indices, queries = docLevelQueries)
118+
return DocLevelMonitorInput(description = description, indices = indices, queries = docLevelQueries, fanoutEnabled = fanoutEnabled)
109119
}
110120

111121
@JvmStatic

0 commit comments

Comments
 (0)