hookbridge 2.1.1__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.
Files changed (26) hide show
  1. {hookbridge-2.1.1 → hookbridge-2.3.0}/PKG-INFO +81 -2
  2. {hookbridge-2.1.1 → hookbridge-2.3.0}/README.md +80 -1
  3. {hookbridge-2.1.1 → hookbridge-2.3.0}/hookbridge/__init__.py +40 -2
  4. hookbridge-2.3.0/hookbridge/_version.py +1 -0
  5. {hookbridge-2.1.1 → hookbridge-2.3.0}/hookbridge/client.py +741 -12
  6. {hookbridge-2.1.1 → hookbridge-2.3.0}/hookbridge/errors.py +3 -1
  7. {hookbridge-2.1.1 → hookbridge-2.3.0}/hookbridge/types.py +163 -2
  8. {hookbridge-2.1.1 → hookbridge-2.3.0}/pyproject.toml +1 -1
  9. hookbridge-2.3.0/tests/test_dry_run_actions.py +169 -0
  10. hookbridge-2.3.0/tests/test_event_types.py +714 -0
  11. hookbridge-2.3.0/tests/test_spec_sync_2_3_0.py +179 -0
  12. hookbridge-2.3.0/tests/test_version.py +42 -0
  13. hookbridge-2.1.1/.claude/settings.local.json +0 -8
  14. {hookbridge-2.1.1 → hookbridge-2.3.0}/.gitignore +0 -0
  15. {hookbridge-2.1.1 → hookbridge-2.3.0}/hookbridge/py.typed +0 -0
  16. {hookbridge-2.1.1 → hookbridge-2.3.0}/requirements-dev.txt +0 -0
  17. {hookbridge-2.1.1 → hookbridge-2.3.0}/requirements.txt +0 -0
  18. {hookbridge-2.1.1 → hookbridge-2.3.0}/tests/__init__.py +0 -0
  19. {hookbridge-2.1.1 → hookbridge-2.3.0}/tests/conftest.py +0 -0
  20. {hookbridge-2.1.1 → hookbridge-2.3.0}/tests/test_async_client.py +0 -0
  21. {hookbridge-2.1.1 → hookbridge-2.3.0}/tests/test_client.py +0 -0
  22. {hookbridge-2.1.1 → hookbridge-2.3.0}/tests/test_client_spec_parity.py +0 -0
  23. {hookbridge-2.1.1 → hookbridge-2.3.0}/tests/test_errors.py +0 -0
  24. {hookbridge-2.1.1 → hookbridge-2.3.0}/tests/test_openapi_sync_2026_11.py +0 -0
  25. {hookbridge-2.1.1 → hookbridge-2.3.0}/tests/test_positional_compat.py +0 -0
  26. {hookbridge-2.1.1 → hookbridge-2.3.0}/tests/test_removed_session_only_methods.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: hookbridge
3
- Version: 2.1.1
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
@@ -165,6 +212,27 @@ for msg in dlq.messages:
165
212
  client.replay_from_dlq(msg.message_id)
166
213
  ```
167
214
 
215
+ ### Dry-Run a Bulk Replay
216
+
217
+ ```python
218
+ preview = client.replay_all_messages_dry_run(status="failed_permanent")
219
+ print(f"Would replay {preview.would_replay} messages")
220
+ ```
221
+
222
+ Use `replay_all_inbound_messages_dry_run` for inbound messages.
223
+
224
+ ### List Message Actions
225
+
226
+ ```python
227
+ page = client.list_message_actions(message_id, limit=50)
228
+ for action in page.actions:
229
+ print(action.action, action.via, action.created_at)
230
+ if page.has_more:
231
+ page = client.list_message_actions(message_id, cursor=page.next_cursor)
232
+ ```
233
+
234
+ Use `list_inbound_message_actions` for inbound messages.
235
+
168
236
  ### Manage Retries
169
237
 
170
238
  ```python
@@ -256,6 +324,17 @@ for rejection in rejections.entries:
256
324
  print(rejection.reason_code, rejection.reason_detail)
257
325
  ```
258
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
+
259
338
  ## Async Usage
260
339
 
261
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
@@ -130,6 +177,27 @@ for msg in dlq.messages:
130
177
  client.replay_from_dlq(msg.message_id)
131
178
  ```
132
179
 
