Skip to content

Commit

Permalink
Add logs and try to add routes
Browse files Browse the repository at this point in the history
Signed-off-by: Annie Lee <[email protected]>
  • Loading branch information
Annie Lee committed Mar 12, 2022
1 parent 64faf12 commit 6f1d9b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
package org.opensearch.alerting.resthandler

import org.apache.logging.log4j.LogManager
import org.opensearch.alerting.AlertingPlugin
import org.opensearch.alerting.action.GetFindingsSearchAction
import org.opensearch.alerting.action.GetFindingsSearchRequest
import org.opensearch.alerting.model.Table
import org.opensearch.alerting.util.context
import org.opensearch.client.node.NodeClient
import org.opensearch.rest.BaseRestHandler
import org.opensearch.rest.BaseRestHandler.RestChannelConsumer
import org.opensearch.rest.RestHandler
import org.opensearch.rest.RestHandler.Route
import org.opensearch.rest.RestRequest
import org.opensearch.rest.RestRequest.Method.GET
import org.opensearch.rest.RestRequest.Method.POST
import org.opensearch.rest.action.RestActions
import org.opensearch.rest.action.RestToXContentListener
import org.opensearch.search.fetch.subphase.FetchSourceContext
Expand All @@ -31,7 +35,10 @@ class RestGetFindingsSearchAction : BaseRestHandler() {
}

override fun routes(): List<Route> {
return listOf()
return listOf(
Route(POST, "${AlertingPlugin.FINDING_BASE_URI}/_search"),
Route(GET, "${AlertingPlugin.MONITOR_BASE_URI}/_search")
)
}

override fun prepareRequest(request: RestRequest, client: NodeClient): RestChannelConsumer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class TransportGetFindingsSearchAction @Inject constructor(
actionListener: ActionListener<GetFindingsSearchResponse>,
user: User?
) {
log.info("Entering RestGetFindingsSearchAction.kt.")
if (user == null) {
// user is null when: 1/ security is disabled. 2/when user is super-admin.
search(searchSourceBuilder, actionListener)
Expand All @@ -131,6 +132,7 @@ class TransportGetFindingsSearchAction @Inject constructor(
}

fun search(searchSourceBuilder: SearchSourceBuilder, actionListener: ActionListener<GetFindingsSearchResponse>) {
log.info("Entering RestGetFindingsSearchAction.kt.")
val searchRequest = SearchRequest()
.source(searchSourceBuilder)
.indices(".opensearch-alerting-findings")
Expand Down

0 comments on commit 6f1d9b7

Please sign in to comment.