Skip to content
Closed
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c3cc2bf
Display toast notifications with actions
manodnyab Nov 13, 2024
09729c7
Condition matcher for displaying notifications
manodnyab Nov 15, 2024
f0dbe5b
initial commit
samgst-amazon Nov 19, 2024
e909a0e
Modified deserialization cases and added tests
manodnyab Nov 20, 2024
5a84e39
Merge branch 'feature/ideNotifs' into manodnyb/checkRulesForNotificat…
manodnyab Nov 20, 2024
56c1888
not required file change
manodnyab Nov 20, 2024
a981227
Merge remote-tracking branch 'origin/manodnyb/checkRulesForNotificati…
manodnyab Nov 20, 2024
bd354fc
run on startup
samgst-amazon Nov 20, 2024
fea410a
detekt
samgst-amazon Nov 20, 2024
746e5ab
move vals
samgst-amazon Nov 20, 2024
b038d48
Merge main into feature/ideNotifs-polling
aws-toolkit-automation Nov 20, 2024
1d6e7d2
Merge main into feature/ideNotifs-polling
aws-toolkit-automation Nov 20, 2024
c4f3cac
remote resource implementation
samgst-amazon Nov 20, 2024
867bcda
comments
samgst-amazon Nov 20, 2024
b7f336e
Merge branch 'feature/ideNotifs' into feature/ideNotifs-polling
samgst-amazon Nov 20, 2024
1883530
detekt
samgst-amazon Nov 20, 2024
dbfcefc
feedback 1
manodnyab Nov 20, 2024
823ea7f
Merge remote-tracking branch 'origin/feature/ideNotifs' into manodnyb…
manodnyab Nov 20, 2024
218c8ed
modified the base class
manodnyab Nov 20, 2024
285650f
Merge main into feature/ideNotifs-polling
aws-toolkit-automation Nov 21, 2024
d2b7a6c
Merge branch 'manodnyb/checkRulesForNotifications' into feature/ideNo…
samgst-amazon Nov 21, 2024
c82ee66
Validate file before saving
samgst-amazon Nov 21, 2024
4c397f4
cache path
samgst-amazon Nov 21, 2024
033a3a9
merge conflicts
samgst-amazon Nov 21, 2024
b01283e
feat(amazonq): Introduce auto trigger changes officially (#5080)
andrewyuq Nov 21, 2024
5506ca8
Merge main into feature/ideNotifs-polling
aws-toolkit-automation Nov 21, 2024
dd72d29
observer implementation
samgst-amazon Nov 21, 2024
d6e7aa7
deserialize notifs from file
samgst-amazon Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"Jenkins plugins and the Maven Wrapper.",
"Miscellaneous Processing Documentation upgrade" to "This diff patch covers a diverse set of upgrades spanning ORMs, XML processing, API documentation, " +
"and more.",
"Deprecated API replacement and dependency upgrades" to "This diff patch replaces deprecated APIs and makes additional dependency version upgrades."
"Deprecated API replacement, dependency upgrades, and formatting" to "This diff patch replaces deprecated APIs, makes additional dependency version " +
"upgrades, and formats code changes."
)

class ArtifactHandler(
Expand Down Expand Up @@ -371,7 +372,7 @@
)

is DownloadFailureReason.SSL_HANDSHAKE_ERROR -> notifyStickyWarn(
message("codemodernizer.notification.warn.view_diff_failed.title"),

Check warning on line 375 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/ArtifactHandler.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
message("codemodernizer.notification.warn.download_failed_ssl.content", error),
project,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
const val FONT_SIZE = 14.0f
}

object SCROLL_PANEL {

Check notice on line 33 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class naming convention

Class name `SCROLL_PANEL` should not contain underscores
const val PADDING_TOP = 7
const val PADDING_RIGHT = 14
const val PADDING_BOTTOM = 7
const val PADDING_LEFT = 14
}

object PLAN_CONSTRAINTS {

Check notice on line 40 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class naming convention

Class name `PLAN_CONSTRAINTS` should not contain underscores
const val PLAN_PADDING_TOP = 50
const val PLAN_PADDING_LEFT = 50
const val PLAN_PADDING_BOTTOM = 50
Expand Down Expand Up @@ -72,7 +72,7 @@
const val TABLE_ROW_HEIGHT = 25
}

