Skip to content

Commit d77dec5

Browse files
authored
Rename references for Get Channels API (opensearch-project#140)
Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
1 parent a086805 commit d77dec5

File tree

14 files changed

+234
-234
lines changed

14 files changed

+234
-234
lines changed

src/main/kotlin/org/opensearch/commons/notifications/NotificationConstants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object NotificationConstants {
5252
const val CREATED_TIME_TAG = "created_time_ms"
5353
const val CONFIG_LIST_TAG = "config_list"
5454
const val EVENT_LIST_TAG = "event_list"
55-
const val FEATURE_CONFIG_LIST_TAG = "feature_channel_list"
55+
const val CHANNEL_LIST_TAG = "channel_list"
5656
const val DELETE_RESPONSE_LIST_TAG = "delete_response_list"
5757
const val FROM_INDEX_TAG = "from_index"
5858
const val MAX_ITEMS_TAG = "max_items"

src/main/kotlin/org/opensearch/commons/notifications/NotificationsPluginInterface.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import org.opensearch.commons.notifications.action.CreateNotificationConfigReque
1414
import org.opensearch.commons.notifications.action.CreateNotificationConfigResponse
1515
import org.opensearch.commons.notifications.action.DeleteNotificationConfigRequest
1616
import org.opensearch.commons.notifications.action.DeleteNotificationConfigResponse
17-
import org.opensearch.commons.notifications.action.GetFeatureChannelListRequest
18-
import org.opensearch.commons.notifications.action.GetFeatureChannelListResponse
17+
import org.opensearch.commons.notifications.action.GetChannelListRequest
18+
import org.opensearch.commons.notifications.action.GetChannelListResponse
1919
import org.opensearch.commons.notifications.action.GetNotificationConfigRequest
2020
import org.opensearch.commons.notifications.action.GetNotificationConfigResponse
2121
import org.opensearch.commons.notifications.action.GetNotificationEventRequest
@@ -26,7 +26,7 @@ import org.opensearch.commons.notifications.action.LegacyPublishNotificationRequ
2626
import org.opensearch.commons.notifications.action.LegacyPublishNotificationResponse
2727
import org.opensearch.commons.notifications.action.NotificationsActions.CREATE_NOTIFICATION_CONFIG_ACTION_TYPE
2828
import org.opensearch.commons.notifications.action.NotificationsActions.DELETE_NOTIFICATION_CONFIG_ACTION_TYPE
29-
import org.opensearch.commons.notifications.action.NotificationsActions.GET_FEATURE_CHANNEL_LIST_ACTION_TYPE
29+
import org.opensearch.commons.notifications.action.NotificationsActions.GET_CHANNEL_LIST_ACTION_TYPE
3030
import org.opensearch.commons.notifications.action.NotificationsActions.GET_NOTIFICATION_CONFIG_ACTION_TYPE
3131
import org.opensearch.commons.notifications.action.NotificationsActions.GET_NOTIFICATION_EVENT_ACTION_TYPE
3232
import org.opensearch.commons.notifications.action.NotificationsActions.GET_PLUGIN_FEATURES_ACTION_TYPE
@@ -156,20 +156,20 @@ object NotificationsPluginInterface {
156156
}
157157

158158
/**
159-
* Get notification channel configuration enabled for a feature.
159+
* Get notification channel configuration.
160160
* @param client Node client for making transport action
161161
* @param request The request object
162162
* @param listener The listener for getting response
163163
*/
164-
fun getFeatureChannelList(
164+
fun getChannelList(
165165
client: NodeClient,
166-
request: GetFeatureChannelListRequest,
167-
listener: ActionListener<GetFeatureChannelListResponse>
166+
request: GetChannelListRequest,
167+
listener: ActionListener<GetChannelListResponse>
168168
) {
169169
client.execute(
170-
GET_FEATURE_CHANNEL_LIST_ACTION_TYPE,
170+
GET_CHANNEL_LIST_ACTION_TYPE,
171171
request,
172-
wrapActionListener(listener) { response -> recreateObject(response) { GetFeatureChannelListResponse(it) } }
172+
wrapActionListener(listener) { response -> recreateObject(response) { GetChannelListResponse(it) } }
173173
)
174174
}
175175

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ import java.io.IOException
2121
/**
2222
* This request is plugin-only call. i.e. REST interface is not exposed.
2323
*/
24-
class GetFeatureChannelListRequest : ActionRequest, ToXContentObject {
24+
class GetChannelListRequest : ActionRequest, ToXContentObject {
2525
val compact: Boolean // Dummy request parameter for transport request
2626

2727
companion object {
28-
private val log by logger(GetFeatureChannelListRequest::class.java)
28+
private val log by logger(GetChannelListRequest::class.java)
2929

3030
/**
3131
* reader to create instance of class from writable.
3232
*/
33-
val reader = Writeable.Reader { GetFeatureChannelListRequest(it) }
33+
val reader = Writeable.Reader { GetChannelListRequest(it) }
3434

3535
/**
3636
* Creator used in REST communication.
3737
* @param parser XContentParser to deserialize data from.
3838
*/
3939
@JvmStatic
4040
@Throws(IOException::class)
41-
fun parse(parser: XContentParser): GetFeatureChannelListRequest {
41+
fun parse(parser: XContentParser): GetChannelListRequest {
4242
var compact = false
4343

4444
XContentParserUtils.ensureExpectedToken(
@@ -53,11 +53,11 @@ class GetFeatureChannelListRequest : ActionRequest, ToXContentObject {
5353
COMPACT_TAG -> compact = parser.booleanValue()
5454
else -> {
5555
parser.skipChildren()
56-
log.info("Unexpected field: $fieldName, while parsing GetFeatureChannelListRequest")
56+
log.info("Unexpected field: $fieldName, while parsing GetChannelListRequest")
5757
}
5858
}
5959
}
60-
return GetFeatureChannelListRequest()
60+
return GetChannelListRequest()
6161
}
6262
}
6363

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,38 @@ import org.opensearch.common.io.stream.Writeable
1010
import org.opensearch.common.xcontent.ToXContent
1111
import org.opensearch.common.xcontent.XContentBuilder
1212
import org.opensearch.common.xcontent.XContentParser
13-
import org.opensearch.commons.notifications.model.FeatureChannelList
13+
import org.opensearch.commons.notifications.model.ChannelList
1414
import java.io.IOException
1515

1616
/**
1717
* Action Response for creating new configuration.
1818
*/
19-
class GetFeatureChannelListResponse : BaseResponse {
20-
val searchResult: FeatureChannelList
19+
class GetChannelListResponse : BaseResponse {
20+
val searchResult: ChannelList
2121

2222
companion object {
2323

2424
/**
2525
* reader to create instance of class from writable.
2626
*/
27-
val reader = Writeable.Reader { GetFeatureChannelListResponse(it) }
27+
val reader = Writeable.Reader { GetChannelListResponse(it) }
2828

2929
/**
3030
* Creator used in REST communication.
3131
* @param parser XContentParser to deserialize data from.
3232
*/
3333
@JvmStatic
3434
@Throws(IOException::class)
35-
fun parse(parser: XContentParser): GetFeatureChannelListResponse {
36-
return GetFeatureChannelListResponse(FeatureChannelList(parser))
35+
fun parse(parser: XContentParser): GetChannelListResponse {
36+
return GetChannelListResponse(ChannelList(parser))
3737
}
3838
}
3939

4040
/**
4141
* constructor for creating the class
4242
* @param searchResult the notification configuration list
4343
*/
44-
constructor(searchResult: FeatureChannelList) {
44+
constructor(searchResult: ChannelList) {
4545
this.searchResult = searchResult
4646
}
4747

@@ -50,7 +50,7 @@ class GetFeatureChannelListResponse : BaseResponse {
5050
*/
5151
@Throws(IOException::class)
5252
constructor(input: StreamInput) : super(input) {
53-
searchResult = FeatureChannelList(input)
53+
searchResult = ChannelList(input)
5454
}
5555

5656
/**

src/main/kotlin/org/opensearch/commons/notifications/action/NotificationsActions.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ object NotificationsActions {
4343
/**
4444
* Get Config List for feature. Internal only - Inter plugin communication.
4545
*/
46-
const val GET_FEATURE_CHANNEL_LIST_NAME = "cluster:admin/opensearch/notifications/feature/channels/get"
46+
const val GET_CHANNEL_LIST_NAME = "cluster:admin/opensearch/notifications/channels/get"
4747

4848
/**
4949
* Send notification message. Internal only - Inter plugin communication.
@@ -93,10 +93,10 @@ object NotificationsActions {
9393
ActionType(GET_PLUGIN_FEATURES_NAME, ::GetPluginFeaturesResponse)
9494

9595
/**
96-
* Get Config List for feature transport action type.
96+
* Get notification channel List transport action type.
9797
*/
98-
val GET_FEATURE_CHANNEL_LIST_ACTION_TYPE =
99-
ActionType(GET_FEATURE_CHANNEL_LIST_NAME, ::GetFeatureChannelListResponse)
98+
val GET_CHANNEL_LIST_ACTION_TYPE =
99+
ActionType(GET_CHANNEL_LIST_NAME, ::GetChannelListResponse)
100100

101101
/**
102102
* Send notification transport action type. Internal only - Inter plugin communication.

src/main/kotlin/org/opensearch/commons/notifications/model/FeatureChannel.kt renamed to src/main/kotlin/org/opensearch/commons/notifications/model/Channel.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import org.opensearch.commons.utils.logger
2121
import java.io.IOException
2222

2323
/**
24-
* Data class representing Notification config for exposed for other plugins.
24+
* Data class representing Notification config exposed for other plugins.
2525
*/
26-
data class FeatureChannel(
26+
data class Channel(
2727
val configId: String,
2828
val name: String,
2929
val description: String,
@@ -37,12 +37,12 @@ data class FeatureChannel(
3737
}
3838

3939
companion object {
40-
private val log by logger(FeatureChannel::class.java)
40+
private val log by logger(Channel::class.java)
4141

4242
/**
4343
* reader to create instance of class from writable.
4444
*/
45-
val reader = Writeable.Reader { FeatureChannel(it) }
45+
val reader = Writeable.Reader { Channel(it) }
4646

4747
/**
4848
* Creator used in REST communication.
@@ -51,7 +51,7 @@ data class FeatureChannel(
5151
@Suppress("ComplexMethod")
5252
@JvmStatic
5353
@Throws(IOException::class)
54-
fun parse(parser: XContentParser): FeatureChannel {
54+
fun parse(parser: XContentParser): Channel {
5555
var configId: String? = null
5656
var name: String? = null
5757
var description = ""
@@ -74,14 +74,14 @@ data class FeatureChannel(
7474
IS_ENABLED_TAG -> isEnabled = parser.booleanValue()
7575
else -> {
7676
parser.skipChildren()
77-
log.info("Unexpected field: $fieldName, while parsing FeatureChannel")
77+
log.info("Unexpected field: $fieldName, while parsing Channel")
7878
}
7979
}
8080
}
8181
configId ?: throw IllegalArgumentException("$CONFIG_ID_TAG field absent")
8282
name ?: throw IllegalArgumentException("$NAME_TAG field absent")
8383
configType ?: throw IllegalArgumentException("$CONFIG_TYPE_TAG field absent")
84-
return FeatureChannel(
84+
return Channel(
8585
configId,
8686
name,
8787
description,

src/main/kotlin/org/opensearch/commons/notifications/model/FeatureChannelList.kt renamed to src/main/kotlin/org/opensearch/commons/notifications/model/ChannelList.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@ import org.apache.lucene.search.TotalHits
99
import org.opensearch.action.search.SearchResponse
1010
import org.opensearch.common.io.stream.StreamInput
1111
import org.opensearch.common.xcontent.XContentParser
12-
import org.opensearch.commons.notifications.NotificationConstants.FEATURE_CONFIG_LIST_TAG
12+
import org.opensearch.commons.notifications.NotificationConstants.CHANNEL_LIST_TAG
1313

1414
/**
15-
* FeatureChannel search results
15+
* Channel search results
1616
*/
17-
class FeatureChannelList : SearchResults<FeatureChannel> {
17+
class ChannelList : SearchResults<Channel> {
1818

1919
/**
2020
* single item result constructor
2121
*/
22-
constructor(objectItem: FeatureChannel) : super(FEATURE_CONFIG_LIST_TAG, objectItem)
22+
constructor(objectItem: Channel) : super(CHANNEL_LIST_TAG, objectItem)
2323

2424
/**
2525
* multiple items result constructor
2626
*/
27-
constructor(objectList: List<FeatureChannel>) : this(
27+
constructor(objectList: List<Channel>) : this(
2828
0,
2929
objectList.size.toLong(),
3030
TotalHits.Relation.EQUAL_TO,
@@ -38,34 +38,34 @@ class FeatureChannelList : SearchResults<FeatureChannel> {
3838
startIndex: Long,
3939
totalHits: Long,
4040
totalHitRelation: TotalHits.Relation,
41-
objectList: List<FeatureChannel>
42-
) : super(startIndex, totalHits, totalHitRelation, FEATURE_CONFIG_LIST_TAG, objectList)
41+
objectList: List<Channel>
42+
) : super(startIndex, totalHits, totalHitRelation, CHANNEL_LIST_TAG, objectList)
4343

4444
/**
4545
* Constructor used in transport action communication.
4646
* @param input StreamInput stream to deserialize data from.
4747
*/
48-
constructor(input: StreamInput) : super(input, FeatureChannel.reader)
48+
constructor(input: StreamInput) : super(input, Channel.reader)
4949

5050
/**
5151
* Construct object from XContentParser
5252
*/
53-
constructor(parser: XContentParser) : super(parser, FEATURE_CONFIG_LIST_TAG)
53+
constructor(parser: XContentParser) : super(parser, CHANNEL_LIST_TAG)
5454

5555
/**
5656
* Construct object from SearchResponse
5757
*/
58-
constructor(from: Long, response: SearchResponse, searchHitParser: SearchHitParser<FeatureChannel>) : super(
58+
constructor(from: Long, response: SearchResponse, searchHitParser: SearchHitParser<Channel>) : super(
5959
from,
6060
response,
6161
searchHitParser,
62-
FEATURE_CONFIG_LIST_TAG
62+
CHANNEL_LIST_TAG
6363
)
6464

6565
/**
6666
* {@inheritDoc}
6767
*/
68-
override fun parseItem(parser: XContentParser): FeatureChannel {
69-
return FeatureChannel.parse(parser)
68+
override fun parseItem(parser: XContentParser): Channel {
69+
return Channel.parse(parser)
7070
}
7171
}

src/test/kotlin/org/opensearch/commons/notifications/NotificationsPluginInterfaceTests.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import org.opensearch.commons.notifications.action.CreateNotificationConfigReque
2525
import org.opensearch.commons.notifications.action.CreateNotificationConfigResponse
2626
import org.opensearch.commons.notifications.action.DeleteNotificationConfigRequest
2727
import org.opensearch.commons.notifications.action.DeleteNotificationConfigResponse
28-
import org.opensearch.commons.notifications.action.GetFeatureChannelListRequest
29-
import org.opensearch.commons.notifications.action.GetFeatureChannelListResponse
28+
import org.opensearch.commons.notifications.action.GetChannelListRequest
29+
import org.opensearch.commons.notifications.action.GetChannelListResponse
3030
import org.opensearch.commons.notifications.action.GetNotificationConfigRequest
3131
import org.opensearch.commons.notifications.action.GetNotificationConfigResponse
3232
import org.opensearch.commons.notifications.action.GetNotificationEventRequest
@@ -38,13 +38,13 @@ import org.opensearch.commons.notifications.action.LegacyPublishNotificationResp
3838
import org.opensearch.commons.notifications.action.SendNotificationResponse
3939
import org.opensearch.commons.notifications.action.UpdateNotificationConfigRequest
4040
import org.opensearch.commons.notifications.action.UpdateNotificationConfigResponse
41+
import org.opensearch.commons.notifications.model.Channel
42+
import org.opensearch.commons.notifications.model.ChannelList
4143
import org.opensearch.commons.notifications.model.ChannelMessage
4244
import org.opensearch.commons.notifications.model.ConfigType
4345
import org.opensearch.commons.notifications.model.DeliveryStatus
4446
import org.opensearch.commons.notifications.model.EventSource
4547
import org.opensearch.commons.notifications.model.EventStatus
46-
import org.opensearch.commons.notifications.model.FeatureChannel
47-
import org.opensearch.commons.notifications.model.FeatureChannelList
4848
import org.opensearch.commons.notifications.model.NotificationConfig
4949
import org.opensearch.commons.notifications.model.NotificationConfigInfo
5050
import org.opensearch.commons.notifications.model.NotificationConfigSearchResult
@@ -168,25 +168,25 @@ internal class NotificationsPluginInterfaceTests {
168168
}
169169

170170
@Test
171-
fun getFeatureChannelList() {
172-
val sampleConfig = FeatureChannel(
171+
fun getChannelList() {
172+
val sampleConfig = Channel(
173173
"config_id",
174174
"name",
175175
"description",
176176
ConfigType.SLACK
177177
)
178178

179-
val request = mock(GetFeatureChannelListRequest::class.java)
180-
val response = GetFeatureChannelListResponse(FeatureChannelList(sampleConfig))
181-
val listener: ActionListener<GetFeatureChannelListResponse> =
182-
mock(ActionListener::class.java) as ActionListener<GetFeatureChannelListResponse>
179+
val request = mock(GetChannelListRequest::class.java)
180+
val response = GetChannelListResponse(ChannelList(sampleConfig))
181+
val listener: ActionListener<GetChannelListResponse> =
182+
mock(ActionListener::class.java) as ActionListener<GetChannelListResponse>
183183

184184
doAnswer {
185-
(it.getArgument(2) as ActionListener<GetFeatureChannelListResponse>)
185+
(it.getArgument(2) as ActionListener<GetChannelListResponse>)
186186
.onResponse(response)
187187
}.whenever(client).execute(any(ActionType::class.java), any(), any())
188188

189-
NotificationsPluginInterface.getFeatureChannelList(client, request, listener)
189+
NotificationsPluginInterface.getChannelList(client, request, listener)
190190
verify(listener, times(1)).onResponse(eq(response))
191191
}
192192

0 commit comments

Comments
 (0)