diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/NotificationPlugin.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/NotificationPlugin.kt index 90c9fbf5..cbdca21e 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/NotificationPlugin.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/NotificationPlugin.kt @@ -24,7 +24,7 @@ import org.opensearch.env.Environment import org.opensearch.env.NodeEnvironment import org.opensearch.notifications.action.CreateNotificationConfigAction import org.opensearch.notifications.action.DeleteNotificationConfigAction -import org.opensearch.notifications.action.GetFeatureChannelListAction +import org.opensearch.notifications.action.GetChannelListAction import org.opensearch.notifications.action.GetNotificationConfigAction import org.opensearch.notifications.action.GetNotificationEventAction import org.opensearch.notifications.action.GetPluginFeaturesAction @@ -36,9 +36,9 @@ import org.opensearch.notifications.index.ConfigIndexingActions import org.opensearch.notifications.index.EventIndexingActions import org.opensearch.notifications.index.NotificationConfigIndex import org.opensearch.notifications.index.NotificationEventIndex +import org.opensearch.notifications.resthandler.NotificationChannelListRestHandler import org.opensearch.notifications.resthandler.NotificationConfigRestHandler import org.opensearch.notifications.resthandler.NotificationEventRestHandler -import org.opensearch.notifications.resthandler.NotificationFeatureChannelListRestHandler import org.opensearch.notifications.resthandler.NotificationFeaturesRestHandler import org.opensearch.notifications.resthandler.NotificationStatsRestHandler import org.opensearch.notifications.resthandler.SendTestMessageRestHandler @@ -140,8 +140,8 @@ class NotificationPlugin : ActionPlugin, Plugin(), NotificationCoreExtension { GetNotificationEventAction::class.java ), ActionPlugin.ActionHandler( - NotificationsActions.GET_FEATURE_CHANNEL_LIST_ACTION_TYPE, - GetFeatureChannelListAction::class.java + NotificationsActions.GET_CHANNEL_LIST_ACTION_TYPE, + GetChannelListAction::class.java ), ActionPlugin.ActionHandler( NotificationsActions.GET_PLUGIN_FEATURES_ACTION_TYPE, @@ -175,7 +175,7 @@ class NotificationPlugin : ActionPlugin, Plugin(), NotificationCoreExtension { NotificationConfigRestHandler(), NotificationEventRestHandler(), NotificationFeaturesRestHandler(), - NotificationFeatureChannelListRestHandler(), + NotificationChannelListRestHandler(), SendTestMessageRestHandler(), NotificationStatsRestHandler() ) diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/action/GetFeatureChannelListAction.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/action/GetChannelListAction.kt similarity index 61% rename from notifications/notifications/src/main/kotlin/org/opensearch/notifications/action/GetFeatureChannelListAction.kt rename to notifications/notifications/src/main/kotlin/org/opensearch/notifications/action/GetChannelListAction.kt index f0979711..7476a228 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/action/GetFeatureChannelListAction.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/action/GetChannelListAction.kt @@ -12,8 +12,8 @@ import org.opensearch.client.Client import org.opensearch.common.inject.Inject import org.opensearch.common.xcontent.NamedXContentRegistry import org.opensearch.commons.authuser.User -import org.opensearch.commons.notifications.action.GetFeatureChannelListRequest -import org.opensearch.commons.notifications.action.GetFeatureChannelListResponse +import org.opensearch.commons.notifications.action.GetChannelListRequest +import org.opensearch.commons.notifications.action.GetChannelListResponse import org.opensearch.commons.notifications.action.NotificationsActions import org.opensearch.commons.utils.recreateObject import org.opensearch.notifications.index.ConfigIndexingActions @@ -21,19 +21,19 @@ import org.opensearch.tasks.Task import org.opensearch.transport.TransportService /** - * Get feature channel list transport action + * Get channel list transport action */ -internal class GetFeatureChannelListAction @Inject constructor( +internal class GetChannelListAction @Inject constructor( transportService: TransportService, client: Client, actionFilters: ActionFilters, val xContentRegistry: NamedXContentRegistry -) : PluginBaseAction( - NotificationsActions.GET_FEATURE_CHANNEL_LIST_NAME, +) : PluginBaseAction( + NotificationsActions.GET_CHANNEL_LIST_NAME, transportService, client, actionFilters, - ::GetFeatureChannelListRequest + ::GetChannelListRequest ) { /** @@ -43,10 +43,10 @@ internal class GetFeatureChannelListAction @Inject constructor( override fun doExecute( task: Task?, request: ActionRequest, - listener: ActionListener + listener: ActionListener ) { - val transformedRequest = request as? GetFeatureChannelListRequest - ?: recreateObject(request) { GetFeatureChannelListRequest(it) } + val transformedRequest = request as? GetChannelListRequest + ?: recreateObject(request) { GetChannelListRequest(it) } super.doExecute(task, transformedRequest, listener) } @@ -54,9 +54,9 @@ internal class GetFeatureChannelListAction @Inject constructor( * {@inheritDoc} */ override fun executeRequest( - request: GetFeatureChannelListRequest, + request: GetChannelListRequest, user: User? - ): GetFeatureChannelListResponse { - return ConfigIndexingActions.getFeatureChannelList(request, user) + ): GetChannelListResponse { + return ConfigIndexingActions.getChannelList(request, user) } } diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/index/ConfigIndexingActions.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/index/ConfigIndexingActions.kt index 9a678321..158aea17 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/index/ConfigIndexingActions.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/index/ConfigIndexingActions.kt @@ -11,18 +11,18 @@ import org.opensearch.commons.notifications.action.CreateNotificationConfigReque import org.opensearch.commons.notifications.action.CreateNotificationConfigResponse import org.opensearch.commons.notifications.action.DeleteNotificationConfigRequest import org.opensearch.commons.notifications.action.DeleteNotificationConfigResponse -import org.opensearch.commons.notifications.action.GetFeatureChannelListRequest -import org.opensearch.commons.notifications.action.GetFeatureChannelListResponse +import org.opensearch.commons.notifications.action.GetChannelListRequest +import org.opensearch.commons.notifications.action.GetChannelListResponse import org.opensearch.commons.notifications.action.GetNotificationConfigRequest import org.opensearch.commons.notifications.action.GetNotificationConfigResponse import org.opensearch.commons.notifications.action.UpdateNotificationConfigRequest import org.opensearch.commons.notifications.action.UpdateNotificationConfigResponse +import org.opensearch.commons.notifications.model.Channel +import org.opensearch.commons.notifications.model.ChannelList import org.opensearch.commons.notifications.model.Chime import org.opensearch.commons.notifications.model.ConfigType import org.opensearch.commons.notifications.model.Email import org.opensearch.commons.notifications.model.EmailGroup -import org.opensearch.commons.notifications.model.FeatureChannel -import org.opensearch.commons.notifications.model.FeatureChannelList import org.opensearch.commons.notifications.model.NotificationConfig import org.opensearch.commons.notifications.model.NotificationConfigInfo import org.opensearch.commons.notifications.model.NotificationConfigSearchResult @@ -340,12 +340,12 @@ object ConfigIndexingActions { /** * Get NotificationConfig info - * @param request [GetFeatureChannelListRequest] object + * @param request [GetChannelListRequest] object * @param user the user info object - * @return [GetFeatureChannelListResponse] + * @return [GetChannelListResponse] */ - fun getFeatureChannelList(request: GetFeatureChannelListRequest, user: User?): GetFeatureChannelListResponse { - log.info("$LOG_PREFIX:getFeatureChannelList $request") + fun getChannelList(request: GetChannelListRequest, user: User?): GetChannelListResponse { + log.info("$LOG_PREFIX:getChannelList $request") userAccess.validateUser(user) val supportedChannelListString = getSupportedChannelList().joinToString(",") val filterParams = mapOf( @@ -359,10 +359,10 @@ object ConfigIndexingActions { val searchResult = getAllResult.objectList.map { val configId = it.configId val config = it.notificationConfig - FeatureChannel(configId, config.name, config.description, config.configType, config.isEnabled) + Channel(configId, config.name, config.description, config.configType, config.isEnabled) } - val featureChannelList = FeatureChannelList(searchResult) - return GetFeatureChannelListResponse(featureChannelList) + val ChannelList = ChannelList(searchResult) + return GetChannelListResponse(ChannelList) } private fun getSupportedChannelList(): List { diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/metrics/Metrics.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/metrics/Metrics.kt index 22ea0e59..146e71a0 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/metrics/Metrics.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/metrics/Metrics.kt @@ -152,19 +152,16 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { "notifications_events.info.system_error", RollingCounter() ), // Feature Channels Endpoints - // GET _plugins/_notifications/feature/channels/{featureTag} - NOTIFICATIONS_FEATURE_CHANNELS_INFO_TOTAL( - "notifications_feature_channels.info.total", + // GET _plugins/_notifications/channels + NOTIFICATIONS_CHANNELS_INFO_TOTAL( + "notifications_channels.info.total", BasicCounter() ), - NOTIFICATIONS_FEATURE_CHANNELS_INFO_INTERVAL_COUNT( - "notifications_feature_channels.info.count", RollingCounter() + NOTIFICATIONS_CHANNELS_INFO_INTERVAL_COUNT( + "notifications_channels.info.count", RollingCounter() ), - NOTIFICATIONS_FEATURE_CHANNELS_INFO_USER_ERROR_INVALID_FEATURE_TAG( - "notifications_feature_channels.info.user_error.invalid_feature_tag", RollingCounter() - ), - NOTIFICATIONS_FEATURE_CHANNELS_INFO_SYSTEM_ERROR( - "notifications_feature_channels.info.system_error", RollingCounter() + NOTIFICATIONS_CHANNELS_INFO_SYSTEM_ERROR( + "notifications_channels.info.system_error", RollingCounter() ), // Features Endpoints // GET _plugins/_notifications/features @@ -193,9 +190,6 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { NOTIFICATIONS_SEND_MESSAGE_USER_ERROR_NOT_FOUND( "notifications.send_message.user_error.not_found", RollingCounter() ), - NOTIFICATIONS_SEND_MESSAGE_USER_ERROR_FEATURE_NOT_FOUND( - "notifications.send_message.user_error.feature_not_found", RollingCounter() - ), NOTIFICATIONS_SEND_MESSAGE_SYSTEM_ERROR( "notifications.send_message.system_error", RollingCounter() diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/resthandler/NotificationFeatureChannelListRestHandler.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/resthandler/NotificationChannelListRestHandler.kt similarity index 73% rename from notifications/notifications/src/main/kotlin/org/opensearch/notifications/resthandler/NotificationFeatureChannelListRestHandler.kt rename to notifications/notifications/src/main/kotlin/org/opensearch/notifications/resthandler/NotificationChannelListRestHandler.kt index d835314e..0495bff1 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/resthandler/NotificationFeatureChannelListRestHandler.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/resthandler/NotificationChannelListRestHandler.kt @@ -7,7 +7,7 @@ package org.opensearch.notifications.resthandler import org.opensearch.client.node.NodeClient import org.opensearch.commons.notifications.NotificationsPluginInterface -import org.opensearch.commons.notifications.action.GetFeatureChannelListRequest +import org.opensearch.commons.notifications.action.GetChannelListRequest import org.opensearch.notifications.NotificationPlugin.Companion.PLUGIN_BASE_URI import org.opensearch.notifications.metrics.Metrics import org.opensearch.rest.BaseRestHandler.RestChannelConsumer @@ -21,19 +21,19 @@ import org.opensearch.rest.action.RestToXContentListener /** * Rest handler for getting notification channels. */ -internal class NotificationFeatureChannelListRestHandler : PluginBaseHandler() { +internal class NotificationChannelListRestHandler : PluginBaseHandler() { companion object { /** * Base URL for this handler */ - private const val REQUEST_URL = "$PLUGIN_BASE_URI/feature/channels" + private const val REQUEST_URL = "$PLUGIN_BASE_URI/channels" } /** * {@inheritDoc} */ override fun getName(): String { - return "notifications_feature_channel_list" + return "notifications_channel_list" } /** @@ -42,10 +42,10 @@ internal class NotificationFeatureChannelListRestHandler : PluginBaseHandler() { override fun routes(): List { return listOf( /** - * Get a notification event + * Get notification channels * Request URL: GET [REQUEST_URL] - * Request body: Ref [org.opensearch.commons.notifications.action.GetFeatureChannelListRequest] - * Response body: [org.opensearch.commons.notifications.action.GetFeatureChannelListResponse] + * Request body: Ref [org.opensearch.commons.notifications.action.GetChannelListRequest] + * Response body: [org.opensearch.commons.notifications.action.GetChannelListResponse] */ Route(GET, REQUEST_URL) ) @@ -64,12 +64,12 @@ internal class NotificationFeatureChannelListRestHandler : PluginBaseHandler() { override fun executeRequest(request: RestRequest, client: NodeClient): RestChannelConsumer { return when (request.method()) { GET -> { - Metrics.NOTIFICATIONS_FEATURE_CHANNELS_INFO_TOTAL.counter.increment() - Metrics.NOTIFICATIONS_FEATURE_CHANNELS_INFO_INTERVAL_COUNT.counter.increment() + Metrics.NOTIFICATIONS_CHANNELS_INFO_TOTAL.counter.increment() + Metrics.NOTIFICATIONS_CHANNELS_INFO_INTERVAL_COUNT.counter.increment() RestChannelConsumer { - NotificationsPluginInterface.getFeatureChannelList( + NotificationsPluginInterface.getChannelList( client, - GetFeatureChannelListRequest(), + GetChannelListRequest(), RestToXContentListener(it) ) } diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/send/SendMessageActionHelper.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/send/SendMessageActionHelper.kt index c9fc0d43..acb65566 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/send/SendMessageActionHelper.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/send/SendMessageActionHelper.kt @@ -284,8 +284,8 @@ object SendMessageActionHelper { */ private fun sendMessageToLegacyDestination(baseMessage: LegacyBaseMessage): LegacyDestinationResponse { val message = - MessageContent(title = "Index Management Notification", textDescription = baseMessage.messageContent) - // These legacy destination calls do not have reference Ids, just passing index management feature constant + MessageContent(title = "Legacy Notification", textDescription = baseMessage.messageContent) + // These legacy destination calls do not have reference Ids, just passing 'legacy' constant return when (baseMessage.channelType) { LegacyDestinationType.LEGACY_SLACK -> { val destination = SlackDestination(baseMessage.url) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/features/GetNotificationFeatureChannelListIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/features/GetNotificationChannelListIT.kt similarity index 91% rename from notifications/notifications/src/test/kotlin/org/opensearch/integtest/features/GetNotificationFeatureChannelListIT.kt rename to notifications/notifications/src/test/kotlin/org/opensearch/integtest/features/GetNotificationChannelListIT.kt index 5a768cfc..fd4e80dd 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/features/GetNotificationFeatureChannelListIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/features/GetNotificationChannelListIT.kt @@ -14,7 +14,7 @@ import org.opensearch.rest.RestRequest import org.opensearch.rest.RestStatus import kotlin.random.Random -class GetNotificationFeatureChannelListIT : PluginRestTestCase() { +class GetNotificationChannelListIT : PluginRestTestCase() { private val charPool: List = ('a'..'z') + ('A'..'Z') + ('0'..'9') private fun getCreateRequestJsonString( @@ -107,7 +107,7 @@ class GetNotificationFeatureChannelListIT : PluginRestTestCase() { if (totalHits >= 0) { Assert.assertEquals(totalHits, jsonObject.get("total_hits").asInt) } - val items = jsonObject.get("feature_channel_list").asJsonArray + val items = jsonObject.get("channel_list").asJsonArray Assert.assertEquals(idSet.size, items.size()) items.forEach { val item = it.asJsonObject @@ -117,25 +117,25 @@ class GetNotificationFeatureChannelListIT : PluginRestTestCase() { } } - fun `test POST feature channel list should result in error`() { + fun `test POST channel list should result in error`() { executeRequest( RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/feature/channels", + "$PLUGIN_BASE_URI/channels", "{\"feature\":\"reports\"}", RestStatus.METHOD_NOT_ALLOWED.status ) } - fun `test PUT feature channel list should result in error`() { + fun `test PUT channel list should result in error`() { executeRequest( RestRequest.Method.PUT.name, - "$PLUGIN_BASE_URI/feature/channels", + "$PLUGIN_BASE_URI/channels", "{\"feature\":\"reports\"}", RestStatus.METHOD_NOT_ALLOWED.status ) } - fun `test getFeatureChannelList should return only channels`() { + fun `test getChannelList should return only channels`() { val slackId = createConfig(configType = ConfigType.SLACK) val chimeId = createConfig(configType = ConfigType.CHIME) val webhookId = createConfig(configType = ConfigType.WEBHOOK) @@ -151,7 +151,7 @@ class GetNotificationFeatureChannelListIT : PluginRestTestCase() { val channelIds = setOf(slackId, chimeId, webhookId, emailId) val response = executeRequest( RestRequest.Method.GET.name, - "$PLUGIN_BASE_URI/feature/channels", + "$PLUGIN_BASE_URI/channels", "", RestStatus.OK.status ) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/notifications/action/PluginActionTests.kt b/notifications/notifications/src/test/kotlin/org/opensearch/notifications/action/PluginActionTests.kt index 8f87c63b..d2f4f036 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/notifications/action/PluginActionTests.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/notifications/action/PluginActionTests.kt @@ -23,8 +23,8 @@ import org.opensearch.commons.notifications.action.CreateNotificationConfigReque import org.opensearch.commons.notifications.action.CreateNotificationConfigResponse import org.opensearch.commons.notifications.action.DeleteNotificationConfigRequest import org.opensearch.commons.notifications.action.DeleteNotificationConfigResponse -import org.opensearch.commons.notifications.action.GetFeatureChannelListRequest -import org.opensearch.commons.notifications.action.GetFeatureChannelListResponse +import org.opensearch.commons.notifications.action.GetChannelListRequest +import org.opensearch.commons.notifications.action.GetChannelListResponse import org.opensearch.commons.notifications.action.GetNotificationConfigRequest import org.opensearch.commons.notifications.action.GetNotificationConfigResponse import org.opensearch.commons.notifications.action.GetNotificationEventRequest @@ -37,7 +37,7 @@ import org.opensearch.commons.notifications.action.SendNotificationRequest import org.opensearch.commons.notifications.action.SendNotificationResponse import org.opensearch.commons.notifications.action.UpdateNotificationConfigRequest import org.opensearch.commons.notifications.action.UpdateNotificationConfigResponse -import org.opensearch.commons.notifications.model.FeatureChannelList +import org.opensearch.commons.notifications.model.ChannelList import org.opensearch.commons.notifications.model.NotificationConfigSearchResult import org.opensearch.commons.notifications.model.NotificationEventSearchResult import org.opensearch.notifications.index.ConfigIndexingActions @@ -163,18 +163,18 @@ internal class PluginActionTests { } @Test - fun `Get feature channel list action should call back action listener`() { - val request = mock(GetFeatureChannelListRequest::class.java) - val response = GetFeatureChannelListResponse(mock(FeatureChannelList::class.java)) + fun `Get channel list action should call back action listener`() { + val request = mock(GetChannelListRequest::class.java) + val response = GetChannelListResponse(mock(ChannelList::class.java)) // Mock singleton's method by mockk framework mockkObject(ConfigIndexingActions) - every { ConfigIndexingActions.getFeatureChannelList(request, any()) } returns response + every { ConfigIndexingActions.getChannelList(request, any()) } returns response - val getFeatureChannelListAction = GetFeatureChannelListAction( + val getChannelListAction = GetChannelListAction( transportService, client, actionFilters, xContentRegistry ) - getFeatureChannelListAction.execute(task, request, AssertionListener(response)) + getChannelListAction.execute(task, request, AssertionListener(response)) } @Test