180
+ ### Dry-Run a Bulk Replay
181
+
182
+ ```python
183
+ preview = client.replay_all_messages_dry_run(status="failed_permanent")
184
+ print(f"Would replay {preview.would_replay} messages")
185
+ ```
186
+
187
+ Use `replay_all_inbound_messages_dry_run` for inbound messages.
188
+
189
+ ### List Message Actions
190
+
191
+ ```python
192
+ page = client.list_message_actions(message_id, limit=50)
193
+ for action in page.actions:
194
+ print(action.action, action.via, action.created_at)
195
+ if page.has_more:
196
+ page = client.list_message_actions(message_id, cursor=page.next_cursor)
197
+ ```
198
+
199
+ Use `list_inbound_message_actions` for inbound messages.
200
+
133
201
  ### Manage Retries
134
202
 
135
203
  ```python
@@ -221,6 +289,17 @@ for rejection in rejections.entries:
221
289
  print(rejection.reason_code, rejection.reason_detail)
222
290
  ```
223
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
+
224
303
  ## Async Usage
225
304
 
226
305
  ```python
@@ -2,6 +2,7 @@
2
2
  HookBridge SDK for Python.
3
3
  """
4
4
 
5
+ from hookbridge._version import __version__
5
6
  from hookbridge.client import AsyncHookBridge, HookBridge
6
7
  from hookbridge.errors import (
7
8
  AuthenticationError,
@@ -39,6 +40,13 @@ from hookbridge.types import (
39
40
  DLQMessagesResponse,
40
41
  Endpoint,
41
42
  EndpointSummary,
43
+ Event,
44
+ EventDetail,
45
+ EventFanoutStatus,
46
+ EventMessage,
47
+ EventSubscriptions,
48
+ EventType,
49
+ EventTypeGroup,
42
50
  ExportDirection,
43
51
  ExportRecord,
44
52
  HMACSignatureEncoding,
@@ -57,9 +65,15 @@ from hookbridge.types import (
57
65
  ListEndpointsResponse,
58
66
  ListenInboundEndpointResponse,
59
67
  ListenMessage,
68
+ ListEventsResponse,
69
+ ListEventTypesResponse,
60
70
  ListInboundEndpointsResponse,
71
+ ListMessageActionsResponse,
61
72
  LogsResponse,
62
73
  Message,
74
+ MessageAction,
75
+ MessageActionType,
76
+ MessageActionVia,
63
77
  MessageStatus,
64
78
  MessageSummary,
65
79
  Metrics,
@@ -79,28 +93,47 @@ from hookbridge.types import (
79
93
  PullTimeSeriesBucket,
80
94
  PullTimeSeriesMetrics,
81
95
  PullTimingBreakdown,
96
+ RecoverJob,
97
+ RecoverJobStatus,
82
98
  ReplayableMessageStatus,
99
+ ReplayAllDryRunResponse,
83
100
  ReplayAllMessagesResponse,
84
101
  ReplayBatchMessagesResponse,
85
102
  ReplayBatchResult,
86
103
  ReplayErrorCode,
87
104
  ReplayMessageResponse,
88
105
  RotateSecretResponse,
106
+ SendTestEventResponse,
89
107
  SendWebhookResponse,
90
108
  SigningKey,
109
+ StartRecoverResponse,
91
110
  Subscription,
92
111
  SubscriptionLimits,
93
112
  SubscriptionUsage,
94
113
  TimeSeriesBucket,
95
114
  TimeSeriesMetrics,
115
+ TypedSendResponse,
96
116
  UpdateResult,
97
117
  UsageHistoryResponse,
98
118
  UsageHistoryRow,
99
119
  )
100
120
 
101
- __version__ = "2.1.1"
102
-
103
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",
136
+ "__version__",
104
137
  "HookBridge",
105
138
  "AsyncHookBridge",
106
139
  "APIKeyInfo",
@@ -166,7 +199,12 @@ __all__ = [
166
199
  "PullTimeSeriesBucket",
167
200
  "PullTimeSeriesMetrics",
168
201
  "PullTimingBreakdown",
202
+ "ReplayAllDryRunResponse",
169
203
  "ReplayAllMessagesResponse",
204
+ "ListMessageActionsResponse",
205
+ "MessageAction",
206
+ "MessageActionType",
207
+ "MessageActionVia",
170
208
  "ReplayBatchMessagesResponse",
171
209
  "ReplayBatchResult",
172
210
  "ReplayErrorCode",
@@ -0,0 +1 @@
1
+ __version__ = "2.3.0"