hookbridge 2.2.0__tar.gz → 2.3.0__tar.gz
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.
- {hookbridge-2.2.0 → hookbridge-2.3.0}/PKG-INFO +60 -2
- {hookbridge-2.2.0 → hookbridge-2.3.0}/README.md +59 -1
- {hookbridge-2.2.0 → hookbridge-2.3.0}/hookbridge/__init__.py +28 -0
- hookbridge-2.3.0/hookbridge/_version.py +1 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/hookbridge/client.py +597 -10
- {hookbridge-2.2.0 → hookbridge-2.3.0}/hookbridge/errors.py +3 -1
- {hookbridge-2.2.0 → hookbridge-2.3.0}/hookbridge/types.py +134 -2
- {hookbridge-2.2.0 → hookbridge-2.3.0}/pyproject.toml +1 -1
- hookbridge-2.3.0/tests/test_event_types.py +714 -0
- hookbridge-2.3.0/tests/test_spec_sync_2_3_0.py +179 -0
- hookbridge-2.2.0/.claude/settings.local.json +0 -8
- hookbridge-2.2.0/hookbridge/_version.py +0 -1
- {hookbridge-2.2.0 → hookbridge-2.3.0}/.gitignore +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/hookbridge/py.typed +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/requirements-dev.txt +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/requirements.txt +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/__init__.py +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/conftest.py +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/test_async_client.py +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/test_client.py +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/test_client_spec_parity.py +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/test_dry_run_actions.py +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/test_errors.py +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/test_openapi_sync_2026_11.py +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/test_positional_compat.py +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/test_removed_session_only_methods.py +0 -0
- {hookbridge-2.2.0 → hookbridge-2.3.0}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: hookbridge
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Official HookBridge SDK for Python
|
|
5
5
|
Project-URL: Homepage, https://hookbridge.io
|
|
6
6
|
Project-URL: Documentation, https://hookbridge.io/docs/sdks/python
|
|
@@ -123,11 +123,57 @@ result = client.send(
|
|
|
123
123
|
)
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
+
### Event Types
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from datetime import datetime, timedelta, timezone
|
|
130
|
+
|
|
131
|
+
from hookbridge import EventSubscriptions
|
|
132
|
+
|
|
133
|
+
# Register an event type and subscribe endpoints to it (exact name or `prefix.*`)
|
|
134
|
+
client.create_event_type("order.created", group="orders", description="An order was placed")
|
|
135
|
+
endpoint = client.create_endpoint(
|
|
136
|
+
url="https://customer.app/webhooks",
|
|
137
|
+
subscriptions=EventSubscriptions(event_types=["order.*"]),
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# Send an event to every subscribed endpoint (pass endpoint_id= to target one)
|
|
141
|
+
sent = client.send_event("order.created", {"order_id": "ord_123"})
|
|
142
|
+
|
|
143
|
+
# Inspect the event and its fanned-out messages
|
|
144
|
+
event = client.get_event(sent.event_id)
|
|
145
|
+
events = client.list_events(event_type="order.created")
|
|
146
|
+
client.delete_event(sent.event_id)
|
|
147
|
+
|
|
148
|
+
# Manage the catalog (names may contain dots and `*`)
|
|
149
|
+
client.list_event_types(name_prefix="order.")
|
|
150
|
+
client.update_event_type("order.created", description="Updated", group=None) # None clears
|
|
151
|
+
client.archive_event_type("order.created")
|
|
152
|
+
client.unarchive_event_type("order.created")
|
|
153
|
+
client.list_event_type_groups()
|
|
154
|
+
|
|
155
|
+
# Endpoints subscribed to a type; subscriptions are only changed when you pass them
|
|
156
|
+
client.list_endpoints(event_type="order.created")
|
|
157
|
+
client.update_endpoint(endpoint.id, subscriptions=EventSubscriptions(groups=["orders"]))
|
|
158
|
+
|
|
159
|
+
# Each event reports how many of its messages are in each status (plus `deleted`)
|
|
160
|
+
print(event.status_counts) # {"succeeded": 2, "pending_retry": 1}
|
|
161
|
+
# `target_endpoint_id` and each message's `endpoint_id` are public `ep_...` ids
|
|
162
|
+
|
|
163
|
+
# Replay missed events to an endpoint and send a test event
|
|
164
|
+
job = client.recover_endpoint(endpoint.id, since=datetime.now(timezone.utc) - timedelta(hours=1))
|
|
165
|
+
client.get_recover_job(endpoint.id, job.recover_job_id)
|
|
166
|
+
client.send_test_event(endpoint.id, event_type="order.created")
|
|
167
|
+
```
|
|
168
|
+
|
|
126
169
|
### Check Message Status
|
|
127
170
|
|
|
128
171
|
```python
|
|
129
172
|
message = client.get_message(result.message_id)
|
|
130
173
|
print(message.status) # 'queued', 'succeeded', 'pending_retry', 'failed_permanent'
|
|
174
|
+
|
|
175
|
+
# Messages sent from an event also carry event info (None for untyped messages)
|
|
176
|
+
print(message.event_type, message.event_id, message.is_test)
|
|
131
177
|
```
|
|
132
178
|
|
|
133
179
|
### Query Delivery Logs
|
|
@@ -138,11 +184,12 @@ from datetime import datetime
|
|
|
138
184
|
logs = client.get_logs(
|
|
139
185
|
status="failed_permanent",
|
|
140
186
|
start_time=datetime(2025, 1, 1),
|
|
187
|
+
endpoint_id="ep_550e8400e29b41d4a716446655440000", # optional endpoint filter
|
|
141
188
|
limit=100
|
|
142
189
|
)
|
|
143
190
|
|
|
144
191
|
for msg in logs.messages:
|
|
145
|
-
print(msg.message_id, msg.last_error)
|
|
192
|
+
print(msg.message_id, msg.last_error, msg.event_type, msg.event_id, msg.is_test)
|
|
146
193
|
```
|
|
147
194
|
|
|
148
195
|
### Get Metrics
|
|
@@ -277,6 +324,17 @@ for rejection in rejections.entries:
|
|
|
277
324
|
print(rejection.reason_code, rejection.reason_detail)
|
|
278
325
|
```
|
|
279
326
|
|
|
327
|
+
## Client Name
|
|
328
|
+
|
|
329
|
+
Pass `client_name` to tag replay, retry and cancel actions in your audit trail. It is sent as the
|
|
330
|
+
`X-Hookbridge-Client` header on every request. It is self-reported (not authenticated), must be
|
|
331
|
+
printable ASCII, and is truncated by the server at 200 bytes. A value with other characters
|
|
332
|
+
(including CR or LF) raises `ValidationError` at construction.
|
|
333
|
+
|
|
334
|
+
```python
|
|
335
|
+
client = HookBridge(api_key="hb_live_xxx", client_name="billing-worker")
|
|
336
|
+
```
|
|
337
|
+
|
|
280
338
|
## Async Usage
|
|
281
339
|
|
|
282
340
|
```python
|
|
@@ -88,11 +88,57 @@ result = client.send(
|
|
|
88
88
|
)
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
+
### Event Types
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from datetime import datetime, timedelta, timezone
|
|
95
|
+
|
|
96
|
+
from hookbridge import EventSubscriptions
|
|
97
|
+
|
|
98
|
+
# Register an event type and subscribe endpoints to it (exact name or `prefix.*`)
|
|
99
|
+
client.create_event_type("order.created", group="orders", description="An order was placed")
|
|
100
|
+
endpoint = client.create_endpoint(
|
|
101
|
+
url="https://customer.app/webhooks",
|
|
102
|
+
subscriptions=EventSubscriptions(event_types=["order.*"]),
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Send an event to every subscribed endpoint (pass endpoint_id= to target one)
|
|
106
|
+
sent = client.send_event("order.created", {"order_id": "ord_123"})
|
|
107
|
+
|
|
108
|
+
# Inspect the event and its fanned-out messages
|
|
109
|
+
event = client.get_event(sent.event_id)
|
|
110
|
+
events = client.list_events(event_type="order.created")
|
|
111
|
+
client.delete_event(sent.event_id)
|
|
112
|
+
|
|
113
|
+
# Manage the catalog (names may contain dots and `*`)
|
|
114
|
+
client.list_event_types(name_prefix="order.")
|
|
115
|
+
client.update_event_type("order.created", description="Updated", group=None) # None clears
|
|
116
|
+
client.archive_event_type("order.created")
|
|
117
|
+
client.unarchive_event_type("order.created")
|
|
118
|
+
client.list_event_type_groups()
|
|
119
|
+
|
|
120
|
+
# Endpoints subscribed to a type; subscriptions are only changed when you pass them
|
|
121
|
+
client.list_endpoints(event_type="order.created")
|
|
122
|
+
client.update_endpoint(endpoint.id, subscriptions=EventSubscriptions(groups=["orders"]))
|
|
123
|
+
|
|
124
|
+
# Each event reports how many of its messages are in each status (plus `deleted`)
|
|
125
|
+
print(event.status_counts) # {"succeeded": 2, "pending_retry": 1}
|
|
126
|
+
# `target_endpoint_id` and each message's `endpoint_id` are public `ep_...` ids
|
|
127
|
+
|
|
128
|
+
# Replay missed events to an endpoint and send a test event
|
|
129
|
+
job = client.recover_endpoint(endpoint.id, since=datetime.now(timezone.utc) - timedelta(hours=1))
|
|
130
|
+
client.get_recover_job(endpoint.id, job.recover_job_id)
|
|
131
|
+
client.send_test_event(endpoint.id, event_type="order.created")
|
|
132
|
+
```
|
|
133
|
+
|
|
91
134
|
### Check Message Status
|
|
92
135
|
|
|
93
136
|
```python
|
|
94
137
|
message = client.get_message(result.message_id)
|
|
95
138
|
print(message.status) # 'queued', 'succeeded', 'pending_retry', 'failed_permanent'
|
|
139
|
+
|
|
140
|
+
# Messages sent from an event also carry event info (None for untyped messages)
|
|
141
|
+
print(message.event_type, message.event_id, message.is_test)
|
|
96
142
|
```
|
|
97
143
|
|
|
98
144
|
### Query Delivery Logs
|
|
@@ -103,11 +149,12 @@ from datetime import datetime
|
|
|
103
149
|
logs = client.get_logs(
|
|
104
150
|
status="failed_permanent",
|
|
105
151
|
start_time=datetime(2025, 1, 1),
|
|
152
|
+
endpoint_id="ep_550e8400e29b41d4a716446655440000", # optional endpoint filter
|
|
106
153
|
limit=100
|
|
107
154
|
)
|
|
108
155
|
|
|
109
156
|
for msg in logs.messages:
|
|
110
|
-
print(msg.message_id, msg.last_error)
|
|
157
|
+
print(msg.message_id, msg.last_error, msg.event_type, msg.event_id, msg.is_test)
|
|
111
158
|
```
|
|
112
159
|
|
|
113
160
|
### Get Metrics
|
|
@@ -242,6 +289,17 @@ for rejection in rejections.entries:
|
|
|
242
289
|
print(rejection.reason_code, rejection.reason_detail)
|
|
243
290
|
```
|
|
244
291
|
|
|
292
|
+
## Client Name
|
|
293
|
+
|
|
294
|
+
Pass `client_name` to tag replay, retry and cancel actions in your audit trail. It is sent as the
|
|
295
|
+
`X-Hookbridge-Client` header on every request. It is self-reported (not authenticated), must be
|
|
296
|
+
printable ASCII, and is truncated by the server at 200 bytes. A value with other characters
|
|
297
|
+
(including CR or LF) raises `ValidationError` at construction.
|
|
298
|
+
|
|
299
|
+
```python
|
|
300
|
+
client = HookBridge(api_key="hb_live_xxx", client_name="billing-worker")
|
|
301
|
+
```
|
|
302
|
+
|
|
245
303
|
## Async Usage
|
|
246
304
|
|
|
247
305
|
```python
|
|
@@ -40,6 +40,13 @@ from hookbridge.types import (
|
|
|
40
40
|
DLQMessagesResponse,
|
|
41
41
|
Endpoint,
|
|
42
42
|
EndpointSummary,
|
|
43
|
+
Event,
|
|
44
|
+
EventDetail,
|
|
45
|
+
EventFanoutStatus,
|
|
46
|
+
EventMessage,
|
|
47
|
+
EventSubscriptions,
|
|
48
|
+
EventType,
|
|
49
|
+
EventTypeGroup,
|
|
43
50
|
ExportDirection,
|
|
44
51
|
ExportRecord,
|
|
45
52
|
HMACSignatureEncoding,
|
|
@@ -58,6 +65,8 @@ from hookbridge.types import (
|
|
|
58
65
|
ListEndpointsResponse,
|
|
59
66
|
ListenInboundEndpointResponse,
|
|
60
67
|
ListenMessage,
|
|
68
|
+
ListEventsResponse,
|
|
69
|
+
ListEventTypesResponse,
|
|
61
70
|
ListInboundEndpointsResponse,
|
|
62
71
|
ListMessageActionsResponse,
|
|
63
72
|
LogsResponse,
|
|
@@ -84,6 +93,8 @@ from hookbridge.types import (
|
|
|
84
93
|
PullTimeSeriesBucket,
|
|
85
94
|
PullTimeSeriesMetrics,
|
|
86
95
|
PullTimingBreakdown,
|
|
96
|
+
RecoverJob,
|
|
97
|
+
RecoverJobStatus,
|
|
87
98
|
ReplayableMessageStatus,
|
|
88
99
|
ReplayAllDryRunResponse,
|
|
89
100
|
ReplayAllMessagesResponse,
|
|
@@ -92,19 +103,36 @@ from hookbridge.types import (
|
|
|
92
103
|
ReplayErrorCode,
|
|
93
104
|
ReplayMessageResponse,
|
|
94
105
|
RotateSecretResponse,
|
|
106
|
+
SendTestEventResponse,
|
|
95
107
|
SendWebhookResponse,
|
|
96
108
|
SigningKey,
|
|
109
|
+
StartRecoverResponse,
|
|
97
110
|
Subscription,
|
|
98
111
|
SubscriptionLimits,
|
|
99
112
|
SubscriptionUsage,
|
|
100
113
|
TimeSeriesBucket,
|
|
101
114
|
TimeSeriesMetrics,
|
|
115
|
+
TypedSendResponse,
|
|
102
116
|
UpdateResult,
|
|
103
117
|
UsageHistoryResponse,
|
|
104
118
|
UsageHistoryRow,
|
|
105
119
|
)
|
|
106
120
|
|
|
107
121
|
__all__ = [
|
|
122
|
+
"Event",
|
|
123
|
+
"EventDetail",
|
|
124
|
+
"EventFanoutStatus",
|
|
125
|
+
"EventMessage",
|
|
126
|
+
"EventSubscriptions",
|
|
127
|
+
"EventType",
|
|
128
|
+
"EventTypeGroup",
|
|
129
|
+
"ListEventsResponse",
|
|
130
|
+
"ListEventTypesResponse",
|
|
131
|
+
"RecoverJob",
|
|
132
|
+
"RecoverJobStatus",
|
|
133
|
+
"SendTestEventResponse",
|
|
134
|
+
"StartRecoverResponse",
|
|
135
|
+
"TypedSendResponse",
|
|
108
136
|
"__version__",
|
|
109
137
|
"HookBridge",
|
|
110
138
|
"AsyncHookBridge",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.3.0"
|