-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apis for get workflow alerts and acknowledge chained alerts (#472)
Signed-off-by: Surya Sashank Nistala <[email protected]>
- Loading branch information
Showing
17 changed files
with
766 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/kotlin/org/opensearch/commons/alerting/action/GetWorkflowAlertsRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/kotlin/org/opensearch/commons/alerting/action/GetWorkflowAlertsResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? | ||
) : 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() | ||
} | ||
} |
Oops, something went wrong.