-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#414) Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
- Loading branch information
1 parent
65ecf37
commit d6f88ce
Showing
6 changed files
with
116 additions
and
0 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
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/org/opensearch/commons/alerting/action/PublishFindingsRequest.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,38 @@ | ||
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.Finding | ||
import java.io.IOException | ||
|
||
class PublishFindingsRequest : ActionRequest { | ||
|
||
val monitorId: String | ||
|
||
val finding: Finding | ||
|
||
constructor( | ||
monitorId: String, | ||
finding: Finding | ||
) : super() { | ||
this.monitorId = monitorId | ||
this.finding = finding | ||
} | ||
|
||
@Throws(IOException::class) | ||
constructor(sin: StreamInput) : this( | ||
monitorId = sin.readString(), | ||
finding = Finding.readFrom(sin) | ||
) | ||
|
||
override fun validate(): ActionRequestValidationException? { | ||
return null | ||
} | ||
|
||
override fun writeTo(out: StreamOutput) { | ||
out.writeString(monitorId) | ||
finding.writeTo(out) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/org/opensearch/commons/alerting/action/SubscribeFindingsResponse.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,38 @@ | ||
package org.opensearch.commons.alerting.action | ||
|
||
import org.opensearch.common.io.stream.StreamInput | ||
import org.opensearch.common.io.stream.StreamOutput | ||
import org.opensearch.commons.notifications.action.BaseResponse | ||
import org.opensearch.core.xcontent.ToXContent | ||
import org.opensearch.core.xcontent.XContentBuilder | ||
import org.opensearch.rest.RestStatus | ||
import java.io.IOException | ||
|
||
class SubscribeFindingsResponse : BaseResponse { | ||
|
||
private var status: RestStatus | ||
|
||
constructor(status: RestStatus) : super() { | ||
this.status = status | ||
} | ||
|
||
@Throws(IOException::class) | ||
constructor(sin: StreamInput) { | ||
this.status = sin.readEnum(RestStatus::class.java) | ||
} | ||
|
||
@Throws(IOException::class) | ||
override fun writeTo(out: StreamOutput) { | ||
out.writeEnum(status) | ||
} | ||
|
||
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { | ||
builder.startObject() | ||
.field("status", status.status) | ||
return builder.endObject() | ||
} | ||
|
||
override fun getStatus(): RestStatus { | ||
return this.status | ||
} | ||
} |
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