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.

get_from_user() User[source]

Return the actual User object based on the from_user_id.

get_team() Team[source]

Return the actual Team object based on the team_id.

delete()[source]

Delete the notification.

edit(subject: ~typing.Optional[~typing.Union[str, ~pykechain.utils.Empty]] = <pykechain.utils.Empty object>, message: ~typing.Optional[~typing.Union[str, ~pykechain.utils.Empty]] = <pykechain.utils.Empty object>, status: ~typing.Optional[~typing.Union[~pykechain.enums.NotificationStatus, ~pykechain.utils.Empty]] = <pykechain.utils.Empty object>, recipients: ~typing.Optional[~typing.Union[~typing.List[~typing.Union[User, str, int]], ~pykechain.utils.Empty]] = <pykechain.utils.Empty object>, team: ~typing.Optional[~typing.Union[Team, str, ~pykechain.utils.Empty]] = <pykechain.utils.Empty object>, from_user: ~typing.Optional[~typing.Union[User, str, ~pykechain.utils.Empty]] = <pykechain.utils.Empty object>, event: ~typing.Optional[~typing.Union[~pykechain.enums.NotificationEvent, ~pykechain.utils.Empty]] = <pykechain.utils.Empty object>, channel: ~typing.Optional[~typing.Union[~pykechain.enums.NotificationChannels, ~pykechain.utils.Empty]] = <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) –

    1. Header text of the notification. Cannot be cleared.

  • message (basestring or None or Empty) –

    1. Content message of the notification. Cannot be cleared.

  • status (NotificationStatus) –

    1. life-cycle status of the notification, defaults to “DRAFT”. Cannot be cleared.

  • recipients (list or None or Empty) –

    1. list of recipients, each being a User object, user ID or an email address.

  • team (Team object or Team UUID) –

    1. team object to which the notification is constrained

  • from_user (User or user ID or None or Empty) –

    1. Sender of the notification, either a User object or user ID. Defaults to script user.

  • event (NotificationEvent) –

    1. originating event of the notification. Cannot be cleared.

  • channel (NotificationChannels) –

    1. 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)