-
Notifications
You must be signed in to change notification settings - Fork 94
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
Added workflow as a composite monitor #380
Merged
eirsep
merged 4 commits into
opensearch-project:feature/composite-monitors
from
stevanbz:feature/composite-monitors-workflow
Mar 21, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8233e7f
Added workflow as a composite monitor
stevanbz a2a2ede
Removed property from workflow. Added comments and aligned code accor…
stevanbz b66c0dc
Added java docs for workflow related fields and classes. Removed unus…
stevanbz 6e2f32f
Updated finding comment
stevanbz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/DeleteWorkflowRequest.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 java.io.IOException | ||
|
||
class DeleteWorkflowRequest : ActionRequest { | ||
|
||
val workflowId: String | ||
/** | ||
* Flag that indicates whether the delegate monitors should be deleted or not. | ||
* If the flag is set to true, Delegate monitors will be deleted only in the case when they are part of the specified workflow and no other. | ||
*/ | ||
val deleteDelegateMonitors: Boolean? | ||
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. java docs |
||
|
||
constructor(workflowId: String, deleteDelegateMonitors: Boolean?) : super() { | ||
this.workflowId = workflowId | ||
this.deleteDelegateMonitors = deleteDelegateMonitors | ||
} | ||
|
||
@Throws(IOException::class) | ||
constructor(sin: StreamInput) : this( | ||
workflowId = sin.readString(), | ||
deleteDelegateMonitors = sin.readOptionalBoolean() | ||
) | ||
|
||
override fun validate(): ActionRequestValidationException? { | ||
return null | ||
} | ||
|
||
@Throws(IOException::class) | ||
override fun writeTo(out: StreamOutput) { | ||
out.writeString(workflowId) | ||
out.writeOptionalBoolean(deleteDelegateMonitors) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/org/opensearch/commons/alerting/action/DeleteWorkflowResponse.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.common.xcontent.ToXContent | ||
import org.opensearch.common.xcontent.XContentBuilder | ||
import org.opensearch.commons.alerting.util.IndexUtils | ||
import org.opensearch.commons.notifications.action.BaseResponse | ||
|
||
class DeleteWorkflowResponse : BaseResponse { | ||
var id: String | ||
var version: Long | ||
|
||
constructor( | ||
id: String, | ||
version: Long | ||
) : super() { | ||
this.id = id | ||
this.version = version | ||
} | ||
|
||
constructor(sin: StreamInput) : this( | ||
sin.readString(), // id | ||
sin.readLong() // version | ||
) | ||
|
||
override fun writeTo(out: StreamOutput) { | ||
out.writeString(id) | ||
out.writeLong(version) | ||
} | ||
|
||
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { | ||
return builder.startObject() | ||
.field(IndexUtils._ID, id) | ||
.field(IndexUtils._VERSION, version) | ||
.endObject() | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/org/opensearch/commons/alerting/action/GetWorkflowRequest.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,42 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
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.rest.RestRequest | ||
import java.io.IOException | ||
|
||
class GetWorkflowRequest : ActionRequest { | ||
val workflowId: String | ||
val method: RestRequest.Method | ||
|
||
constructor( | ||
workflowId: String, | ||
method: RestRequest.Method | ||
) : super() { | ||
this.workflowId = workflowId | ||
this.method = method | ||
} | ||
|
||
@Throws(IOException::class) | ||
constructor(sin: StreamInput) : this( | ||
sin.readString(), // workflowId | ||
sin.readEnum(RestRequest.Method::class.java) // method | ||
) | ||
|
||
override fun validate(): ActionRequestValidationException? { | ||
return null | ||
} | ||
|
||
@Throws(IOException::class) | ||
override fun writeTo(out: StreamOutput) { | ||
out.writeString(workflowId) | ||
out.writeEnum(method) | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
src/main/kotlin/org/opensearch/commons/alerting/action/GetWorkflowResponse.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,88 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.commons.alerting.action | ||
|
||
import org.opensearch.common.io.stream.StreamInput | ||
import org.opensearch.common.io.stream.StreamOutput | ||
import org.opensearch.common.xcontent.ToXContent | ||
import org.opensearch.common.xcontent.XContentBuilder | ||
import org.opensearch.commons.alerting.model.Workflow | ||
import org.opensearch.commons.alerting.util.IndexUtils.Companion._ID | ||
import org.opensearch.commons.alerting.util.IndexUtils.Companion._PRIMARY_TERM | ||
import org.opensearch.commons.alerting.util.IndexUtils.Companion._SEQ_NO | ||
import org.opensearch.commons.alerting.util.IndexUtils.Companion._VERSION | ||
import org.opensearch.commons.notifications.action.BaseResponse | ||
import org.opensearch.rest.RestStatus | ||
import java.io.IOException | ||
|
||
class GetWorkflowResponse : BaseResponse { | ||
var id: String | ||
var version: Long | ||
var seqNo: Long | ||
var primaryTerm: Long | ||
private var status: RestStatus | ||
var workflow: Workflow? | ||
|
||
constructor( | ||
id: String, | ||
version: Long, | ||
seqNo: Long, | ||
primaryTerm: Long, | ||
status: RestStatus, | ||
workflow: Workflow? | ||
) : super() { | ||
this.id = id | ||
this.version = version | ||
this.seqNo = seqNo | ||
this.primaryTerm = primaryTerm | ||
this.status = status | ||
this.workflow = workflow | ||
} | ||
|
||
@Throws(IOException::class) | ||
constructor(sin: StreamInput) : this( | ||
sin.readString(), // id | ||
sin.readLong(), // version | ||
sin.readLong(), // seqNo | ||
sin.readLong(), // primaryTerm | ||
sin.readEnum(RestStatus::class.java), // RestStatus | ||
if (sin.readBoolean()) { | ||
Workflow.readFrom(sin) // monitor | ||
} else null | ||
) | ||
|
||
@Throws(IOException::class) | ||
override fun writeTo(out: StreamOutput) { | ||
out.writeString(id) | ||
out.writeLong(version) | ||
out.writeLong(seqNo) | ||
out.writeLong(primaryTerm) | ||
out.writeEnum(status) | ||
if (workflow != null) { | ||
out.writeBoolean(true) | ||
workflow?.writeTo(out) | ||
} else { | ||
out.writeBoolean(false) | ||
} | ||
} | ||
|
||
@Throws(IOException::class) | ||
override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { | ||
builder.startObject() | ||
.field(_ID, id) | ||
.field(_VERSION, version) | ||
.field(_SEQ_NO, seqNo) | ||
.field(_PRIMARY_TERM, primaryTerm) | ||
if (workflow != null) | ||
builder.field("workflow", workflow) | ||
|
||
return builder.endObject() | ||
} | ||
|
||
override fun getStatus(): RestStatus { | ||
return this.status | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we can also add execute workflow
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.
We could - but then we need to extract the ExecuteWorkflowRequest.
Should I add a execute workflow method here or?