object FONT_CONSTRAINTS {

Check notice on line 75 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Class naming convention

Class name `FONT_CONSTRAINTS` should not contain underscores
const val PLAIN = 0
const val BOLD = 1
const val ITALIC = 2
Expand All @@ -97,73 +97,73 @@
insets = Insets(5, 5, 5, 5)
}

val DESCRIPTION_FONT = JBFont.create(Font("Arial", Font.PLAIN, PLAN_CONSTRAINTS.STEP_DESCRIPTION_FONT_SIZE))

Check notice on line 100 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.

val PLAN_BORDER = BorderFactory.createEmptyBorder(

Check notice on line 102 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
PLAN_CONSTRAINTS.PLAN_PADDING_TOP,
PLAN_CONSTRAINTS.PLAN_PADDING_LEFT,
PLAN_CONSTRAINTS.PLAN_PADDING_BOTTOM,
PLAN_CONSTRAINTS.PLAN_PADDING_RIGHT
)

val NAME_BORDER = BorderFactory.createEmptyBorder(

Check notice on line 109 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
PLAN_CONSTRAINTS.NAME_PADDING_TOP,
PLAN_CONSTRAINTS.NAME_PADDING_LEFT,
PLAN_CONSTRAINTS.NAME_PADDING_BOTTOM,
PLAN_CONSTRAINTS.NAME_PADDING_RIGHT
)

val DESCRIPTION_BORDER = BorderFactory.createEmptyBorder(

Check notice on line 116 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
PLAN_CONSTRAINTS.DESCRIPTION_PADDING_TOP,
PLAN_CONSTRAINTS.DESCRIPTION_PADDING_LEFT,
PLAN_CONSTRAINTS.DESCRIPTION_PADDING_BOTTOM,
PLAN_CONSTRAINTS.DESCRIPTION_PADDING_RIGHT
)

val TABLE_NAME_BORDER = BorderFactory.createEmptyBorder(

Check notice on line 123 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
PLAN_CONSTRAINTS.TABLE_NAME_PADDING_TOP,
PLAN_CONSTRAINTS.TABLE_NAME_PADDING_LEFT,
PLAN_CONSTRAINTS.TABLE_NAME_PADDING_BOTTOM,
PLAN_CONSTRAINTS.TABLE_NAME_PADDING_RIGHT
)

val TRANSFORMATION_PLAN_PANEL_BORDER = BorderFactory.createCompoundBorder(

Check notice on line 130 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
BorderFactory.createEmptyBorder(10, 10, 10, 10),
BorderFactory.createLineBorder(CodeWhispererColorUtil.POPUP_BUTTON_BORDER, 1, true)

)
val APPENDIX_BORDER = BorderFactory.createEmptyBorder(10, 10, 10, 10)

Check notice on line 135 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
val STEPS_INTRO_BORDER = BorderFactory.createEmptyBorder(10, 10, 30, 10)

Check notice on line 136 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
val STEPS_INTRO_TITLE_BORDER = BorderFactory.createEmptyBorder(0, 0, 5, 0)

Check notice on line 137 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
val TRANSFORMATION_STEP_PANEL_COMPOUND_BORDER = BorderFactory.createCompoundBorder(

Check notice on line 138 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(0, 20, 20, 20),
BorderFactory.createLineBorder(Color.GRAY, 1, true)
),
BorderFactory.createEmptyBorder(5, 5, 5, 5)
)
val TRANSFORMATION_STEPS_INFO_BORDER = BorderFactory.createCompoundBorder(

Check notice on line 145 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(0, 10, 0, 0),
BorderFactory.createLineBorder(Color.GRAY, 1, true)
),
BorderFactory.createEmptyBorder(10, 10, 10, 10)
)
val TRANSFORMATION_STEPS_QCT_INFO_BORDER = BorderFactory.createCompoundBorder(

Check notice on line 152 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(0, 0, 0, 10),
BorderFactory.createLineBorder(Color.GRAY, 1, true)
),
BorderFactory.createEmptyBorder(10, 10, 10, 10)
)
val TRANSFORMATION_PLAN_INFO_BORDER = BorderFactory.createEmptyBorder(10, 10, 10, 10)

Check notice on line 159 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeModernizerUIConstants.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.
val FILLER_CONSTRAINT = GridBagConstraints().apply {
gridy = 1
weighty = 1.0
}

