Base Notifier¶
Base class for notification delivery implementations.
Base notifier class for notification delivery.
Provides the abstract base class for implementing notification delivery to different channels.
Notifier
dataclass
¶
Notifier()
Bases: Generic[NOTIFIER_TARGET]
Abstract base class for notification delivery implementations.
Defines the interface for sending notifications to specific targets. Subclasses implement the actual delivery logic for different channels (e.g., SES, SNS).
Class Type Parameters:
| Name | Bound or Constraints | Description | Default |
|---|---|---|---|
NOTIFIER_TARGET
|
The target model type for this notifier. |
required |
Example
@dataclass
class MyNotifier(Notifier[MyTarget]):
def notify(self, content: NotificationContent, target: MyTarget) -> NotifierResult:
# Implement delivery logic
return NotifierResult(success=True, ...)
notifier_target_class
classmethod
¶
notifier_target_class()
Get the target class type for this notifier.
Returns:
| Type | Description |
|---|---|
Type[NOTIFIER_TARGET]
|
The target model class. |
Source code in src/aibs_informatics_aws_lambda/handlers/notifications/notifiers/base.py
43 44 45 46 47 48 49 50 | |
notify
abstractmethod
¶
notify(content, target)
Deliver a notification to the target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
NotificationContent
|
The notification content to deliver. |
required |
target
|
NOTIFIER_TARGET
|
The delivery target specification. |
required |
Returns:
| Type | Description |
|---|---|
NotifierResult
|
Result indicating success or failure. |
Source code in src/aibs_informatics_aws_lambda/handlers/notifications/notifiers/base.py
52 53 54 55 56 57 58 59 60 61 62 63 | |
parse_target
classmethod
¶
parse_target(target)
Parse a target from a dictionary or validate an existing target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Union[Dict[str, Any], NOTIFIER_TARGET]
|
Either a dictionary to parse or an existing target object. |
required |
Returns:
| Type | Description |
|---|---|
NOTIFIER_TARGET
|
The parsed or validated target object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the target cannot be parsed. |
Source code in src/aibs_informatics_aws_lambda/handlers/notifications/notifiers/base.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |