fun parse()

in src/main/kotlin/org/opensearch/commons/notifications/model/SesAccount.kt [63:93]


        fun parse(parser: XContentParser): SesAccount {
            var awsRegion: String? = null
            var roleArn: String? = null
            var fromAddress: String? = 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) {
                    REGION_TAG -> awsRegion = parser.text()
                    ROLE_ARN_TAG -> roleArn = parser.textOrNull()
                    FROM_ADDRESS_TAG -> fromAddress = parser.text()
                    else -> {
                        parser.skipChildren()
                        log.info("Unexpected field: $fieldName, while parsing SesAccount")
                    }
                }
            }
            awsRegion ?: throw IllegalArgumentException("$REGION_TAG field absent")
            fromAddress ?: throw IllegalArgumentException("$FROM_ADDRESS_TAG field absent")
            return SesAccount(
                awsRegion,
                roleArn,
                fromAddress
            )
        }