fun getGreenThemeFontColor(): Color = if (JBColor.isBright()) JBColor.GREEN.darker() else JBColor.GREEN
fun getRedThemeFontColor(): Color = JBColor.RED
fun getGrayThemeFontColor(): Color = JBColor.GRAY
fun getLightYellowThemeBackgroundColor(): Color = JBColor.YELLOW.darker()
fun getStepIcon() = if (JBColor.isBright()) AwsIcons.CodeTransform.TIMELINE_STEP_LIGHT else AwsIcons.CodeTransform.TIMELINE_STEP_DARK
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
val row2TextStr = if (it.description.isNotEmpty()) {
it.description
} else {
if (it.status == BuildStepStatus.DONE) {

Check notice on line 74 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/panels/BuildProgressStepDetailsPanel.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Cascade 'if' can be replaced with 'when'

Cascade 'if' should be replaced with 'when'
message("codemodernizer.migration_plan.substeps.description_succeed")
} else if (it.status == BuildStepStatus.ERROR) {
message("codemodernizer.migration_plan.substeps.description_failed")
Expand All @@ -91,8 +91,8 @@
// We don't show description text until step finished.
when (it.status) {
BuildStepStatus.DONE -> setForeground(CodeModernizerUIConstants.getGreenThemeFontColor())
BuildStepStatus.ERROR -> setForeground(CodeModernizerUIConstants.getRedThemeFontColor())
BuildStepStatus.WARNING -> setForeground(CodeModernizerUIConstants.getRedThemeFontColor())
BuildStepStatus.ERROR -> setForeground(CodeModernizerUIConstants.getGrayThemeFontColor())
BuildStepStatus.WARNING -> setForeground(CodeModernizerUIConstants.getGrayThemeFontColor())
BuildStepStatus.WORKING -> text = null
}
}
Expand Down Expand Up @@ -145,7 +145,7 @@
description = if (state == TransformationStatus.STOPPED) {
message("codemodernizer.migration_plan.substeps.description_stopped")
} else {
message("codemodernizer.migration_plan.substeps.description_failed")

Check warning on line 148 in plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/panels/BuildProgressStepDetailsPanel.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
}
)
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.core.notifications

fun checkSeverity(notificationSeverity: String): NotificationSeverity = when (notificationSeverity) {

Check warning on line 6 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/CustomizeNotificationsUi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Function "checkSeverity" is never used
"Critical" -> NotificationSeverity.CRITICAL
"Warning" -> NotificationSeverity.WARNING
"Info" -> NotificationSeverity.INFO
else -> NotificationSeverity.INFO
}

// TODO: Add actions that can be performed from the notifications here
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.core.notifications

import com.intellij.openapi.project.Project

Check warning on line 6 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/DisplayToastNotifications.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused import directive

Unused import directive

object DisplayToastNotifications {}

Check notice on line 8 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/DisplayToastNotifications.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Replace empty class body

Redundant empty class body

Check warning on line 8 in plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/notifications/DisplayToastNotifications.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Unused symbol

Object "DisplayToastNotifications" is never used
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.core.notifications

import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.core.JsonToken
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.databind.JsonNode

class OperationConditionDeserializer : JsonDeserializer<NotificationExpression.OperationCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.OperationCondition = when (parser.currentToken) {
JsonToken.VALUE_STRING -> {
// Handle direct string value
NotificationExpression.OperationCondition(parser.valueAsString)
}
else -> throw JsonMappingException(parser, "Cannot deserialize OperatingCondition")
}
}

class ComparisonConditionDeserializer : JsonDeserializer<NotificationExpression.ComparisonCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.ComparisonCondition {
val op = OperationConditionDeserializer().deserialize(parser, ctxt)
return NotificationExpression.ComparisonCondition(op.value)
}
}

