16.2.1.7. Event Handler¶
The following event handlers are known to privacyIDEA
- class privacyidea.lib.event.EventConfiguration[source]¶
This class is supposed to contain the event handling configuration during the Request. The currently defined events are fetched from the request-local config object.
- property events¶
Shortcut for retrieving the currently defined event handlers from the request-local config object.
- privacyidea.lib.event.delete_event(event_id: int) int[source]¶
Delete the event configuration with this given ID. :param event_id: The database ID of the event. :return: event ID
- privacyidea.lib.event.enable_event(event_id, enable=True)[source]¶
Enable or disable the event
- Parameters:
event_id (int) – ID of the event
enable (bool) – enable or disable the event
- Returns:
- class privacyidea.lib.event.event(eventname, request, g)[source]¶
This is the event decorator that calls the event handler in the handler module. This event decorator can be used at any API call
- privacyidea.lib.event.get_handler_modules()[source]¶
Return the identifiers of all available event handler modules.
- privacyidea.lib.event.get_handler_object(handler_name)[source]¶
Return an event handler object based on the Name of the event handler class
- Parameters:
handler_name (basestring) – The identifier of the Handler Class
- Returns:
- privacyidea.lib.event.set_event(name=None, event=None, handlermodule=None, action=None, conditions: dict = None, ordering=0, options: dict = None, id=None, active=True, position='post', abort_on_error=None)[source]¶
Set an event handling configuration. This writes an entry to the database eventhandler.
- Parameters:
name – The name of the event definition
event (basestring) – The name of the event to react on. Can be a single event or a comma separated list.
handlermodule (basestring) – The identifier of the event handler module. This is an identifier string like “UserNotification”
action (basestring) – The action to perform. This is an action defined by the handler module
conditions (dict) – A condition. Only if this condition is met, the action is performed. If
None(the default) the stored conditions are kept untouched. A dict replaces all stored conditions; an empty dict clears them.ordering (integer) – An optional ordering of the event definitions.
options (dict) – Additional options, that are needed as parameters for the action. If
None(the default) the stored options are kept untouched. A dict replaces all stored options; an empty dict clears them.id (int) – The DB id of the event. If the id is given, the event is updated. Otherwise, a new entry is generated.
position (basestring) – The position of the event handler being “post” or “pre”
abort_on_error (bool) – Abort the request if the handler raises an exception. A failing handler otherwise only adds a failure entry to the audit log and the request continues without it. If it is None, an existing event keeps its value and a new event gets the default of its handler module.
- Returns:
The id of the event.