Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -7,13 +7,15 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.action.support.WriteRequest
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import java.io.IOException
import java.util.Collections

class AcknowledgeAlertRequest : ActionRequest {
class AcknowledgeAlertRequest : ActionRequest, DocRequest {
val monitorId: String
val alertIds: List<String>
val refreshPolicy: WriteRequest.RefreshPolicy
Expand Down Expand Up @@ -45,4 +47,12 @@ class AcknowledgeAlertRequest : ActionRequest {
out.writeStringCollection(alertIds)
refreshPolicy.writeTo(out)
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
return monitorId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import java.io.IOException
import java.util.Collections

/** Request DTO for acknowledging chained alerts generated by workflow.*/
class AcknowledgeChainedAlertRequest : ActionRequest {
class AcknowledgeChainedAlertRequest : ActionRequest, DocRequest {
val workflowId: String
val alertIds: List<String>

Expand All @@ -40,4 +42,12 @@ class AcknowledgeChainedAlertRequest : ActionRequest {
out.writeString(workflowId)
out.writeStringCollection(alertIds)
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
return workflowId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.commons.alerting.util.AlertingConstants.Companion.ALL_COMMENTS_INDEX_PATTERN
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import java.io.IOException

class DeleteCommentRequest : ActionRequest {
class DeleteCommentRequest : ActionRequest, DocRequest {
val commentId: String

constructor(commentId: String) : super() {
Expand All @@ -31,4 +33,12 @@ class DeleteCommentRequest : ActionRequest {
override fun writeTo(out: StreamOutput) {
out.writeString(commentId)
}

override fun index(): String? {
return ALL_COMMENTS_INDEX_PATTERN
}

override fun id(): String? {
return commentId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.action.support.WriteRequest
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import java.io.IOException

class DeleteMonitorRequest : ActionRequest {
class DeleteMonitorRequest : DocRequest, ActionRequest {

val monitorId: String
val refreshPolicy: WriteRequest.RefreshPolicy
Expand All @@ -32,4 +34,12 @@ class DeleteMonitorRequest : ActionRequest {
out.writeString(monitorId)
refreshPolicy.writeTo(out)
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
return monitorId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import java.io.IOException

class DeleteWorkflowRequest : ActionRequest {
class DeleteWorkflowRequest : ActionRequest, DocRequest {

val workflowId: String

Expand Down Expand Up @@ -36,4 +38,12 @@ class DeleteWorkflowRequest : ActionRequest {
out.writeString(workflowId)
out.writeOptionalBoolean(deleteDelegateMonitors)
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
return workflowId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.commons.alerting.model.IndexExecutionContext
import org.opensearch.commons.alerting.model.Monitor
import org.opensearch.commons.alerting.model.MonitorMetadata
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.commons.alerting.model.WorkflowRunContext
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
Expand All @@ -19,7 +21,7 @@ import org.opensearch.core.xcontent.ToXContentObject
import org.opensearch.core.xcontent.XContentBuilder
import java.io.IOException

class DocLevelMonitorFanOutRequest : ActionRequest, ToXContentObject {
class DocLevelMonitorFanOutRequest : ActionRequest, DocRequest, ToXContentObject {
val monitor: Monitor
val dryRun: Boolean
val monitorMetadata: MonitorMetadata
Expand Down Expand Up @@ -98,4 +100,12 @@ class DocLevelMonitorFanOutRequest : ActionRequest, ToXContentObject {
.field("workflow_run_context", workflowRunContext)
return builder.endObject()
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
return monitor.id
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.commons.alerting.model.Table
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import org.opensearch.index.query.BoolQueryBuilder
import java.io.IOException

class GetAlertsRequest : ActionRequest {
class GetAlertsRequest : ActionRequest, DocRequest {
val table: Table
val severityLevel: String
val alertState: String
Expand Down Expand Up @@ -75,4 +77,14 @@ class GetAlertsRequest : ActionRequest {
out.writeOptionalBoolean(false)
}
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
// Access is gated on the underlying monitor when a single monitorId is provided; otherwise let the security
// plugin fall back to search-level DLS filtering.
return monitorId ?: monitorIds?.singleOrNull()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.commons.alerting.model.Table
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import org.opensearch.index.query.BoolQueryBuilder
import java.io.IOException

class GetFindingsRequest : ActionRequest {
class GetFindingsRequest : ActionRequest, DocRequest {
val findingId: String?
val table: Table
val monitorId: String?
Expand Down Expand Up @@ -54,4 +56,14 @@ class GetFindingsRequest : ActionRequest {
out.writeOptionalStringCollection(monitorIds)
boolQueryBuilder?.writeTo(out)
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
// Access is gated on the underlying monitor when a single monitorId is provided; otherwise fall back to
// search-level DLS filtering.
return monitorId ?: monitorIds?.singleOrNull()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import org.opensearch.rest.RestRequest
import org.opensearch.search.fetch.subphase.FetchSourceContext
import java.io.IOException

class GetMonitorRequest : ActionRequest {
class GetMonitorRequest : ActionRequest, DocRequest {
val monitorId: String
val version: Long
val method: RestRequest.Method
Expand Down Expand Up @@ -55,4 +57,12 @@ class GetMonitorRequest : ActionRequest {
out.writeBoolean(srcContext != null)
srcContext?.writeTo(out)
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
return monitorId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.commons.alerting.model.Table
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import java.io.IOException

class GetWorkflowAlertsRequest : ActionRequest {
class GetWorkflowAlertsRequest : ActionRequest, DocRequest {
val table: Table
val severityLevel: String
val alertState: String
Expand Down Expand Up @@ -69,4 +71,13 @@ class GetWorkflowAlertsRequest : ActionRequest {
out.writeOptionalStringCollection(alertIds)
out.writeBoolean(getAssociatedAlerts)
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
// Access is gated on the workflow when a single workflowId is provided; otherwise fall back to search-level DLS.
return workflowIds?.singleOrNull()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import org.opensearch.rest.RestRequest
import java.io.IOException

class GetWorkflowRequest : ActionRequest {
class GetWorkflowRequest : ActionRequest, DocRequest {
val workflowId: String
val method: RestRequest.Method

Expand All @@ -39,4 +41,12 @@ class GetWorkflowRequest : ActionRequest {
out.writeString(workflowId)
out.writeEnum(method)
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
return workflowId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.commons.alerting.util.AlertingConstants.Companion.ALL_COMMENTS_INDEX_PATTERN
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import org.opensearch.rest.RestRequest
Expand All @@ -16,7 +18,7 @@ import java.io.IOException
* commentId: the ID of an existing Comment. This field is expected to be non-blank if the request is to
* update an existing Comment.
*/
class IndexCommentRequest : ActionRequest {
class IndexCommentRequest : ActionRequest, DocRequest {
val entityId: String
val entityType: String
val commentId: String
Expand Down Expand Up @@ -75,4 +77,13 @@ class IndexCommentRequest : ActionRequest {
out.writeEnum(method)
out.writeString(content)
}

override fun index(): String? {
return ALL_COMMENTS_INDEX_PATTERN
}

override fun id(): String? {
// For updates, the target is the existing comment; for creates, no comment id exists yet.
return commentId.ifBlank { null }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ package org.opensearch.commons.alerting.action

import org.opensearch.action.ActionRequest
import org.opensearch.action.ActionRequestValidationException
import org.opensearch.action.DocRequest
import org.opensearch.action.support.WriteRequest
import org.opensearch.commons.alerting.model.DocLevelMonitorInput
import org.opensearch.commons.alerting.model.Monitor
import org.opensearch.commons.alerting.model.ScheduledJob
import org.opensearch.commons.alerting.util.IndexPatternUtils
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import org.opensearch.rest.RestRequest
import java.io.IOException
import java.util.Locale

class IndexMonitorRequest : ActionRequest {
class IndexMonitorRequest : ActionRequest, DocRequest {
val monitorId: String
val seqNo: Long
val primaryTerm: Long
Expand Down Expand Up @@ -82,4 +84,12 @@ class IndexMonitorRequest : ActionRequest {
monitor.writeTo(out)
out.writeOptionalStringCollection(rbacRoles)
}

override fun index(): String? {
return ScheduledJob.SCHEDULED_JOBS_INDEX
}

override fun id(): String? {
return monitor.id
}
}
Loading
Loading