class NotEqualsConditionDeserializer : JsonDeserializer<NotificationExpression.NotEqualsCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.NotEqualsCondition {
val op = OperationConditionDeserializer().deserialize(parser, ctxt)
return NotificationExpression.NotEqualsCondition(op.value)
}
}
class GreaterThanConditionDeserializer : JsonDeserializer<NotificationExpression.GreaterThanCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.GreaterThanCondition {
val op = OperationConditionDeserializer().deserialize(parser, ctxt)
return NotificationExpression.GreaterThanCondition(op.value)
}
}
class GreaterThanOrEqualsConditionDeserializer : JsonDeserializer<NotificationExpression.GreaterThanOrEqualsCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.GreaterThanOrEqualsCondition {
val op = OperationConditionDeserializer().deserialize(parser, ctxt)
return NotificationExpression.GreaterThanOrEqualsCondition(op.value)
}
}
class LessThanConditionDeserializer : JsonDeserializer<NotificationExpression.LessThanCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.LessThanCondition {
val op = OperationConditionDeserializer().deserialize(parser, ctxt)
return NotificationExpression.LessThanCondition(op.value)
}
}
class LessThanOrEqualsConditionDeserializer : JsonDeserializer<NotificationExpression.LessThanOrEqualsCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.LessThanOrEqualsCondition {
val op = OperationConditionDeserializer().deserialize(parser, ctxt)
return NotificationExpression.LessThanOrEqualsCondition(op.value)
}
}
class ComplexOperationConditionDeserializer : JsonDeserializer<NotificationExpression.ComplexOperationCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.ComplexOperationCondition {
val node = parser.codec.readTree<JsonNode>(parser)
if (!node.isArray) {
throw JsonMappingException(parser, "anyOf/noneOf must contain an array of values")
}
val values = node.map { it.asText() }
return NotificationExpression.ComplexOperationCondition(values)
}
}
class AnyOfConditionDeserializer : JsonDeserializer<NotificationExpression.AnyOfCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.AnyOfCondition {
val op = ComplexOperationConditionDeserializer().deserialize(parser, ctxt)
return NotificationExpression.AnyOfCondition(op.value)
}
}

class NoneOfConditionDeserializer : JsonDeserializer<NotificationExpression.NoneOfCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.NoneOfCondition {
val op = ComplexOperationConditionDeserializer().deserialize(parser, ctxt)
return NotificationExpression.NoneOfCondition(op.value)
}
}

class ComplexConditionDeserializer : JsonDeserializer<NotificationExpression.ComplexCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.ComplexCondition {
val node = parser.codec.readTree<JsonNode>(parser)
if (!node.isArray) {
throw JsonMappingException(parser, "or/and must contain an array of values")
}
return NotificationExpression.ComplexCondition(node.toNotificationExpressions(parser))
}
}
class OrConditionDeserializer : JsonDeserializer<NotificationExpression.OrCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.OrCondition {
val op = ComplexConditionDeserializer().deserialize(parser, ctxt)
return NotificationExpression.OrCondition(op.expectedValueList)
}
}

class AndConditionDeserializer : JsonDeserializer<NotificationExpression.AndCondition>() {
override fun deserialize(parser: JsonParser, ctxt: DeserializationContext): NotificationExpression.AndCondition {
val op = ComplexConditionDeserializer().deserialize(parser, ctxt)
return NotificationExpression.AndCondition(op.expectedValueList)
}
}

class NotConditionDeserializer : JsonDeserializer<NotificationExpression.NotCondition>() {
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): NotificationExpression.NotCondition {
val node = p.codec.readTree<JsonNode>(p)
val parser = node.traverse(p.codec)
parser.nextToken()

return NotificationExpression.NotCondition(parser.readValueAs(NotificationExpression::class.java))
}
}

