Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter authoring docs #702

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,47 @@ Examples:
| The meta key is used to store metadata about the event and its needed to
| correctly report about the events in the aap-server.


=======================
Authoring Event Filters
=======================


Event filters are functions in a python module that perform transformations on
the event data. They can remove, add, change, or move any data in the event
data structure. Event filters take the event as the first argument and
additional keyword arguments are provided by the configuration in the rulebook.


The basic structure follows:

.. code-block:: python

# my_namespace.my_collection/extensions/eda/plugins/event_filter/my_filter.py

def main(event: dict, arg1, arg2):

# Process event data here

return event


This filter can be used in a rulebook by adding it to the filters list in an event source:


.. code-block:: yaml

sources:
- name: azure_service_bus
ansible.eda.azure_service_bus:
conn_str: "{{connection_str}}"
queue_name: "{{queue_name}}"
filters:
- my_namespace.my_collection.my_filter:
arg1: hello
arg2: world


See the event filter plugins in ansible.eda collection for more examples of how to author them.

.. _collection: https://github.com/ansible/event-driven-ansible/tree/main/extensions/eda/plugins/event_filter
Loading