-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added common utils for microsoft teams #374
Closed
dankyalo599
wants to merge
4
commits into
opensearch-project:main
from
dankyalo599:add_Microsoft_teams
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b13bf3d
Added common utils for microsoft teams
dankyalo599 700a68b
Added configType ,eventstatus,configDataProperties and msTeams files
dankyalo599 ae39922
Added ConfigType,EventStatus,ConfigDataProperties and MicrosoftTeams
dankyalo599 b874d40
Added ConfigType,EventStatus,ConfigDataProperties and MicrosoftTeams
dankyalo599 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
src/main/kotlin/org/opensearch/commons/notifications/model/MicrosoftTeams.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.commons.notifications.model | ||
|
||
import org.opensearch.common.Strings | ||
import org.opensearch.common.io.stream.StreamInput | ||
import org.opensearch.common.io.stream.StreamOutput | ||
import org.opensearch.common.io.stream.Writeable | ||
import org.opensearch.common.xcontent.XContentParserUtils | ||
import org.opensearch.commons.notifications.NotificationConstants.URL_TAG | ||
import org.opensearch.commons.utils.logger | ||
import org.opensearch.commons.utils.validateUrl | ||
import org.opensearch.core.xcontent.ToXContent | ||
import org.opensearch.core.xcontent.XContentBuilder | ||
import org.opensearch.core.xcontent.XContentParser | ||
import java.io.IOException | ||
<<<<<<< HEAD | ||
|
||
/** | ||
* Data class representing Microsoft Teams channel. | ||
*/ | ||
|
||
data class MicrosoftTeams( | ||
val url: String | ||
======= | ||
/** | ||
* Data class representing Microsoft Teams channel. | ||
*/ | ||
data class MicrosoftTeams( | ||
val url: String | ||
>>>>>>> b13bf3d337f15337a3c6999c5285482a79fd5a5d | ||
) : BaseConfigData { | ||
|
||
init { | ||
require(!Strings.isNullOrEmpty(url)) { "URL is null or empty" } | ||
validateUrl(url) | ||
} | ||
|
||
companion object { | ||
private val log by logger(MicrosoftTeams::class.java) | ||
|
||
/** | ||
<<<<<<< HEAD | ||
* reader to create instance of class from writable. | ||
======= | ||
* Reader to create instance of class from writable. | ||
>>>>>>> b13bf3d337f15337a3c6999c5285482a79fd5a5d | ||
*/ | ||
val reader = Writeable.Reader { MicrosoftTeams(it) } | ||
|
||
/** | ||
* Parser to parse xContent | ||
*/ | ||
val xParser = XParser { parse(it) } | ||
|
||
/** | ||
* Creator used in REST communication. | ||
* @param parser XContentParser to deserialize data from. | ||
*/ | ||
@JvmStatic | ||
@Throws(IOException::class) | ||
fun parse(parser: XContentParser): MicrosoftTeams { | ||
var url: String? = null | ||
|
||
XContentParserUtils.ensureExpectedToken( | ||
<<<<<<< HEAD | ||
XContentParser.Token.START_OBJECT, | ||
parser.currentToken(), | ||
parser | ||
======= | ||
XContentParser.Token.START_OBJECT, | ||
parser.currentToken(), | ||
parser | ||
>>>>>>> b13bf3d337f15337a3c6999c5285482a79fd5a5d | ||
) | ||
while (parser.nextToken() != XContentParser.Token.END_OBJECT) { | ||
val fieldName = parser.currentName() | ||
parser.nextToken() | ||
when (fieldName) { | ||
URL_TAG -> url = parser.text() | ||
else -> { | ||
parser.skipChildren() | ||
log.info("Unexpected field: $fieldName, while parsing Microsoft Teams destination") | ||
} | ||
} | ||
} | ||
url ?: throw IllegalArgumentException("$URL_TAG field absent") | ||
return MicrosoftTeams(url) | ||
} | ||
} | ||
|
||
/** | ||
* Constructor used in transport action communication. | ||
* @param input StreamInput stream to deserialize data from. | ||
*/ | ||
constructor(input: StreamInput) : this( | ||
<<<<<<< HEAD | ||
url = input.readString() | ||
======= | ||
url = input.readString() | ||
>>>>>>> b13bf3d337f15337a3c6999c5285482a79fd5a5d | ||
) | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
override fun writeTo(output: StreamOutput) { | ||
output.writeString(url) | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
override fun toXContent(builder: XContentBuilder?, params: ToXContent.Params?): XContentBuilder { | ||
builder!! | ||
return builder.startObject() | ||
<<<<<<< HEAD | ||
.field(URL_TAG, url) | ||
.endObject() | ||
======= | ||
.field(URL_TAG, url) | ||
.endObject() | ||
>>>>>>> b13bf3d337f15337a3c6999c5285482a79fd5a5d | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you have code merge conflicts here.