From bd2564c1dde63581dfb1272842a9dbf9853c092c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 21 May 2024 22:08:06 +0000 Subject: [PATCH] changes to add start_time and end_time filters to getalertsrequest (#1551) Signed-off-by: Subhobrata Dey (cherry picked from commit 859756158ee6c874685823ba6051ca557fe690e6) Signed-off-by: github-actions[bot] --- .../alerting/transport/TransportGetAlertsAction.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetAlertsAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetAlertsAction.kt index 604c130fc..2745501b7 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetAlertsAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetAlertsAction.kt @@ -37,6 +37,7 @@ import org.opensearch.commons.alerting.model.ScheduledJob import org.opensearch.commons.authuser.User import org.opensearch.commons.utils.recreateObject import org.opensearch.core.action.ActionListener +import org.opensearch.core.common.io.stream.NamedWriteableRegistry import org.opensearch.core.xcontent.NamedXContentRegistry import org.opensearch.core.xcontent.XContentParser import org.opensearch.core.xcontent.XContentParserUtils @@ -60,6 +61,7 @@ class TransportGetAlertsAction @Inject constructor( actionFilters: ActionFilters, val settings: Settings, val xContentRegistry: NamedXContentRegistry, + val namedWriteableRegistry: NamedWriteableRegistry ) : HandledTransportAction( AlertingActions.GET_ALERTS_ACTION_NAME, transportService, @@ -81,7 +83,7 @@ class TransportGetAlertsAction @Inject constructor( actionListener: ActionListener, ) { val getAlertsRequest = request as? GetAlertsRequest - ?: recreateObject(request) { GetAlertsRequest(it) } + ?: recreateObject(request, namedWriteableRegistry) { GetAlertsRequest(it) } val user = readUserFromThreadContext(client) val tableProp = getAlertsRequest.table @@ -92,7 +94,7 @@ class TransportGetAlertsAction @Inject constructor( sortBuilder.missing(tableProp.missing) } - val queryBuilder = QueryBuilders.boolQuery() + val queryBuilder = getAlertsRequest.boolQueryBuilder ?: QueryBuilders.boolQuery() if (getAlertsRequest.severityLevel != "ALL") { queryBuilder.filter(QueryBuilders.termQuery("severity", getAlertsRequest.severityLevel))