Skip to main content

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

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

django_action_triggers-0.1.1.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

django_action_triggers-0.1.1-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file django_action_triggers-0.1.1.tar.gz.

File metadata

  • Download URL: django_action_triggers-0.1.1.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

Hashes for django_action_triggers-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4c7161f77fe4ef79aab0e1b9ce9fd3aee30e92299ca99cb384d7036d6276b9cf
MD5 46cb45971d34c570de3d001779e44787
BLAKE2b-256 a185fdbd79cbd7d44538e224ff920c1dc9f2e5b200473d0eaf28c7c3a08c4427

See more details on using hashes here.

File details

Details for the file django_action_triggers-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: django_action_triggers-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 25.1 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

Hashes for django_action_triggers-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 07837c4a4e48af2ca894fc9cf0fc3a091cc1223b9c4b46b32a7f9d4da9d514e4
MD5 ae0fa63040cc3c7e5cc9690bb6951052
BLAKE2b-256 02bc566cc2d689f498b55a2e6f098ecb13858c46a81a8cd9d256e78113757043

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page