Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to add start_time and end_time filters to getAlertsRequest #655

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -16,6 +17,7 @@ class GetAlertsRequest : ActionRequest {
val monitorIds: List<String>?
val workflowIds: List<String>?
val alertIds: List<String>?
val boolQueryBuilder: BoolQueryBuilder?

constructor(
table: Table,
Expand All @@ -25,7 +27,8 @@ class GetAlertsRequest : ActionRequest {
alertIndex: String?,
monitorIds: List<String>? = null,
workflowIds: List<String>? = null,
alertIds: List<String>? = null
alertIds: List<String>? = null,
boolQueryBuilder: BoolQueryBuilder? = null
) : super() {
this.table = table
this.severityLevel = severityLevel
Expand All @@ -35,6 +38,7 @@ class GetAlertsRequest : ActionRequest {
this.monitorIds = monitorIds
this.workflowIds = workflowIds
this.alertIds = alertIds
this.boolQueryBuilder = boolQueryBuilder
}

@Throws(IOException::class)
Expand All @@ -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? {
Expand All @@ -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)
}
}
}
Loading