-
Notifications
You must be signed in to change notification settings - Fork 95
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
apis for get workflow alerts and acknowledge chained alerts #472
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.opensearch.commons.alerting.action | ||
|
||
import org.opensearch.action.ActionRequest | ||
import org.opensearch.action.ActionRequestValidationException | ||
import org.opensearch.common.io.stream.StreamInput | ||
import org.opensearch.common.io.stream.StreamOutput | ||
import org.opensearch.commons.alerting.model.Table | ||
import java.io.IOException | ||
|
||
class GetWorkflowAlertsRequest : ActionRequest { | ||
val table: Table | ||
val severityLevel: String | ||
val alertState: String | ||
val alertIndex: String? | ||
val monitorIds: List<String>? | ||
val workflowIds: List<String>? | ||
val alertIds: List<String>? | ||
val getAssociatedAlerts: Boolean | ||
|
||
constructor( | ||
table: Table, | ||
severityLevel: String, | ||
alertState: String, | ||
alertIndex: String?, | ||
monitorIds: List<String>? = null, | ||
workflowIds: List<String>? = null, | ||
alertIds: List<String>? = null, | ||
getAssociatedAlerts: Boolean | ||
) : super() { | ||
this.table = table | ||
this.severityLevel = severityLevel | ||
this.alertState = alertState | ||
this.alertIndex = alertIndex | ||
this.monitorIds = monitorIds | ||
this.workflowIds = workflowIds | ||
this.alertIds = alertIds | ||
this.getAssociatedAlerts = getAssociatedAlerts | ||
} | ||
|
||
@Throws(IOException::class) | ||
constructor(sin: StreamInput) : this( | ||
table = Table.readFrom(sin), | ||
severityLevel = sin.readString(), | ||
alertState = sin.readString(), | ||
alertIndex = sin.readOptionalString(), | ||
monitorIds = sin.readOptionalStringList(), | ||
workflowIds = sin.readOptionalStringList(), | ||
alertIds = sin.readOptionalStringList(), | ||
getAssociatedAlerts = sin.readBoolean() | ||
) | ||
|
||
override fun validate(): ActionRequestValidationException? { | ||
return null | ||
} | ||
|
||
@Throws(IOException::class) | ||
override fun writeTo(out: StreamOutput) { | ||
table.writeTo(out) | ||
out.writeString(severityLevel) | ||
out.writeString(alertState) | ||
out.writeOptionalString(alertIndex) | ||
out.writeOptionalStringCollection(monitorIds) | ||
out.writeOptionalStringCollection(workflowIds) | ||
out.writeOptionalStringCollection(alertIds) | ||
out.writeBoolean(getAssociatedAlerts) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.opensearch.commons.alerting.action | ||
|
||
import org.opensearch.common.io.stream.StreamInput | ||
import org.opensearch.common.io.stream.StreamOutput | ||
import org.opensearch.commons.alerting.model.Alert | ||
import org.opensearch.commons.notifications.action.BaseResponse | ||
import org.opensearch.core.xcontent.ToXContent | ||
import org.opensearch.core.xcontent.XContentBuilder | ||
import java.io.IOException | ||
import java.util.Collections | ||
|
||
class GetWorkflowAlertsResponse : BaseResponse { | ||
val alerts: List<Alert> | ||
val associatedAlerts: List<Alert> | ||
// totalAlerts is not the same as the size of alerts because there can be 30 alerts from the request, but | ||
// the request only asked for 5 alerts, so totalAlerts will be 30, but alerts will only contain 5 alerts | ||
val totalAlerts: Int? | ||
|
||
constructor( | ||
alerts: List<Alert>, | ||
associatedAlerts: List<Alert>, | ||
totalAlerts: Int? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a parallel api to get alerts. Keeping it consistent with the response structure of GetAlertsResponse which has totalAlerts as nullable |
||
) : super() { | ||
this.alerts = alerts | ||
this.associatedAlerts = associatedAlerts | ||
this.totalAlerts = totalAlerts | ||
} | ||
|
||
@Throws(IOException::class) | ||
constructor(sin: StreamInput) : this( | ||
alerts = Collections.unmodifiableList(sin.readList(::Alert)), | ||
associatedAlerts = Collections.unmodifiableList(sin.readList(::Alert)), | ||
totalAlerts = sin.readOptionalInt() | ||
) | ||
|
||
@Throws(IOException::class) | ||
override fun writeTo(out: StreamOutput) { | ||
out.writeCollection(alerts) | ||
out.writeCollection(associatedAlerts) | ||
out.writeOptionalInt(totalAlerts) | ||
} | ||
|
||
@Throws(IOException::class) | ||
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { | ||
builder.startObject() | ||
.field("alerts", alerts) | ||
.field("associatedAlerts", associatedAlerts) | ||
.field("totalAlerts", totalAlerts) | ||
return builder.endObject() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing
@JvmField
annotation?