private fun JsonNode.toNotificationExpressions(p: JsonParser): List<NotificationExpression> = this.map { element ->
val parser = element.traverse(p.codec)
parser.nextToken()
parser.readValueAs(NotificationExpression::class.java)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

package software.aws.toolkits.jetbrains.core.notifications

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.databind.annotation.JsonDeserialize

data class NotificationsList(
val schema: Schema,
val notifications: List<NotificationData>?,
)

data class Schema(
val version: String,
)

data class NotificationData(
val id: String,
val schedule: NotificationSchedule,
val severity: String,
val condition: NotificationDisplayCondition?,
val content: NotificationContentDescriptionLocale,
val actions: List<NotificationFollowupActions>? = emptyList(),
)

data class NotificationSchedule(
val type: String,
)

enum class NotificationSeverity {
INFO,
WARNING,
CRITICAL,
}

data class NotificationContentDescriptionLocale(
@JsonProperty("en-US")
val locale: NotificationContentDescription,
)

data class NotificationContentDescription(
val title: String,
val description: String,
)

data class NotificationFollowupActions(
val type: String,
val content: NotificationFollowupActionsContent,
)

data class NotificationFollowupActionsContent(
@JsonProperty("en-US")
val locale: NotificationActionDescription,
)

data class NotificationActionDescription(
val title: String,
val url: String?,
)

data class NotificationDisplayCondition(
val compute: ComputeType?,
val os: SystemType?,
val ide: SystemType?,
val extension: List<ExtensionType>?,
val authx: List<AuthxType>?,
)

data class ComputeType(
val type: NotificationExpression?,
val architecture: NotificationExpression?,
)

data class SystemType(
val type: NotificationExpression?,
val version: NotificationExpression?,
)

data class ExtensionType(
val id: String?,
val version: NotificationExpression?,
)

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.WRAPPER_OBJECT
)
@JsonSubTypes(
JsonSubTypes.Type(value = NotificationExpression.ComparisonCondition::class, name = "=="),
JsonSubTypes.Type(value = NotificationExpression.NotEqualsCondition::class, name = "!="),
JsonSubTypes.Type(value = NotificationExpression.GreaterThanCondition::class, name = ">"),
JsonSubTypes.Type(value = NotificationExpression.GreaterThanOrEqualsCondition::class, name = ">="),
JsonSubTypes.Type(value = NotificationExpression.LessThanCondition::class, name = "<"),
JsonSubTypes.Type(value = NotificationExpression.LessThanOrEqualsCondition::class, name = "<="),
JsonSubTypes.Type(value = NotificationExpression.AnyOfCondition::class, name = "anyOf"),
JsonSubTypes.Type(value = NotificationExpression.NotCondition::class, name = "not"),
JsonSubTypes.Type(value = NotificationExpression.OrCondition::class, name = "or"),
JsonSubTypes.Type(value = NotificationExpression.AndCondition::class, name = "and"),
JsonSubTypes.Type(value = NotificationExpression.NoneOfCondition::class, name = "noneOf")
)
sealed interface NotificationExpression {
@JsonDeserialize(using = NotConditionDeserializer::class)
data class NotCondition(
val expectedValue: NotificationExpression,
) : NotificationExpression

@JsonDeserialize(using = OrConditionDeserializer::class)
data class OrCondition(
val expectedValueList: List<NotificationExpression>,
) : NotificationExpression

@JsonDeserialize(using = AndConditionDeserializer::class)
data class AndCondition(
val expectedValueList: List<NotificationExpression>,
) : NotificationExpression

@JsonDeserialize(using = ComplexConditionDeserializer::class)
data class ComplexCondition(
val expectedValueList: List<NotificationExpression>,
) : NotificationExpression

// General class for comparison operators
@JsonDeserialize(using = OperationConditionDeserializer::class)
data class OperationCondition(
val value: String,
) : NotificationExpression

@JsonDeserialize(using = ComplexOperationConditionDeserializer::class)
data class ComplexOperationCondition(
val value: List<String>,
) : NotificationExpression

@JsonDeserialize(using = ComparisonConditionDeserializer::class)
data class ComparisonCondition(
val value: String,
) : NotificationExpression

@JsonDeserialize(using = NotEqualsConditionDeserializer::class)
data class NotEqualsCondition(
val value: String,
) : NotificationExpression

@JsonDeserialize(using = GreaterThanConditionDeserializer::class)
data class GreaterThanCondition(
val value: String,
) : NotificationExpression

@JsonDeserialize(using = GreaterThanOrEqualsConditionDeserializer::class)
data class GreaterThanOrEqualsCondition(
val value: String,
) : NotificationExpression

@JsonDeserialize(using = LessThanConditionDeserializer::class)
data class LessThanCondition(
val value: String,
) : NotificationExpression

@JsonDeserialize(using = LessThanOrEqualsConditionDeserializer::class)
data class LessThanOrEqualsCondition(
val value: String,
) : NotificationExpression

@JsonDeserialize(using = AnyOfConditionDeserializer::class)
data class AnyOfCondition(
val value: List<String>,
) : NotificationExpression

@JsonDeserialize(using = NoneOfConditionDeserializer::class)
data class NoneOfCondition(
val value: List<String>,
) : NotificationExpression
}

data class AuthxType(
val feature: String,
val type: NotificationExpression?,
val region: NotificationExpression?,
val connectionState: NotificationExpression?,
val ssoScopes: NotificationExpression?,
)
Loading
Loading