From af9614432147e281840f79caab9d5ff1ed910631 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 19:19:48 -0700 Subject: [PATCH] changes to add start_time and end_time filters to getalertsrequest (#655) (#658) Signed-off-by: Subhobrata Dey --- .../commons/alerting/action/GetAlertsRequest.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/org/opensearch/commons/alerting/action/GetAlertsRequest.kt b/src/main/kotlin/org/opensearch/commons/alerting/action/GetAlertsRequest.kt index 8b8a5a1f..4592a9be 100644 --- a/src/main/kotlin/org/opensearch/commons/alerting/action/GetAlertsRequest.kt +++ b/src/main/kotlin/org/opensearch/commons/alerting/action/GetAlertsRequest.kt @@ -5,6 +5,7 @@ import org.opensearch.action.ActionRequestValidationException import org.opensearch.commons.alerting.model.Table import org.opensearch.core.common.io.stream.StreamInput import org.opensearch.core.common.io.stream.StreamOutput +import org.opensearch.index.query.BoolQueryBuilder import java.io.IOException class GetAlertsRequest : ActionRequest { @@ -16,6 +17,7 @@ class GetAlertsRequest : ActionRequest { val monitorIds: List? val workflowIds: List? val alertIds: List? + val boolQueryBuilder: BoolQueryBuilder? constructor( table: Table, @@ -25,7 +27,8 @@ class GetAlertsRequest : ActionRequest { alertIndex: String?, monitorIds: List? = null, workflowIds: List? = null, - alertIds: List? = null + alertIds: List? = null, + boolQueryBuilder: BoolQueryBuilder? = null ) : super() { this.table = table this.severityLevel = severityLevel @@ -35,6 +38,7 @@ class GetAlertsRequest : ActionRequest { this.monitorIds = monitorIds this.workflowIds = workflowIds this.alertIds = alertIds + this.boolQueryBuilder = boolQueryBuilder } @Throws(IOException::class) @@ -46,7 +50,8 @@ class GetAlertsRequest : ActionRequest { alertIndex = sin.readOptionalString(), monitorIds = sin.readOptionalStringList(), workflowIds = sin.readOptionalStringList(), - alertIds = sin.readOptionalStringList() + alertIds = sin.readOptionalStringList(), + boolQueryBuilder = if (sin.readOptionalBoolean() == true) BoolQueryBuilder(sin) else null ) override fun validate(): ActionRequestValidationException? { @@ -63,5 +68,11 @@ class GetAlertsRequest : ActionRequest { out.writeOptionalStringCollection(monitorIds) out.writeOptionalStringCollection(workflowIds) out.writeOptionalStringCollection(alertIds) + if (boolQueryBuilder != null) { + out.writeOptionalBoolean(true) + boolQueryBuilder.writeTo(out) + } else { + out.writeOptionalBoolean(false) + } } }