A Django application that triggers actions based on database changes. Supports webhook integration, message brokers (Kafka, RabbitMQ), and flexible configurations.
Project description
Django Action Triggers (In Development)
Table of Contents
Description
Django Action Triggers is a Django application that allows you to trigger actions based on changes in your database. These actions can include sending a request to a webhook or adding a message to a message broker such as Kafka or RabbitMQ.
This application is highly flexible and can be configured via code or through the Django admin interface.
Key Features
- Database-Driven Triggers: Automatically trigger actions based on model events (e.g., save, delete).
- Webhook Integration: Send HTTP requests to external services when triggers are activated.
- Message Broker Integration: Send messages to messaging brokers like Kafka and RabbitMQ.
- Extensible: Easily extend to support custom triggers and actions.
- Secure Dynamic Configuration: Dynamically set values at runtime for secure and flexible configuration.
Installation
To install the package, run the following command:
pip install django-action-triggers
Then, add the following to your INSTALLED_APPS
in your Django settings:
INSTALLED_APPS = [
...
'action_triggers',
...
]
If you plan on using the API, add the following to your urls.py
:
from django.urls import path, include
urlpatterns = [
...
path('api/action-triggers/', include('action_triggers.urls')),
...
]
Usage
Once installed, you can create triggers and actions using the Django admin interface or programmatically through the API.
For detailed usage instructions, configuration options, and examples, please refer to the official documentation.
Example Scenarios
Example 1: Webhook Trigger on User Creation/Update/Deletion
Trigger a webhook whenever a User
model is created, updated, or deleted:
{
"config_signals": [
{"signal": "post_save"},
{"signal": "post_delete"}
],
"content_types": [
{
"app_label": "auth",
"model_name": "User"
}
],
"webhooks": [
{
"url": "https://my-webhook.com",
"http_method": "POST",
"headers": {
"Authorization": "Bearer {{ myapp.utils.get_token }}"
}
}
],
"active": true
}
Example 2: Webhooks and Message Queues on Product and Sale Creation/Update
Trigger multiple webhooks and add messages to queues when Product
or Sale
models are created or updated:
{
"config_signals": [
{"signal": "post_save"}
],
"content_types": [
{
"app_label": "myapp",
"model_name": "Product"
},
{
"app_label": "myapp",
"model_name": "Sale"
}
],
"webhooks": [
{
"url": "https://my-webhook.com",
"http_method": "POST",
"headers": {
"Authorization": "Bearer {{ myapp.utils.get_token }}"
}
},
{
"url": "https://my-other-webhook.com",
"http_method": "POST",
"headers": {
"Authorization": "Bearer {{ myapp.utils.get_token }}"
}
}
],
"msg_broker_queues": [
{
"name": "my-msg-broker-config",
"parameters": {
"product_id": "{{ myapp.utils.get_product_id }}"
}
},
{
"name": "my-other-msg-broker-config",
"parameters": {
"sale_id": "{{ myapp.utils.get_sale_id }}"
}
}
],
"active": true
}
Documentation
For detailed documentation, including setup, configuration options, API specifications, and more examples, please refer to the official documentation.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_action_triggers-0.1.0.tar.gz
.
File metadata
- Download URL: django_action_triggers-0.1.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f8b5ecea5e42e3da3d298fdbed9dd158f45c3308d24d214a182784913f70928 |
|
MD5 | e2b2188e07b2ecbae0a2148c2fade4ee |
|
BLAKE2b-256 | fc8ddd5bdce47ce6b382d266226216a6af83d814e33ca666d6d02dc694233126 |
File details
Details for the file django_action_triggers-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: django_action_triggers-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9143f9cc5ab1a8b771668976ee4fbd061f4f7f234ab02f839aa10d3c6730b05 |
|
MD5 | c0ec0fb9894412c59793f324eff31665 |
|
BLAKE2b-256 | e178965f08729dde57520d28945b7910bc23527741bb8667363876eb1f3131b0 |