hookbridge 2.2.0__tar.gz → 2.4.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.
Files changed (30) hide show
  1. hookbridge-2.4.0/CHANGELOG.md +15 -0
  2. {hookbridge-2.2.0 → hookbridge-2.4.0}/PKG-INFO +60 -2
  3. {hookbridge-2.2.0 → hookbridge-2.4.0}/README.md +59 -1
  4. {hookbridge-2.2.0 → hookbridge-2.4.0}/hookbridge/__init__.py +28 -0
  5. hookbridge-2.4.0/hookbridge/_version.py +1 -0
  6. {hookbridge-2.2.0 → hookbridge-2.4.0}/hookbridge/client.py +792 -63
  7. {hookbridge-2.2.0 → hookbridge-2.4.0}/hookbridge/errors.py +3 -1
  8. {hookbridge-2.2.0 → hookbridge-2.4.0}/hookbridge/types.py +140 -2
  9. {hookbridge-2.2.0 → hookbridge-2.4.0}/pyproject.toml +1 -1
  10. hookbridge-2.4.0/tests/test_additive_2_4_0.py +472 -0
  11. hookbridge-2.4.0/tests/test_event_types.py +714 -0
  12. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/test_positional_compat.py +59 -3
  13. hookbridge-2.4.0/tests/test_pull_contract.py +224 -0
  14. hookbridge-2.4.0/tests/test_spec_sync_2_3_0.py +179 -0
  15. hookbridge-2.2.0/hookbridge/_version.py +0 -1
  16. {hookbridge-2.2.0 → hookbridge-2.4.0}/.claude/settings.local.json +0 -0
  17. {hookbridge-2.2.0 → hookbridge-2.4.0}/.gitignore +0 -0
  18. {hookbridge-2.2.0 → hookbridge-2.4.0}/hookbridge/py.typed +0 -0
  19. {hookbridge-2.2.0 → hookbridge-2.4.0}/requirements-dev.txt +0 -0
  20. {hookbridge-2.2.0 → hookbridge-2.4.0}/requirements.txt +0 -0
  21. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/__init__.py +0 -0
  22. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/conftest.py +0 -0
  23. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/test_async_client.py +0 -0
  24. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/test_client.py +0 -0
  25. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/test_client_spec_parity.py +0 -0
  26. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/test_dry_run_actions.py +0 -0
  27. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/test_errors.py +0 -0
  28. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/test_openapi_sync_2026_11.py +0 -0
  29. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/test_removed_session_only_methods.py +0 -0
  30. {hookbridge-2.2.0 → hookbridge-2.4.0}/tests/test_version.py +0 -0
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## 2.4.0 (2026-11-27)
4
+
5
+ ### Added
6
+ - `get_metrics(window, *, endpoint_id=...)` filters aggregated metrics by endpoint (sync and async).
7
+ - Per-call `client_name=` on `replay`, `cancel_retry`, `retry_now`, `replay_all_messages`, `replay_batch_messages`, `replay_from_dlq`, `replay_inbound_message`, `replay_all_inbound_messages` and `replay_batch_inbound_messages`. It sets `X-Hookbridge-Client` for that call and wins over the client-level `client_name`. The same printable-ASCII validation applies.
8
+ - `ReplayMessageResponse.message` and `ReplayAllMessagesResponse.message` carry the top-level `message` the server sends.
9
+ - `PullLogEntry.deleted_at`, `Message.failed_at`, `InboundMetrics.avg_queue_wait_ms`, and `UpdateResult.subscriptions` (all optional, default `None`).
10
+
11
+ ### Fixed
12
+ - `replay`, `cancel_retry`, `retry_now` and `replay_from_dlq` now return a `ReplayMessageResponse` instead of `None`. On an empty or 204 body they still do not raise: `message_id` is the ID you passed and `status` is `""`.
13
+ - `update_endpoint` now returns an `UpdateResult`; `delete_endpoint` and `delete_api_key` now return a `DeleteResult` (`delete_api_key` has `id=None`, as the server sends only `deleted`). On an empty body they return `updated=True` / `deleted=True` without raising.
14
+ - `update_pull_endpoint` no longer raises `KeyError` when the server could not re-fetch the endpoint after the update and sent back only the `id`; it now falls back to `get_pull_endpoint`.
15
+ - Timestamps with 1 to 9 fractional digits (Go RFC3339Nano trims trailing zeros) now parse on Python 3.9 and 3.10.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: hookbridge
3
- Version: 2.2.0
3
+ Version: 2.4.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.4.0"