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

Feature findings enhancemnt #596

Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -13,19 +13,25 @@
val monitorId: String?
val monitorIds: List<String>?
AWSHurneyt marked this conversation as resolved.
Show resolved Hide resolved
val findingIndex: String?
val severity: String?
val detectionType: String?
AWSHurneyt marked this conversation as resolved.
Show resolved Hide resolved

constructor(
findingId: String?,
table: Table,
monitorId: String? = null,
findingIndexName: String? = null,
monitorIds: List<String>? = null
monitorIds: List<String>? = null,
severity: String? = null,
detectionType: String? = null

Check warning on line 26 in src/main/kotlin/org/opensearch/commons/alerting/action/GetFindingsRequest.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/commons/alerting/action/GetFindingsRequest.kt#L24-L26

Added lines #L24 - L26 were not covered by tests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be enums? Not sure if there's a fixed list of possibilities or not

) : super() {
this.findingId = findingId
this.table = table
this.monitorId = monitorId
this.findingIndex = findingIndexName
this.monitorIds = monitorIds
this.severity = severity
this.detectionType = detectionType
}

@Throws(IOException::class)
Expand All @@ -34,7 +40,9 @@
table = Table.readFrom(sin),
monitorId = sin.readOptionalString(),
findingIndexName = sin.readOptionalString(),
monitorIds = sin.readOptionalStringList()
monitorIds = sin.readOptionalStringList(),
severity = sin.readOptionalString(),
detectionType = sin.readOptionalString()
)

override fun validate(): ActionRequestValidationException? {
Expand All @@ -48,5 +56,7 @@
out.writeOptionalString(monitorId)
out.writeOptionalString(findingIndex)
out.writeOptionalStringCollection(monitorIds)
out.writeOptionalString(severity)
out.writeOptionalString(detectionType)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal class GetFindingsRequestTests {
fun `test get findings request`() {
val table = Table("asc", "sortString", null, 1, 0, "")

val req = GetFindingsRequest("2121", table, "1", "finding_index_name", listOf("1", "2"))
val req = GetFindingsRequest("2121", table, "1", "finding_index_name", listOf("1", "2"), "severity", "detectionType")
assertNotNull(req)

val out = BytesStreamOutput()
Expand All @@ -26,6 +26,8 @@ internal class GetFindingsRequestTests {
assertEquals("1", newReq.monitorId)
assertEquals("2121", newReq.findingId)
assertEquals("finding_index_name", newReq.findingIndex)
assertEquals("severity", newReq.severity)
assertEquals("detectionType", newReq.detectionType)
assertEquals(table, newReq.table)
assertTrue(newReq.monitorIds!!.contains("1"))
assertTrue(newReq.monitorIds!!.contains("2"))
Expand All @@ -35,7 +37,7 @@ internal class GetFindingsRequestTests {
fun `test validate returns null`() {
val table = Table("asc", "sortString", null, 1, 0, "")

val req = GetFindingsRequest("2121", table, "1", "active")
val req = GetFindingsRequest("2121", table, "1", "active", listOf("1", "2"), "severity", "detectionType")
assertNotNull(req)
assertNull(req.validate())
}
Expand Down
Loading