Skip to content

Commit

Permalink
Removed tenant information from the models (#73)
Browse files Browse the repository at this point in the history
* Removed tenant information from the models

[Tests]
Updated unit tests

Signed-off-by: @akbhatta

* Updated OpenSearch branch to 1.1

Signed-off-by: @akbhatta
  • Loading branch information
akbhatta authored Sep 17, 2021
1 parent 3913d70 commit 8fccbea
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 198 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
repository: 'opensearch-project/OpenSearch'
path: OpenSearch
ref: '1.x'
ref: '1.1'
- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ object NotificationConstants {
const val FROM_ADDRESS_TAG = "from_address"
const val UPDATED_TIME_TAG = "last_updated_time_ms"
const val CREATED_TIME_TAG = "created_time_ms"
const val TENANT_TAG = "tenant"
const val CONFIG_LIST_TAG = "config_list"
const val EVENT_LIST_TAG = "event_list"
const val FEATURE_CONFIG_LIST_TAG = "feature_channel_list"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ import java.io.IOException

/**
* This request is plugin-only call. i.e. REST interface is not exposed.
* Also the library will remove the user context while making this call
* so that user making this call need not have to set permission to this API.
* Hence the request also contains tenant info for space isolation.
*/
class GetFeatureChannelListRequest : ActionRequest, ToXContentObject {
val feature: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import org.opensearch.common.xcontent.XContentParserUtils
import org.opensearch.commons.notifications.NotificationConstants.CONFIG_ID_TAG
import org.opensearch.commons.notifications.NotificationConstants.CONFIG_TAG
import org.opensearch.commons.notifications.NotificationConstants.CREATED_TIME_TAG
import org.opensearch.commons.notifications.NotificationConstants.TENANT_TAG
import org.opensearch.commons.notifications.NotificationConstants.UPDATED_TIME_TAG
import org.opensearch.commons.utils.logger
import java.io.IOException
Expand All @@ -50,7 +49,6 @@ data class NotificationConfigInfo(
val configId: String,
val lastUpdatedTime: Instant,
val createdTime: Instant,
val tenant: String,
val notificationConfig: NotificationConfig
) : BaseModel {

Expand All @@ -76,7 +74,6 @@ data class NotificationConfigInfo(
var configId: String? = null
var lastUpdatedTime: Instant? = null
var createdTime: Instant? = null
var tenant: String? = null
var notificationConfig: NotificationConfig? = null

XContentParserUtils.ensureExpectedToken(
Expand All @@ -91,7 +88,6 @@ data class NotificationConfigInfo(
CONFIG_ID_TAG -> configId = parser.text()
UPDATED_TIME_TAG -> lastUpdatedTime = Instant.ofEpochMilli(parser.longValue())
CREATED_TIME_TAG -> createdTime = Instant.ofEpochMilli(parser.longValue())
TENANT_TAG -> tenant = parser.text()
CONFIG_TAG -> notificationConfig = NotificationConfig.parse(parser)
else -> {
parser.skipChildren()
Expand All @@ -102,13 +98,11 @@ data class NotificationConfigInfo(
configId ?: throw IllegalArgumentException("$CONFIG_ID_TAG field absent")
lastUpdatedTime ?: throw IllegalArgumentException("$UPDATED_TIME_TAG field absent")
createdTime ?: throw IllegalArgumentException("$CREATED_TIME_TAG field absent")
tenant = tenant ?: ""
notificationConfig ?: throw IllegalArgumentException("$CONFIG_TAG field absent")
return NotificationConfigInfo(
configId,
lastUpdatedTime,
createdTime,
tenant,
notificationConfig
)
}
Expand All @@ -122,7 +116,6 @@ data class NotificationConfigInfo(
configId = input.readString(),
lastUpdatedTime = input.readInstant(),
createdTime = input.readInstant(),
tenant = input.readString(),
notificationConfig = NotificationConfig.reader.read(input)
)

Expand All @@ -133,7 +126,6 @@ data class NotificationConfigInfo(
output.writeString(configId)
output.writeInstant(lastUpdatedTime)
output.writeInstant(createdTime)
output.writeString(tenant)
notificationConfig.writeTo(output)
}

Expand All @@ -146,7 +138,6 @@ data class NotificationConfigInfo(
.field(CONFIG_ID_TAG, configId)
.field(UPDATED_TIME_TAG, lastUpdatedTime.toEpochMilli())
.field(CREATED_TIME_TAG, createdTime.toEpochMilli())
.field(TENANT_TAG, tenant)
.field(CONFIG_TAG, notificationConfig)
.endObject()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import org.opensearch.common.xcontent.XContentParserUtils
import org.opensearch.commons.notifications.NotificationConstants.CREATED_TIME_TAG
import org.opensearch.commons.notifications.NotificationConstants.EVENT_ID_TAG
import org.opensearch.commons.notifications.NotificationConstants.EVENT_TAG
import org.opensearch.commons.notifications.NotificationConstants.TENANT_TAG
import org.opensearch.commons.notifications.NotificationConstants.UPDATED_TIME_TAG
import org.opensearch.commons.utils.logger
import java.io.IOException
Expand All @@ -50,7 +49,6 @@ data class NotificationEventInfo(
val eventId: String,
val lastUpdatedTime: Instant,
val createdTime: Instant,
val tenant: String,
val notificationEvent: NotificationEvent
) : BaseModel {

Expand All @@ -76,7 +74,6 @@ data class NotificationEventInfo(
var eventId: String? = null
var lastUpdatedTime: Instant? = null
var createdTime: Instant? = null
var tenant: String? = null
var notificationEvent: NotificationEvent? = null

XContentParserUtils.ensureExpectedToken(
Expand All @@ -91,7 +88,6 @@ data class NotificationEventInfo(
EVENT_ID_TAG -> eventId = parser.text()
UPDATED_TIME_TAG -> lastUpdatedTime = Instant.ofEpochMilli(parser.longValue())
CREATED_TIME_TAG -> createdTime = Instant.ofEpochMilli(parser.longValue())
TENANT_TAG -> tenant = parser.text()
EVENT_TAG -> notificationEvent = NotificationEvent.parse(parser)
else -> {
parser.skipChildren()
Expand All @@ -102,13 +98,11 @@ data class NotificationEventInfo(
eventId ?: throw IllegalArgumentException("$EVENT_ID_TAG field absent")
lastUpdatedTime ?: throw IllegalArgumentException("$UPDATED_TIME_TAG field absent")
createdTime ?: throw IllegalArgumentException("$CREATED_TIME_TAG field absent")
tenant = tenant ?: ""
notificationEvent ?: throw IllegalArgumentException("$EVENT_TAG field absent")
return NotificationEventInfo(
eventId,
lastUpdatedTime,
createdTime,
tenant,
notificationEvent
)
}
Expand All @@ -123,7 +117,6 @@ data class NotificationEventInfo(
.field(EVENT_ID_TAG, eventId)
.field(UPDATED_TIME_TAG, lastUpdatedTime.toEpochMilli())
.field(CREATED_TIME_TAG, createdTime.toEpochMilli())
.field(TENANT_TAG, tenant)
.field(EVENT_TAG, notificationEvent)
.endObject()
}
Expand All @@ -136,7 +129,6 @@ data class NotificationEventInfo(
eventId = input.readString(),
lastUpdatedTime = input.readInstant(),
createdTime = input.readInstant(),
tenant = input.readString(),
notificationEvent = NotificationEvent.reader.read(input)
)

Expand All @@ -147,7 +139,6 @@ data class NotificationEventInfo(
output.writeString(eventId)
output.writeInstant(lastUpdatedTime)
output.writeInstant(createdTime)
output.writeString(tenant)
notificationEvent.writeTo(output)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ internal class NotificationsPluginInterfaceTests {
"config_id",
Instant.now(),
Instant.now(),
"tenant",
sampleConfig
)
return GetNotificationConfigResponse(NotificationConfigSearchResult(configInfo))
Expand All @@ -284,7 +283,6 @@ internal class NotificationsPluginInterfaceTests {
"event_id",
Instant.now(),
Instant.now(),
"tenant",
sampleEvent
)
return GetNotificationEventResponse(NotificationEventSearchResult(eventInfo))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ internal class GetNotificationConfigResponseTests {
"config_id",
Instant.now(),
Instant.now(),
"tenant",
sampleConfig
)
val searchResult = NotificationConfigSearchResult(configInfo)
Expand All @@ -92,7 +91,6 @@ internal class GetNotificationConfigResponseTests {
"config_id1",
Instant.now(),
Instant.now(),
"tenant",
sampleConfig1
)
val sampleConfig2 = NotificationConfig(
Expand All @@ -106,7 +104,6 @@ internal class GetNotificationConfigResponseTests {
"config_id2",
Instant.now(),
Instant.now(),
"tenant",
sampleConfig2
)
val searchResult = NotificationConfigSearchResult(
Expand Down Expand Up @@ -136,7 +133,6 @@ internal class GetNotificationConfigResponseTests {
"config_id",
lastUpdatedTimeMs,
createdTimeMs,
"tenant",
sampleConfig
)
val searchResult = NotificationConfigSearchResult(configInfo)
Expand All @@ -161,7 +157,6 @@ internal class GetNotificationConfigResponseTests {
"config_id1",
lastUpdatedTimeMs,
createdTimeMs,
"tenant",
sampleConfig1
)
val sampleConfig2 = NotificationConfig(
Expand All @@ -175,7 +170,6 @@ internal class GetNotificationConfigResponseTests {
"config_id2",
lastUpdatedTimeMs,
createdTimeMs,
"tenant",
sampleConfig2
)
val searchResult = NotificationConfigSearchResult(
Expand Down Expand Up @@ -207,7 +201,6 @@ internal class GetNotificationConfigResponseTests {
"config-Id",
lastUpdatedTimeMs,
createdTimeMs,
"selectedTenant",
sampleConfig
)
val searchResult = NotificationConfigSearchResult(configInfo)
Expand All @@ -221,7 +214,6 @@ internal class GetNotificationConfigResponseTests {
"config_id":"config-Id",
"last_updated_time_ms":"${lastUpdatedTimeMs.toEpochMilli()}",
"created_time_ms":"${createdTimeMs.toEpochMilli()}",
"tenant":"selectedTenant",
"config":{
"name":"name",
"description":"description",
Expand Down Expand Up @@ -258,7 +250,6 @@ internal class GetNotificationConfigResponseTests {
"config-Id",
lastUpdatedTimeMs,
createdTimeMs,
"selectedTenant",
sampleConfig
)
val searchResult = NotificationConfigSearchResult(configInfo)
Expand All @@ -269,7 +260,6 @@ internal class GetNotificationConfigResponseTests {
"config_id":"config-Id",
"last_updated_time_ms":"${lastUpdatedTimeMs.toEpochMilli()}",
"created_time_ms":"${createdTimeMs.toEpochMilli()}",
"tenant":"selectedTenant",
"config":{
"name":"name",
"description":"description",
Expand Down Expand Up @@ -299,8 +289,7 @@ internal class GetNotificationConfigResponseTests {
{
"config_id":"config-Id",
"last_updated_time_ms":"${lastUpdatedTimeMs.toEpochMilli()}",
"created_time_ms":"${createdTimeMs.toEpochMilli()}",
"tenant":"selectedTenant"
"created_time_ms":"${createdTimeMs.toEpochMilli()}"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ internal class GetNotificationEventResponseTests {
"event_id",
Instant.now(),
Instant.now(),
"tenant",
sampleEvent
)
val searchResult = NotificationEventSearchResult(eventInfo)
Expand Down Expand Up @@ -116,28 +115,24 @@ internal class GetNotificationEventResponseTests {
"event_id1",
Instant.now(),
Instant.now(),
"tenant",
NotificationEvent(eventSource1, listOf(status1))
)
val eventInfo2 = NotificationEventInfo(
"event_id2",
Instant.now(),
Instant.now(),
"tenant",
NotificationEvent(eventSource2, listOf(status2))
)
val eventInfo3 = NotificationEventInfo(
"event_id3",
Instant.now(),
Instant.now(),
"tenant",
NotificationEvent(eventSource1, listOf(status1, status2))
)
val eventInfo4 = NotificationEventInfo(
"event_id4",
Instant.now(),
Instant.now(),
"tenant",
NotificationEvent(eventSource2, listOf(status1, status2))
)
val searchResult = NotificationEventSearchResult(
Expand Down Expand Up @@ -172,7 +167,6 @@ internal class GetNotificationEventResponseTests {
"event_id",
lastUpdatedTimeMs,
createdTimeMs,
"tenant",
sampleEvent
)
val searchResult = NotificationEventSearchResult(eventInfo)
Expand Down Expand Up @@ -214,14 +208,12 @@ internal class GetNotificationEventResponseTests {
"event_id1",
lastUpdatedTimeMs,
createdTimeMs,
"tenant",
NotificationEvent(eventSource1, listOf(status1))
)
val eventInfo2 = NotificationEventInfo(
"event_id2",
lastUpdatedTimeMs,
createdTimeMs,
"tenant",
NotificationEvent(eventSource2, listOf(status2))
)
val searchResult = NotificationEventSearchResult(
Expand Down Expand Up @@ -257,7 +249,6 @@ internal class GetNotificationEventResponseTests {
"event_id",
lastUpdatedTimeMs,
createdTimeMs,
"selectedTenant",
sampleEvent
)
val searchResult = NotificationEventSearchResult(eventInfo)
Expand All @@ -271,7 +262,6 @@ internal class GetNotificationEventResponseTests {
"event_id":"event_id",
"last_updated_time_ms":"${lastUpdatedTimeMs.toEpochMilli()}",
"created_time_ms":"${createdTimeMs.toEpochMilli()}",
"tenant":"selectedTenant",
"event":{
"event_source":{
"title":"title",
Expand Down Expand Up @@ -325,7 +315,6 @@ internal class GetNotificationEventResponseTests {
"event_id",
lastUpdatedTimeMs,
createdTimeMs,
"selectedTenant",
sampleEvent
)
val searchResult = NotificationEventSearchResult(eventInfo)
Expand All @@ -336,7 +325,6 @@ internal class GetNotificationEventResponseTests {
"event_id":"event_id",
"last_updated_time_ms":"${lastUpdatedTimeMs.toEpochMilli()}",
"created_time_ms":"${createdTimeMs.toEpochMilli()}",
"tenant":"selectedTenant",
"event":{
"event_source":{
"title":"title",
Expand Down Expand Up @@ -379,8 +367,7 @@ internal class GetNotificationEventResponseTests {
{
"event_id":"event_id",
"last_updated_time_ms":"${lastUpdatedTimeMs.toEpochMilli()}",
"created_time_ms":"${createdTimeMs.toEpochMilli()}",
"tenant":"selectedTenant"
"created_time_ms":"${createdTimeMs.toEpochMilli()}"
}
]
}
Expand Down
Loading

0 comments on commit 8fccbea

Please sign in to comment.