1313import msgspec
1414
1515from taskgraph .transforms .base import TransformSequence
16- from taskgraph .util .schema import resolve_keyed_by
16+ from taskgraph .util .schema import Schema , resolve_keyed_by
1717
1818StatusType = Literal [
1919 "on-completed" ,
2626]
2727
2828
29- class EmailRecipient (msgspec . Struct , kw_only = True , rename = "kebab" ):
29+ class EmailRecipient (Schema ):
3030 """Email notification recipient."""
3131
3232 type : Literal ["email" ]
3333 address : Union [str , Dict [str , Any ]] # Can be keyed-by
3434 status_type : Optional [StatusType ] = None
3535
3636
37- class MatrixRoomRecipient (msgspec . Struct , kw_only = True , rename = "kebab" ):
37+ class MatrixRoomRecipient (Schema ):
3838 """Matrix room notification recipient."""
3939
4040 type : Literal ["matrix-room" ]
4141 room_id : str
4242 status_type : Optional [StatusType ] = None
4343
4444
45- class PulseRecipient (msgspec . Struct , kw_only = True , rename = "kebab" ):
45+ class PulseRecipient (Schema ):
4646 """Pulse notification recipient."""
4747
4848 type : Literal ["pulse" ]
4949 routing_key : str
5050 status_type : Optional [StatusType ] = None
5151
5252
53- class SlackChannelRecipient (msgspec . Struct , kw_only = True , rename = "kebab" ):
53+ class SlackChannelRecipient (Schema ):
5454 """Slack channel notification recipient."""
5555
5656 type : Literal ["slack-channel" ]
@@ -71,22 +71,22 @@ class SlackChannelRecipient(msgspec.Struct, kw_only=True, rename="kebab"):
7171"""Map each type to its primary key that will be used in the route."""
7272
7373
74- class EmailLink (msgspec . Struct , kw_only = True ):
74+ class EmailLink (Schema , rename = None , omit_defaults = False ):
7575 """Email link configuration."""
7676
7777 text : str
7878 href : str
7979
8080
81- class EmailContent (msgspec . Struct , kw_only = True , omit_defaults = True ):
81+ class EmailContent (Schema , rename = None ):
8282 """Email notification content."""
8383
8484 subject : Optional [str ] = None
8585 content : Optional [str ] = None
8686 link : Optional [EmailLink ] = None
8787
8888
89- class MatrixContent (msgspec . Struct , kw_only = True , omit_defaults = True , rename = "kebab" ):
89+ class MatrixContent (Schema ):
9090 """Matrix notification content."""
9191
9292 body : Optional [str ] = None
@@ -95,32 +95,30 @@ class MatrixContent(msgspec.Struct, kw_only=True, omit_defaults=True, rename="ke
9595 msg_type : Optional [str ] = None
9696
9797
98- class SlackContent (msgspec . Struct , kw_only = True , omit_defaults = True ):
98+ class SlackContent (Schema , rename = None ):
9999 """Slack notification content."""
100100
101101 text : Optional [str ] = None
102102 blocks : Optional [List [Any ]] = None
103103 attachments : Optional [List [Any ]] = None
104104
105105
106- class NotifyContent (msgspec . Struct , kw_only = True , omit_defaults = True ):
106+ class NotifyContent (Schema , rename = None ):
107107 """Notification content configuration."""
108108
109109 email : Optional [EmailContent ] = None
110110 matrix : Optional [MatrixContent ] = None
111111 slack : Optional [SlackContent ] = None
112112
113113
114- class NotifyConfig (msgspec . Struct , kw_only = True , omit_defaults = True ):
114+ class NotifyConfig (Schema , rename = None ):
115115 """Modern notification configuration."""
116116
117117 recipients : List [Dict [str , Any ]] # Will be validated as Recipient union
118118 content : Optional [NotifyContent ] = None
119119
120120
121- class LegacyNotificationsConfig (
122- msgspec .Struct , kw_only = True , omit_defaults = True , rename = "kebab"
123- ):
121+ class LegacyNotificationsConfig (Schema , rename = "kebab" ):
124122 """Legacy notification configuration for backwards compatibility."""
125123
126124 emails : Union [List [str ], Dict [str , Any ]] # Can be keyed-by
@@ -130,9 +128,7 @@ class LegacyNotificationsConfig(
130128
131129
132130#: Schema for notify transforms
133- class NotifySchema (
134- msgspec .Struct , kw_only = True , omit_defaults = True , tag_field = "notify_type"
135- ):
131+ class NotifySchema (Schema , tag_field = "notify_type" ):
136132 """Schema for notify transforms.
137133
138134 Note: This schema allows either 'notify' or 'notifications' field,
0 commit comments