Skip to content

Commit

Permalink
changes to add start_time and end_time filters to getalertsrequest
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
  • Loading branch information
sbcd90 committed May 21, 2024
1 parent 66359f8 commit fce69e2
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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
Expand All @@ -61,6 +62,7 @@ class TransportGetAlertsAction @Inject constructor(
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val namedWriteableRegistry: NamedWriteableRegistry
) : HandledTransportAction<ActionRequest, GetAlertsResponse>(
AlertingActions.GET_ALERTS_ACTION_NAME,
transportService,
Expand All @@ -82,7 +84,7 @@ class TransportGetAlertsAction @Inject constructor(
actionListener: ActionListener<GetAlertsResponse>,
) {
val getAlertsRequest = request as? GetAlertsRequest
?: recreateObject(request) { GetAlertsRequest(it) }
?: recreateObject(request, namedWriteableRegistry) { GetAlertsRequest(it) }
val user = readUserFromThreadContext(client)

val tableProp = getAlertsRequest.table
Expand All @@ -93,7 +95,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))
Expand Down

0 comments on commit fce69e2

Please sign in to comment.