django-krules-extensions 0.1
A Django app that provides models and admin interface to store and manage your krules processed events within your Django ORM
Requires Python: >=3.6
Keywords: django krules

Django KRules Extensions
========================

This app provides models and admin interface to store and manage your krules application within your Django ORM

Quick start
-----------

1. Add "krules", "prettyjson" and "rest_framework" to your INSTALLED_APPS setting like this::

    INSTALLED_APPS = [
        ...
        'prettyjson',
        'rest_framework',
        'krules',
        ...
    ]

2. Collect static::

    python manage.py collectstatic


Scheduler
---------

1. Add "krules.scheduler" to your INSTALLED_APPS settings just after "krules" like this::

    INSTALLED_APPS = [
        ...
        'prettyjson',
        'rest_framework',
        'krules',
        'krules.scheduler',
        ...
    ]


2. Add urls to your application::

    from django.urls import path, include

    urlpatterns = [
        ...
        path(r'api/', include("krules.scheduler.urls")),
        ...
    ]

3. Migrate::

    python manage.py migrate

4. [OPTIONAL] Define custom authentication policies

    By default procevents API is completely open because they are designed to be used within an isolated cluster.
    However, if you want to integrate them into an external service, you can override the authentication mode, using for example a jwt token, and restrict the permissions by changing the settings.

    SCHEDULED_EVENTS_AUTHENTICATION_CLASSES = []

    SCHEDULED_EVENTS_PERMISSION_CLASSES = ['rest_framework.permissions.AllowAny', ]

    Both authentication and permission classes must be compliant with `Django Rest Framework <https://www.django-rest-framework.org/>`_.
    Look at `Authentication <https://www.django-rest-framework.org/api-guide/authentication/>`_ and `Permissions <https://www.django-rest-framework.org/api-guide/permissions/>`_ sections for more info.

Procevents
----------

1. Add "krules.procevents" to your INSTALLED_APPS settings just after "krules" like this::

    INSTALLED_APPS = [
        ...
        'prettyjson',
        'rest_framework',
        'krules',
        'krules.procevents',
        ...
    ]


2. Add urls to your application::

    from django.urls import path, include

    urlpatterns = [
        ...
        path(r'api/procevents', include("krules.procevents.urls")),
        ...
    ]

    *API Guide*





3. [OPTIONAL] Define custom authentication policies

    By default procevents API is completely open because they are designed to be used within an isolated cluster.
    However, if you want to integrate them into an external service, you can override the authentication mode, using for example a jwt token, and restrict the permissions by changing the settings.

    PROCEVENTS_AUTHENTICATION_CLASSES = []
    PROCEVENTS_PERMISSION_CLASSES = ['rest_framework.permissions.AllowAny', ]

    Both authentication and permission classes must be compliant with `Django Rest Framework <https://www.django-rest-framework.org/>`_.
    Look at `Authentication <https://www.django-rest-framework.org/api-guide/authentication/>`_ and `Permissions <https://www.django-rest-framework.org/api-guide/permissions/>`_ sections for more info.


API Guide
---------

- Scheduler


    **GET**

    Url: /api/scheduler/<id>

    Returns:

        {
            "uid": UUID string,
            "event_type": string,
            "subject": string,
            "origin_id": string,
            "payload": dict,
            "when": datetime string [YYYY:MM:ddTHH:mm:ss]
        }


    **POST**

    Url: /api/scheduler/

    Content-Type: application/json

    Data:

        {
            "uid": UUID string,
            "event_type": string,
            "subject": string,
            "origin_id": string,
            "payload": dict,
            "when": datetime string [YYYY:MM:ddTHH:mm:ss]
        }


    **LIST**

    Url: /api/scheduler/

    Returns:

        [
            {
                "uid": UUID string,
                "event_type": string,
                "subject": string,
                "origin_id": string,
                "payload": dict,
                "when": datetime string [YYYY:MM:ddTHH:mm:ss]
            }
        ]

- Procevents


    **GET**

    Url: /api/procevents/<id>

    Returns:

        {
            "rule_name": string,
            "type": string,
            "subject": string,
            "event_info": dict,
            "payload": dict,
            "time": datetime string [YYYY:MM:ddTHH:mm:ss],
            "filters": dict,
            "processing": dict,
            "got_errors": boolean,
            "processed": boolean,
            "source": string,
            "origin_id": string
        }


    **POST**

    Url: /api/procevents/

    Content-Type: application/json

    Data:

        {
            "rule_name": string,
            "type": string,
            "subject": string,
            "event_info": dict,
            "payload": dict,
            "time": datetime string [YYYY:mm:ddTHH:MM:ss],
            "filters": dict,
            "processing": dict,
            "got_errors": boolean,
            "processed": boolean,
            "source": string,
            "origin_id": string
        }



    **LIST**

    Url: /api/procevents/

    Returns:

        [
            {
                "rule_name": string,
                "type": string,
                "subject": string,
                "event_info": dict,
                "payload": dict,
                "time": datetime string [YYYY:MM:ddTHH:mm:ss],
                "filters": dict,
                "processing": dict,
                "got_errors": boolean,
                "processed": boolean,
                "source": string,
                "origin_id": string
            }
        ]