django-webhook-subscriber 1.0.0__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_webhook_subscriber/__init__.py +7 -1
- django_webhook_subscriber/admin.py +831 -182
- django_webhook_subscriber/apps.py +3 -20
- django_webhook_subscriber/conf.py +11 -24
- django_webhook_subscriber/delivery.py +414 -159
- django_webhook_subscriber/http.py +51 -0
- django_webhook_subscriber/management/commands/webhook.py +169 -0
- django_webhook_subscriber/management/commands/webhook_cache.py +173 -0
- django_webhook_subscriber/management/commands/webhook_logs.py +226 -0
- django_webhook_subscriber/management/commands/webhook_performance_test.py +469 -0
- django_webhook_subscriber/management/commands/webhook_send.py +96 -0
- django_webhook_subscriber/management/commands/webhook_status.py +139 -0
- django_webhook_subscriber/managers.py +36 -14
- django_webhook_subscriber/migrations/0002_remove_webhookregistry_content_type_and_more.py +192 -0
- django_webhook_subscriber/models.py +291 -114
- django_webhook_subscriber/serializers.py +16 -50
- django_webhook_subscriber/tasks.py +434 -56
- django_webhook_subscriber/tests/factories.py +40 -0
- django_webhook_subscriber/tests/settings.py +27 -8
- django_webhook_subscriber/tests/test_delivery.py +453 -190
- django_webhook_subscriber/tests/test_http.py +32 -0
- django_webhook_subscriber/tests/test_managers.py +26 -37
- django_webhook_subscriber/tests/test_models.py +341 -251
- django_webhook_subscriber/tests/test_serializers.py +22 -56
- django_webhook_subscriber/tests/test_tasks.py +477 -189
- django_webhook_subscriber/tests/test_utils.py +98 -94
- django_webhook_subscriber/utils.py +87 -69
- django_webhook_subscriber/validators.py +53 -0
- django_webhook_subscriber-2.0.0.dist-info/METADATA +774 -0
- django_webhook_subscriber-2.0.0.dist-info/RECORD +38 -0
- django_webhook_subscriber/management/commands/check_webhook_tasks.py +0 -113
- django_webhook_subscriber/management/commands/clean_webhook_logs.py +0 -65
- django_webhook_subscriber/management/commands/test_webhook.py +0 -96
- django_webhook_subscriber/signals.py +0 -152
- django_webhook_subscriber/testing.py +0 -14
- django_webhook_subscriber/tests/test_signals.py +0 -268
- django_webhook_subscriber-1.0.0.dist-info/METADATA +0 -448
- django_webhook_subscriber-1.0.0.dist-info/RECORD +0 -33
- {django_webhook_subscriber-1.0.0.dist-info → django_webhook_subscriber-2.0.0.dist-info}/WHEEL +0 -0
- {django_webhook_subscriber-1.0.0.dist-info → django_webhook_subscriber-2.0.0.dist-info}/licenses/LICENSE +0 -0
- {django_webhook_subscriber-1.0.0.dist-info → django_webhook_subscriber-2.0.0.dist-info}/top_level.txt +0 -0
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
"""Django Webhook Subscriber App Configuration."""
|
|
2
|
-
|
|
3
1
|
from django.apps import AppConfig
|
|
4
|
-
from django.conf import settings
|
|
5
|
-
|
|
6
|
-
from django_webhook_subscriber.signals import register_webhooks_from_settings
|
|
7
|
-
from django_webhook_subscriber.utils import unregister_webhook_signals
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class WebhookSubscriberConfig(AppConfig):
|
|
11
|
-
name = 'django_webhook_subscriber'
|
|
12
|
-
verbose_name = 'Django Webhook Subscriber'
|
|
13
|
-
|
|
14
|
-
def ready(self):
|
|
15
|
-
"""This method is called when the app is ready."""
|
|
16
2
|
|
|
17
|
-
# Unregister all webhooks first (to clean up any existing signals)
|
|
18
|
-
unregister_webhook_signals()
|
|
19
3
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
register_webhooks_from_settings()
|
|
4
|
+
class DjangoWebhookSubscriberConfig(AppConfig):
|
|
5
|
+
verbose_name = "Django Webhook Subscriber"
|
|
6
|
+
name = "django_webhook_subscriber"
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
+
from copy import deepcopy
|
|
2
|
+
|
|
1
3
|
from django.conf import settings
|
|
2
4
|
from django.core.exceptions import ImproperlyConfigured
|
|
3
|
-
from copy import deepcopy
|
|
4
5
|
|
|
5
6
|
DEFAULTS = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'DEFAULT_MAX_RETRIES': 3, # Default max retries for webhook delivery
|
|
11
|
-
'DEFAULT_RETRY_DELAY': 60, # Default delay between retries in seconds
|
|
12
|
-
'REQUEST_TIMEOUT': 30, # Default timeout for webhook requests
|
|
7
|
+
"LOG_RETENTION_DAYS": 30, # Number of days to keep logs
|
|
8
|
+
"AUTO_CLEANUP": True, # Automatically clean up old logs
|
|
9
|
+
"WEBHOOK_CACHE_TTL": 300, # Cache TTL for webhook configurations
|
|
10
|
+
"MAX_BATCH_SIZE": 100, # Max number of webhooks to send in a single batch
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
USER_SETTINGS = getattr(settings,
|
|
13
|
+
USER_SETTINGS = getattr(settings, "WEBHOOK_SUBSCRIBER", {})
|
|
16
14
|
|
|
17
15
|
|
|
18
16
|
# Merge user settings with defaults
|
|
@@ -28,10 +26,9 @@ class Settings:
|
|
|
28
26
|
val = self._user_settings.get(attr, deepcopy(self._defaults[attr]))
|
|
29
27
|
|
|
30
28
|
if attr in [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'DEFAULT_RETRY_DELAY',
|
|
29
|
+
"LOG_RETENTION_DAYS",
|
|
30
|
+
"WEBHOOK_CACHE_TTL",
|
|
31
|
+
"MAX_BATCH_SIZE",
|
|
35
32
|
]:
|
|
36
33
|
if not isinstance(val, int) or val <= 0:
|
|
37
34
|
raise ImproperlyConfigured(
|
|
@@ -39,19 +36,9 @@ class Settings:
|
|
|
39
36
|
"positive integer."
|
|
40
37
|
)
|
|
41
38
|
|
|
42
|
-
if attr == 'WEBHOOK_MODELS':
|
|
43
|
-
if not isinstance(val, dict):
|
|
44
|
-
raise ImproperlyConfigured(
|
|
45
|
-
f"Invalid value for '{attr}': {val}. It should be a "
|
|
46
|
-
"dictionary."
|
|
47
|
-
)
|
|
48
|
-
|
|
49
39
|
return val
|
|
50
40
|
|
|
51
41
|
|
|
52
|
-
# rest_webhook_settings = Settings(USER_SETTINGS, DEFAULTS)
|
|
53
|
-
|
|
54
|
-
|
|
55
42
|
# Lazy loading of settings
|
|
56
43
|
# This allows settings to be accessed without importing them directly
|
|
57
44
|
# from the settings module. This is useful for testing and other
|
|
@@ -60,7 +47,7 @@ class LazySettings:
|
|
|
60
47
|
def __getattr__(self, attr):
|
|
61
48
|
from django.conf import settings
|
|
62
49
|
|
|
63
|
-
user_settings = getattr(settings,
|
|
50
|
+
user_settings = getattr(settings, "WEBHOOK_SUBSCRIBER", {})
|
|
64
51
|
_settings = Settings(user_settings, DEFAULTS)
|
|
65
52
|
return getattr(_settings, attr)
|
|
66
53
|
|