hookbridge 2.3.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/.claude/settings.local.json +8 -0
  2. hookbridge-2.4.0/CHANGELOG.md +15 -0
  3. {hookbridge-2.3.0 → hookbridge-2.4.0}/PKG-INFO +1 -1
  4. hookbridge-2.4.0/hookbridge/_version.py +1 -0
  5. {hookbridge-2.3.0 → hookbridge-2.4.0}/hookbridge/client.py +199 -57
  6. {hookbridge-2.3.0 → hookbridge-2.4.0}/hookbridge/types.py +6 -0
  7. {hookbridge-2.3.0 → hookbridge-2.4.0}/pyproject.toml +1 -1
  8. hookbridge-2.4.0/tests/test_additive_2_4_0.py +472 -0
  9. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_positional_compat.py +59 -3
  10. hookbridge-2.4.0/tests/test_pull_contract.py +224 -0
  11. hookbridge-2.3.0/hookbridge/_version.py +0 -1
  12. {hookbridge-2.3.0 → hookbridge-2.4.0}/.gitignore +0 -0
  13. {hookbridge-2.3.0 → hookbridge-2.4.0}/README.md +0 -0
  14. {hookbridge-2.3.0 → hookbridge-2.4.0}/hookbridge/__init__.py +0 -0
  15. {hookbridge-2.3.0 → hookbridge-2.4.0}/hookbridge/errors.py +0 -0
  16. {hookbridge-2.3.0 → hookbridge-2.4.0}/hookbridge/py.typed +0 -0
  17. {hookbridge-2.3.0 → hookbridge-2.4.0}/requirements-dev.txt +0 -0
  18. {hookbridge-2.3.0 → hookbridge-2.4.0}/requirements.txt +0 -0
  19. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/__init__.py +0 -0
  20. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/conftest.py +0 -0
  21. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_async_client.py +0 -0
  22. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_client.py +0 -0
  23. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_client_spec_parity.py +0 -0
  24. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_dry_run_actions.py +0 -0
  25. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_errors.py +0 -0
  26. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_event_types.py +0 -0
  27. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_openapi_sync_2026_11.py +0 -0
  28. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_removed_session_only_methods.py +0 -0
  29. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_spec_sync_2_3_0.py +0 -0
  30. {hookbridge-2.3.0 → hookbridge-2.4.0}/tests/test_version.py +0 -0
