in src/main/kotlin/org/opensearch/commons/notifications/model/NotificationConfigInfo.kt [73:108]
fun parse(parser: XContentParser): NotificationConfigInfo {
var configId: String? = null
var lastUpdatedTime: Instant? = null
var createdTime: Instant? = null
var notificationConfig: NotificationConfig? = null
XContentParserUtils.ensureExpectedToken(
XContentParser.Token.START_OBJECT,
parser.currentToken(),
parser
)
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
val fieldName = parser.currentName()
parser.nextToken()
when (fieldName) {
CONFIG_ID_TAG -> configId = parser.text()
UPDATED_TIME_TAG -> lastUpdatedTime = Instant.ofEpochMilli(parser.longValue())
CREATED_TIME_TAG -> createdTime = Instant.ofEpochMilli(parser.longValue())
CONFIG_TAG -> notificationConfig = NotificationConfig.parse(parser)
else -> {
parser.skipChildren()
log.info("Unexpected field: $fieldName, while parsing configuration")
}
}
}
configId ?: throw IllegalArgumentException("$CONFIG_ID_TAG field absent")
lastUpdatedTime ?: throw IllegalArgumentException("$UPDATED_TIME_TAG field absent")
createdTime ?: throw IllegalArgumentException("$CREATED_TIME_TAG field absent")
notificationConfig ?: throw IllegalArgumentException("$CONFIG_TAG field absent")
return NotificationConfigInfo(
configId,
lastUpdatedTime,
createdTime,
notificationConfig
)
}