models.Notification¶
- class Notification(json: Dict, **kwargs)[source]¶
A virtual object representing a KE-chain notification.
- Variables:
id – UUID of the notification
subject – subject of the notification
created_at – the datetime when the object was created if available (otherwise None)
updated_at – the datetime when the object was last updated if available (otherwise None)
status – The status of the notification (see
pykechain.enums.NotificationStatus
)event – The event of the notification (see
pykechain.enums.NotificationEvent
)recipient_users – The list of ids of the users
Construct a notification from a KE-chain 2 json response.
- Parameters:
json (dict) – the json response to construct the
Notification
from
- get_recipient_users() List[User] [source]¶
Return the list of actual User objects based on recipient_users_ids.
- edit(subject: str | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, message: str | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, status: ~pykechain.enums.NotificationStatus | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, recipients: ~typing.List[User | str | int] | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, team: Team | str | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, from_user: User | str | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, event: ~pykechain.enums.NotificationEvent | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, channel: ~pykechain.enums.NotificationChannels | ~pykechain.utils.Empty | None = <pykechain.utils.Empty object>, **kwargs) None [source]¶
Update the current Notification attributes.
Setting an input to None will clear out the value (only applicable to recipients and from_user).
- Parameters:
subject (basestring or None or Empty) –
Header text of the notification. Cannot be cleared.
message (basestring or None or Empty) –
Content message of the notification. Cannot be cleared.
status (NotificationStatus) –
life-cycle status of the notification, defaults to “DRAFT”. Cannot be cleared.
recipients (list or None or Empty) –
list of recipients, each being a User object, user ID or an email address.
team (Team object or Team UUID) –
team object to which the notification is constrained
from_user (User or user ID or None or Empty) –
Sender of the notification, either a User object or user ID. Defaults to script user.
event (NotificationEvent) –
originating event of the notification. Cannot be cleared.
channel (NotificationChannels) –
method used to send the notification, defaults to “EMAIL”. Cannot be cleared.
kwargs – (optional) keyword=value arguments
- Returns:
None
- Raises:
APIError: when the Notification could not be updated
Not mentioning an input parameter in the function will leave it unchanged. Setting a parameter as None will clear its value (where that is possible). The example below will clear the from_user, but leave everything else unchanged.
>>> notification.edit(from_user=None)