@@ -0,0 +1,8 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(mypy hookbridge:*)",
5
+ "Bash(ruff check:*)"
6
+ ]
7
+ }
8
+ }
@@ -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.3.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
@@ -0,0 +1 @@
1
+ __version__ = "2.4.0"
@@ -3,6 +3,7 @@ HookBridge SDK clients.
3
3
  """
4
4
 
5
5
  import os
6
+ import re
6
7
  import time
7
8
  from datetime import date, datetime
8
9
  from typing import Any, Optional, Union
@@ -124,9 +125,13 @@ DEFAULT_TIMEOUT = 30.0
124
125
  DEFAULT_RETRIES = 3
125
126
 
126
127
 
128
+ _FRACTION = re.compile(r"\.(\d+)")
129
+
130
+
127
131
  def _parse_datetime(value: str) -> datetime:
128
132
  if value.endswith("Z"):
129
133
  value = value[:-1] + "+00:00"
134
+ value = _FRACTION.sub(lambda m: "." + m.group(1)[:6].ljust(6, "0"), value, count=1)
130
135
  return datetime.fromisoformat(value)
131
136
 
132
137
 
@@ -195,6 +200,7 @@ def _parse_message(data: dict[str, Any]) -> Message:
195
200
  event_type=data.get("event_type"),
196
201
  event_id=data.get("event_id"),
197
202
  is_test=data.get("is_test"),
203
+ failed_at=_parse_datetime(data["failed_at"]) if data.get("failed_at") else None,
198
204
  )
199
205
 
200
206
 
@@ -344,16 +350,41 @@ def _parse_endpoint_summary(data: dict[str, Any]) -> EndpointSummary:
344
350
  )
345
351
 
346
352
 
347
- def _parse_replay_all_messages(data: dict[str, Any]) -> ReplayAllMessagesResponse:
353
+ def _parse_replay_all_messages(response: dict[str, Any]) -> ReplayAllMessagesResponse:
354
+ data = response["data"]
348
355
  return ReplayAllMessagesResponse(
349
356
  replayed=data["replayed"],
350
357
  failed=data["failed"],
351
358
  stuck=data["stuck"],
352
359
  replayed_message_ids=data.get("replayed_message_ids", []),
353
360
  stuck_message_ids=data.get("stuck_message_ids", []),
361
+ message=response.get("message"),
354
362
  )
355
363
 
356
364
 
365
+ def _parse_replay_message(response: dict[str, Any], message_id: str) -> ReplayMessageResponse:
366
+ data = response.get("data") or {}
367
+ return ReplayMessageResponse(
368
+ message_id=data.get("message_id", message_id),
369
+ status=data.get("status", ""),
370
+ message=response.get("message"),
371
+ )
372
+
373
+
374
+ def _parse_update_result(response: dict[str, Any], endpoint_id: str) -> UpdateResult:
375
+ data = response.get("data") or {}
376
+ return UpdateResult(
377
+ id=data.get("id", endpoint_id),
378
+ updated=data.get("updated", True),
379
+ subscriptions=_parse_subscriptions(data.get("subscriptions")),
380
+ )
381
+
382
+
383
+ def _parse_delete_result(response: dict[str, Any], resource_id: Optional[str]) -> DeleteResult:
384
+ data = response.get("data") or {}
385
+ return DeleteResult(deleted=data.get("deleted", True), id=data.get("id", resource_id))
386
+
387
+
357
388
  def _parse_replay_all_dry_run(data: dict[str, Any]) -> ReplayAllDryRunResponse:
358
389
  return ReplayAllDryRunResponse(would_replay=data["would_replay"])
359
390
 
@@ -592,6 +623,7 @@ def _parse_pull_log_entry(data: dict[str, Any]) -> PullLogEntry:
592
623
  time_to_ack_ms=data["timing"].get("time_to_ack_ms"),
593
624
  total_lifecycle_ms=data["timing"].get("total_lifecycle_ms"),
594
625
  ) if data.get("timing") else None,
626
+ deleted_at=_parse_datetime(data["deleted_at"]) if data.get("deleted_at") else None,
595
627
  )
596
628
 
597
629
 
@@ -638,6 +670,7 @@ def _parse_inbound_metrics(data: dict[str, Any]) -> InboundMetrics:
638
670
  success_rate=data["success_rate"],
639
671
  avg_latency_ms=data["avg_latency_ms"],
640
672
  avg_delivery_time_ms=data["avg_delivery_time_ms"],
673
+ avg_queue_wait_ms=data.get("avg_queue_wait_ms"),
641
674
  )
642
675
 
643
676
 
@@ -942,6 +975,14 @@ def _typed_send_body(
942
975
  return body
943
976
 
944
977
 
978
+ def _client_name_headers(client_name: Optional[str]) -> Optional[dict[str, str]]:
979
+ if not client_name:
980
+ return None
981
+ if any(not 0x20 <= ord(ch) <= 0x7E for ch in client_name):
982
+ raise ValidationError("client_name must contain only printable ASCII characters")
983
+ return {"X-Hookbridge-Client": client_name}
984
+
985
+
945
986
  def _build_common_headers(api_key: str, client_name: Optional[str]) -> dict[str, str]:
946
987
  headers = {
947
988
  "Authorization": f"Bearer {api_key}",
@@ -949,10 +990,7 @@ def _build_common_headers(api_key: str, client_name: Optional[str]) -> dict[str,
949
990
  "Accept": "application/json",
950
991
  "User-Agent": f"hookbridge-python/{__version__}",
951
992
  }
952
- if client_name:
953
- if any(not 0x20 <= ord(ch) <= 0x7E for ch in client_name):
954
- raise ValidationError("client_name must contain only printable ASCII characters")
955
- headers["X-Hookbridge-Client"] = client_name
993
+ headers.update(_client_name_headers(client_name) or {})
956
994
  return headers
957
995
 
958
996
 
@@ -1049,14 +1087,31 @@ class HookBridge:
1049
1087
  self._request("GET", f"/v1/messages/{message_id}/attempts")
1050
1088
  )
1051
1089
 
1052
- def replay(self, message_id: str) -> None:
1053
- self._request("POST", f"/v1/messages/{message_id}/replay")
1090
+ def replay(
1091
+ self, message_id: str, *, client_name: Optional[str] = None
1092
+ ) -> ReplayMessageResponse:
1093
+ response = self._request(
1094
+ "POST", f"/v1/messages/{message_id}/replay", headers=_client_name_headers(client_name)
1095
+ )
1096
+ return _parse_replay_message(response, message_id)
1054
1097
 
1055
- def cancel_retry(self, message_id: str) -> None:
1056
- self._request("POST", f"/v1/messages/{message_id}/cancel")
1098
+ def cancel_retry(
1099
+ self, message_id: str, *, client_name: Optional[str] = None
1100
+ ) -> ReplayMessageResponse:
1101
+ response = self._request(
1102
+ "POST", f"/v1/messages/{message_id}/cancel", headers=_client_name_headers(client_name)
1103
+ )
1104
+ return _parse_replay_message(response, message_id)
1057
1105
 
1058
- def retry_now(self, message_id: str) -> None:
1059
- self._request("POST", f"/v1/messages/{message_id}/retry-now")
1106
+ def retry_now(
1107
+ self, message_id: str, *, client_name: Optional[str] = None
1108
+ ) -> ReplayMessageResponse:
1109
+ response = self._request(
1110
+ "POST",
1111
+ f"/v1/messages/{message_id}/retry-now",
1112
+ headers=_client_name_headers(client_name),
1113
+ )
1114
+ return _parse_replay_message(response, message_id)
1060
1115
 
1061
1116
  def replay_all_messages(
1062
1117
  self,
@@ -1064,12 +1119,15 @@ class HookBridge:
1064
1119
  status: ReplayableMessageStatus,
1065
1120
  endpoint_id: Optional[str] = None,
1066
1121
  limit: Optional[int] = None,
1122
+ client_name: Optional[str] = None,
1067
1123
  ) -> ReplayAllMessagesResponse:
1068
1124
  path = _with_query(
1069
1125
  "/v1/messages/replay-all",
1070
1126
  {"status": status, "endpoint_id": endpoint_id, "limit": limit},
1071
1127
  )
1072
- return _parse_replay_all_messages(self._request("POST", path)["data"])
1128
+ return _parse_replay_all_messages(
1129
+ self._request("POST", path, headers=_client_name_headers(client_name))
1130
+ )
1073
1131
 
1074
1132
  def replay_all_messages_dry_run(
1075
1133
  self,
@@ -1097,9 +1155,14 @@ class HookBridge:
1097
1155
  )
1098
1156
  return _parse_message_actions(self._request("GET", path))
1099
1157
 
1100
- def replay_batch_messages(self, message_ids: list[str]) -> ReplayBatchMessagesResponse:
1158
+ def replay_batch_messages(
1159
+ self, message_ids: list[str], *, client_name: Optional[str] = None
1160
+ ) -> ReplayBatchMessagesResponse:
1101
1161
  response = self._request(
1102
- "POST", "/v1/messages/replay-batch", json={"message_ids": message_ids}
1162
+ "POST",
1163
+ "/v1/messages/replay-batch",
1164
+ json={"message_ids": message_ids},
1165
+ headers=_client_name_headers(client_name),
1103
1166
  )
1104
1167
  return _parse_replay_batch_messages(response["data"])
1105
1168
 
@@ -1134,8 +1197,11 @@ class HookBridge:
1134
1197
  next_cursor=meta.get("next_cursor"),
1135
1198
  )
1136
1199
 
1137
- def get_metrics(self, window: MetricsWindow = "24h") -> Metrics:
1138
- return _parse_metrics(self._request("GET", f"/v1/metrics?window={window}")["data"])
1200
+ def get_metrics(
1201
+ self, window: MetricsWindow = "24h", *, endpoint_id: Optional[str] = None
1202
+ ) -> Metrics:
1203
+ path = _with_query("/v1/metrics", {"window": window, "endpoint_id": endpoint_id})
1204
+ return _parse_metrics(self._request("GET", path)["data"])
1139
1205
 
1140
1206
  def get_timeseries_metrics(
1141
1207
  self, window: MetricsWindow = "24h", *, endpoint_id: Optional[str] = None
@@ -1158,8 +1224,13 @@ class HookBridge:
1158
1224
  next_cursor=data.get("next_cursor"),
1159
1225
  )
1160
1226
 
1161
- def replay_from_dlq(self, message_id: str) -> None:
1162
- self._request("POST", f"/v1/dlq/replay/{message_id}")
1227
+ def replay_from_dlq(
1228
+ self, message_id: str, *, client_name: Optional[str] = None
1229
+ ) -> ReplayMessageResponse:
1230
+ response = self._request(
1231
+ "POST", f"/v1/dlq/replay/{message_id}", headers=_client_name_headers(client_name)
1232
+ )
1233
+ return _parse_replay_message(response, message_id)
1163
1234
 
1164
1235
  def list_api_keys(self) -> list[APIKeyInfo]:
1165
1236
  return [_parse_api_key_info(item) for item in self._request("GET", "/v1/api-keys")["data"]]
@@ -1179,8 +1250,9 @@ class HookBridge:
1179
1250
  created_at=_parse_datetime(data["created_at"]),
1180
1251
  )
1181
1252
 
1182
- def delete_api_key(self, key_id: str) -> None:
1183
- self._request("DELETE", f"/v1/api-keys/{key_id}")
1253
+ def delete_api_key(self, key_id: str) -> DeleteResult:
1254
+ response = self._request("DELETE", f"/v1/api-keys/{key_id}")
1255
+ return _parse_delete_result(response, None)
1184
1256
 
1185
1257
  def create_endpoint(
1186
1258
  self,
@@ -1255,7 +1327,7 @@ class HookBridge:
1255
1327
  burst: Optional[int] = None,
1256
1328
  headers: Optional[dict[str, str]] = None,
1257
1329
  subscriptions: Optional[EventSubscriptions] = None,
1258
- ) -> None:
1330
+ ) -> UpdateResult:
1259
1331
  body: dict[str, Any] = {}
1260
1332
  if url is not None:
1261
1333
  body["url"] = url
@@ -1269,10 +1341,12 @@ class HookBridge:
1269
1341
  body["headers"] = headers
1270
1342
  if subscriptions is not None:
1271
1343
  body["subscriptions"] = _subscriptions_body(subscriptions)
1272
- self._request("PATCH", f"/v1/endpoints/{endpoint_id}", json=body)
1344
+ response = self._request("PATCH", f"/v1/endpoints/{endpoint_id}", json=body)
1345
+ return _parse_update_result(response, endpoint_id)
1273
1346
 
1274
- def delete_endpoint(self, endpoint_id: str) -> None:
1275
- self._request("DELETE", f"/v1/endpoints/{endpoint_id}")
1347
+ def delete_endpoint(self, endpoint_id: str) -> DeleteResult:
1348
+ response = self._request("DELETE", f"/v1/endpoints/{endpoint_id}")
1349
+ return _parse_delete_result(response, endpoint_id)
1276
1350
 
1277
1351
  def pause_endpoint(self, endpoint_id: str) -> PauseState:
1278
1352
  data = self._request("POST", f"/v1/endpoints/{endpoint_id}/pause")["data"]
@@ -1376,6 +1450,8 @@ class HookBridge:
1376
1450
  def update_pull_endpoint(self, endpoint_id: str, **kwargs: Any) -> PullEndpoint:
1377
1451
  body = {key: value for key, value in kwargs.items() if value is not None}
1378
1452
  data = self._request("PATCH", f"/v1/pull-endpoints/{endpoint_id}", json=body)["data"]
1453
+ if "ingest_url" not in data:
1454
+ return self.get_pull_endpoint(endpoint_id)
1379
1455
  return _parse_pull_endpoint(data)
1380
1456
 
1381
1457
  def delete_pull_endpoint(self, endpoint_id: str) -> DeleteResult:
@@ -1669,9 +1745,15 @@ class HookBridge:
1669
1745
  self._request("GET", f"/v1/inbound-messages/{message_id}/attempts")
1670
1746
  )
1671
1747
 
1672
- def replay_inbound_message(self, message_id: str) -> ReplayMessageResponse:
1673
- data = self._request("POST", f"/v1/inbound-messages/{message_id}/replay")["data"]
1674
- return ReplayMessageResponse(message_id=data["message_id"], status=data["status"])
1748
+ def replay_inbound_message(
1749
+ self, message_id: str, *, client_name: Optional[str] = None
1750
+ ) -> ReplayMessageResponse:
1751
+ response = self._request(
1752
+ "POST",
1753
+ f"/v1/inbound-messages/{message_id}/replay",
1754
+ headers=_client_name_headers(client_name),
1755
+ )
1756
+ return _parse_replay_message(response, message_id)
1675
1757
 
1676
1758
  def replay_all_inbound_messages(
1677
1759
  self,
@@ -1679,6 +1761,7 @@ class HookBridge:
1679
1761
  status: ReplayableMessageStatus,
1680
1762
  inbound_endpoint_id: Optional[str] = None,
1681
1763
  limit: Optional[int] = None,
1764
+ client_name: Optional[str] = None,
1682
1765
  ) -> ReplayAllMessagesResponse:
1683
1766
  path = _with_query(
1684
1767
  "/v1/inbound-messages/replay-all",
@@ -1688,7 +1771,9 @@ class HookBridge:
1688
1771
  "limit": limit,
1689
1772
  },
1690
1773
  )
1691
- return _parse_replay_all_messages(self._request("POST", path)["data"])
1774
+ return _parse_replay_all_messages(
1775
+ self._request("POST", path, headers=_client_name_headers(client_name))
1776
+ )
1692
1777
 
1693
1778
  def replay_all_inbound_messages_dry_run(
1694
1779
  self,
@@ -1721,9 +1806,14 @@ class HookBridge:
1721
1806
  )
1722
1807
  return _parse_message_actions(self._request("GET", path))
1723
1808
 
1724
- def replay_batch_inbound_messages(self, message_ids: list[str]) -> ReplayBatchMessagesResponse:
1809
+ def replay_batch_inbound_messages(
1810
+ self, message_ids: list[str], *, client_name: Optional[str] = None
1811
+ ) -> ReplayBatchMessagesResponse:
1725
1812
  response = self._request(
1726
- "POST", "/v1/inbound-messages/replay-batch", json={"message_ids": message_ids}
1813
+ "POST",
1814
+ "/v1/inbound-messages/replay-batch",
1815
+ json={"message_ids": message_ids},
1816
+ headers=_client_name_headers(client_name),
1727
1817
  )
1728
1818
  return _parse_replay_batch_messages(response["data"])
1729
1819
 
@@ -2171,6 +2261,7 @@ class HookBridge:
2171
2261
  path: str,
2172
2262
  *,
2173
2263
  json: Optional[dict[str, Any]] = None,
2264
+ headers: Optional[dict[str, str]] = None,
2174
2265
  use_send_client: bool = False,
2175
2266
  allow_redirect: bool = False,
2176
2267
  ) -> dict[str, Any]:
@@ -2179,7 +2270,7 @@ class HookBridge:
2179
2270
 
2180
2271
  for attempt in range(self._retries + 1):
2181
2272
  try:
2182
- response = client.request(method, path, json=json)
2273
+ response = client.request(method, path, json=json, headers=headers)
2183
2274
  if allow_redirect and response.status_code in {301, 302, 303, 307, 308}:
2184
2275
  location = response.headers.get("Location")
2185
2276
  if not location:
@@ -2271,14 +2362,31 @@ class AsyncHookBridge:
2271
2362
  await self._request("GET", f"/v1/messages/{message_id}/attempts")
2272
2363
  )
2273
2364
 
2274
- async def replay(self, message_id: str) -> None:
2275
- await self._request("POST", f"/v1/messages/{message_id}/replay")
2365
+ async def replay(
2366
+ self, message_id: str, *, client_name: Optional[str] = None
2367
+ ) -> ReplayMessageResponse:
2368
+ response = await self._request(
2369
+ "POST", f"/v1/messages/{message_id}/replay", headers=_client_name_headers(client_name)
2370
+ )
2371
+ return _parse_replay_message(response, message_id)
2276
2372
 
2277
- async def cancel_retry(self, message_id: str) -> None:
2278
- await self._request("POST", f"/v1/messages/{message_id}/cancel")
2373
+ async def cancel_retry(
2374
+ self, message_id: str, *, client_name: Optional[str] = None
2375
+ ) -> ReplayMessageResponse:
2376
+ response = await self._request(
2377
+ "POST", f"/v1/messages/{message_id}/cancel", headers=_client_name_headers(client_name)
2378
+ )
2379
+ return _parse_replay_message(response, message_id)
2279
2380
 
2280
- async def retry_now(self, message_id: str) -> None:
2281
- await self._request("POST", f"/v1/messages/{message_id}/retry-now")
2381
+ async def retry_now(
2382
+ self, message_id: str, *, client_name: Optional[str] = None
2383
+ ) -> ReplayMessageResponse:
2384
+ response = await self._request(
2385
+ "POST",
2386
+ f"/v1/messages/{message_id}/retry-now",
2387
+ headers=_client_name_headers(client_name),
2388
+ )
2389
+ return _parse_replay_message(response, message_id)
2282
2390
 
2283
2391
  async def replay_all_messages(
2284
2392
  self,
@@ -2286,12 +2394,15 @@ class AsyncHookBridge:
2286
2394
  status: ReplayableMessageStatus,
2287
2395
  endpoint_id: Optional[str] = None,
2288
2396
  limit: Optional[int] = None,
2397
+ client_name: Optional[str] = None,
2289
2398
  ) -> ReplayAllMessagesResponse:
2290
2399
  path = _with_query(
2291
2400
  "/v1/messages/replay-all",
2292
2401
  {"status": status, "endpoint_id": endpoint_id, "limit": limit},
2293
2402
  )
2294
- return _parse_replay_all_messages((await self._request("POST", path))["data"])
2403
+ return _parse_replay_all_messages(
2404
+ await self._request("POST", path, headers=_client_name_headers(client_name))
2405
+ )
2295
2406
 
2296
2407
  async def replay_all_messages_dry_run(
2297
2408
  self,
@@ -2319,9 +2430,14 @@ class AsyncHookBridge:
2319
2430
  )
2320
2431
  return _parse_message_actions(await self._request("GET", path))
2321
2432
 
2322
- async def replay_batch_messages(self, message_ids: list[str]) -> ReplayBatchMessagesResponse:
2433
+ async def replay_batch_messages(
2434
+ self, message_ids: list[str], *, client_name: Optional[str] = None
2435
+ ) -> ReplayBatchMessagesResponse:
2323
2436
  response = await self._request(
2324
- "POST", "/v1/messages/replay-batch", json={"message_ids": message_ids}
2437
+ "POST",
2438
+ "/v1/messages/replay-batch",
2439
+ json={"message_ids": message_ids},
2440
+ headers=_client_name_headers(client_name),
2325
2441
  )
2326
2442
  return _parse_replay_batch_messages(response["data"])
2327
2443
 
@@ -2356,8 +2472,11 @@ class AsyncHookBridge:
2356
2472
  next_cursor=meta.get("next_cursor"),
2357
2473
  )
2358
2474
 
2359
- async def get_metrics(self, window: MetricsWindow = "24h") -> Metrics:
2360
- return _parse_metrics((await self._request("GET", f"/v1/metrics?window={window}"))["data"])
2475
+ async def get_metrics(
2476
+ self, window: MetricsWindow = "24h", *, endpoint_id: Optional[str] = None
2477
+ ) -> Metrics:
2478
+ path = _with_query("/v1/metrics", {"window": window, "endpoint_id": endpoint_id})
2479
+ return _parse_metrics((await self._request("GET", path))["data"])
2361
2480
 
2362
2481
  async def get_timeseries_metrics(
2363
2482
  self, window: MetricsWindow = "24h", *, endpoint_id: Optional[str] = None
@@ -2381,8 +2500,13 @@ class AsyncHookBridge:
2381
2500
  next_cursor=data.get("next_cursor"),
2382
2501
  )
2383
2502
 
2384
- async def replay_from_dlq(self, message_id: str) -> None:
2385
- await self._request("POST", f"/v1/dlq/replay/{message_id}")
2503
+ async def replay_from_dlq(
2504
+ self, message_id: str, *, client_name: Optional[str] = None
2505
+ ) -> ReplayMessageResponse:
2506
+ response = await self._request(
2507
+ "POST", f"/v1/dlq/replay/{message_id}", headers=_client_name_headers(client_name)
2508
+ )
2509
+ return _parse_replay_message(response, message_id)
2386
2510
 
2387
2511
  async def list_api_keys(self) -> list[APIKeyInfo]:
2388
2512
  response = await self._request("GET", "/v1/api-keys")
@@ -2403,8 +2527,9 @@ class AsyncHookBridge:
2403
2527
  created_at=_parse_datetime(data["created_at"]),
2404
2528
  )
2405
2529
 
2406
- async def delete_api_key(self, key_id: str) -> None:
2407
- await self._request("DELETE", f"/v1/api-keys/{key_id}")
2530
+ async def delete_api_key(self, key_id: str) -> DeleteResult:
2531
+ response = await self._request("DELETE", f"/v1/api-keys/{key_id}")
2532
+ return _parse_delete_result(response, None)
2408
2533
 
2409
2534
  async def create_endpoint(
2410
2535
  self,
@@ -2480,7 +2605,7 @@ class AsyncHookBridge:
2480
2605
  burst: Optional[int] = None,
2481
2606
  headers: Optional[dict[str, str]] = None,
2482
2607
  subscriptions: Optional[EventSubscriptions] = None,
2483
- ) -> None:
2608
+ ) -> UpdateResult:
2484
2609
  body: dict[str, Any] = {}
2485
2610
  if url is not None:
2486
2611
  body["url"] = url
@@ -2494,10 +2619,12 @@ class AsyncHookBridge:
2494
2619
  body["headers"] = headers
2495
2620
  if subscriptions is not None:
2496
2621
  body["subscriptions"] = _subscriptions_body(subscriptions)
2497
- await self._request("PATCH", f"/v1/endpoints/{endpoint_id}", json=body)
2622
+ response = await self._request("PATCH", f"/v1/endpoints/{endpoint_id}", json=body)
2623
+ return _parse_update_result(response, endpoint_id)
2498
2624
 
2499
- async def delete_endpoint(self, endpoint_id: str) -> None:
2500
- await self._request("DELETE", f"/v1/endpoints/{endpoint_id}")
2625
+ async def delete_endpoint(self, endpoint_id: str) -> DeleteResult:
2626
+ response = await self._request("DELETE", f"/v1/endpoints/{endpoint_id}")
2627
+ return _parse_delete_result(response, endpoint_id)
2501
2628
 
2502
2629
  async def pause_endpoint(self, endpoint_id: str) -> PauseState:
2503
2630
  data = (await self._request("POST", f"/v1/endpoints/{endpoint_id}/pause"))["data"]
@@ -2634,6 +2761,8 @@ class AsyncHookBridge:
2634
2761
  data = (
2635
2762
  await self._request("PATCH", f"/v1/pull-endpoints/{endpoint_id}", json=body)
2636
2763
  )["data"]
2764
+ if "ingest_url" not in data:
2765
+ return await self.get_pull_endpoint(endpoint_id)
2637
2766
  return _parse_pull_endpoint(data)
2638
2767
 
2639
2768
  async def delete_pull_endpoint(self, endpoint_id: str) -> DeleteResult:
@@ -2906,9 +3035,15 @@ class AsyncHookBridge:
2906
3035
  await self._request("GET", f"/v1/inbound-messages/{message_id}/attempts")
2907
3036
  )
2908
3037
 
2909
- async def replay_inbound_message(self, message_id: str) -> ReplayMessageResponse:
2910
- data = (await self._request("POST", f"/v1/inbound-messages/{message_id}/replay"))["data"]
2911
- return ReplayMessageResponse(message_id=data["message_id"], status=data["status"])
3038
+ async def replay_inbound_message(
3039
+ self, message_id: str, *, client_name: Optional[str] = None
3040
+ ) -> ReplayMessageResponse:
3041
+ response = await self._request(
3042
+ "POST",
3043
+ f"/v1/inbound-messages/{message_id}/replay",
3044
+ headers=_client_name_headers(client_name),
3045
+ )
3046
+ return _parse_replay_message(response, message_id)
2912
3047
 
2913
3048
  async def replay_all_inbound_messages(
2914
3049
  self,
@@ -2916,6 +3051,7 @@ class AsyncHookBridge:
2916
3051
  status: ReplayableMessageStatus,
2917
3052
  inbound_endpoint_id: Optional[str] = None,
2918
3053
  limit: Optional[int] = None,
3054
+ client_name: Optional[str] = None,
2919
3055
  ) -> ReplayAllMessagesResponse:
2920
3056
  path = _with_query(
2921
3057
  "/v1/inbound-messages/replay-all",
@@ -2925,7 +3061,9 @@ class AsyncHookBridge:
2925
3061
  "limit": limit,
2926
3062
  },
2927
3063
  )
2928
- return _parse_replay_all_messages((await self._request("POST", path))["data"])
3064
+ return _parse_replay_all_messages(
3065
+ await self._request("POST", path, headers=_client_name_headers(client_name))
3066
+ )
2929
3067
 
2930
3068
  async def replay_all_inbound_messages_dry_run(
2931
3069
  self,
@@ -2959,10 +3097,13 @@ class AsyncHookBridge:
2959
3097
  return _parse_message_actions(await self._request("GET", path))
2960
3098
 
2961
3099
  async def replay_batch_inbound_messages(
2962
- self, message_ids: list[str]
3100
+ self, message_ids: list[str], *, client_name: Optional[str] = None
2963
3101
  ) -> ReplayBatchMessagesResponse:
2964
3102
  response = await self._request(
2965
- "POST", "/v1/inbound-messages/replay-batch", json={"message_ids": message_ids}
3103
+ "POST",
3104
+ "/v1/inbound-messages/replay-batch",
3105
+ json={"message_ids": message_ids},
3106
+ headers=_client_name_headers(client_name),
2966
3107
  )
2967
3108
  return _parse_replay_batch_messages(response["data"])
2968
3109
 
@@ -3425,6 +3566,7 @@ class AsyncHookBridge:
3425
3566
  path: str,
3426
3567
  *,
3427
3568
  json: Optional[dict[str, Any]] = None,
3569
+ headers: Optional[dict[str, str]] = None,
3428
3570
  use_send_client: bool = False,
3429
3571
  allow_redirect: bool = False,
3430
3572
  ) -> dict[str, Any]:
@@ -3433,7 +3575,7 @@ class AsyncHookBridge:
3433
3575
 
3434
3576
  for attempt in range(self._retries + 1):
3435
3577
  try:
3436
- response = await client.request(method, path, json=json)
3578
+ response = await client.request(method, path, json=json, headers=headers)
3437
3579
  if allow_redirect and response.status_code in {301, 302, 303, 307, 308}:
3438
3580
  location = response.headers.get("Location")
3439
3581
  if not location:
@@ -30,6 +30,7 @@ class SendWebhookResponse:
30
30
  class ReplayMessageResponse:
31
31
  message_id: str
32
32
  status: str
33
+ message: Optional[str] = None
33
34
 
34
35
 
35
36
  @dataclass(frozen=True)
@@ -62,6 +63,7 @@ class Message:
62
63
  event_type: Optional[str] = None
63
64
  event_id: Optional[str] = None
64
65
  is_test: Optional[bool] = None
66
+ failed_at: Optional[datetime] = None
65
67
 
66
68
 
67
69
  @dataclass(frozen=True)
@@ -123,6 +125,7 @@ class InboundMetrics:
123
125
  success_rate: float
124
126
  avg_latency_ms: int
125
127
  avg_delivery_time_ms: int
128
+ avg_queue_wait_ms: Optional[int] = None
126
129
 
127
130
 
128
131
  @dataclass(frozen=True)
@@ -267,6 +270,7 @@ class ReplayAllMessagesResponse:
267
270
  stuck: int
268
271
  replayed_message_ids: list[str]
269
272
  stuck_message_ids: list[str]
273
+ message: Optional[str] = None
270
274
 
271
275
 
272
276
  @dataclass(frozen=True)
@@ -424,6 +428,7 @@ class ListInboundEndpointsResponse:
424
428
  class UpdateResult:
425
429
  id: str
426
430
  updated: bool
431
+ subscriptions: Optional[EventSubscriptions] = None
427
432
 
428
433
 
429
434
  @dataclass(frozen=True)
@@ -619,6 +624,7 @@ class PullLogEntry:
619
624
  fetched_at: Optional[datetime] = None
620
625
  delivered_at: Optional[datetime] = None
621
626
  timing: Optional["PullTimingBreakdown"] = None
627
+ deleted_at: Optional[datetime] = None
622
628
 
623
629
 
624
630
  @dataclass(frozen=True)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "hookbridge"
7
- version = "2.3.0"
7
+ version = "2.4.0"
8
8
  description = "Official HookBridge SDK for Python"
9
9
  readme = "README.md"
10
10
  license = "MIT"