hookbridge 2.1.0__tar.gz → 2.2.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 (24) hide show
  1. {hookbridge-2.1.0 → hookbridge-2.2.0}/PKG-INFO +22 -1
  2. {hookbridge-2.1.0 → hookbridge-2.2.0}/README.md +21 -0
  3. {hookbridge-2.1.0 → hookbridge-2.2.0}/hookbridge/__init__.py +12 -2
  4. hookbridge-2.2.0/hookbridge/_version.py +1 -0
  5. {hookbridge-2.1.0 → hookbridge-2.2.0}/hookbridge/client.py +144 -2
  6. {hookbridge-2.1.0 → hookbridge-2.2.0}/hookbridge/types.py +91 -4
  7. {hookbridge-2.1.0 → hookbridge-2.2.0}/pyproject.toml +1 -1
  8. hookbridge-2.2.0/tests/test_dry_run_actions.py +169 -0
  9. hookbridge-2.2.0/tests/test_positional_compat.py +614 -0
  10. hookbridge-2.2.0/tests/test_version.py +42 -0
  11. {hookbridge-2.1.0 → hookbridge-2.2.0}/.claude/settings.local.json +0 -0
  12. {hookbridge-2.1.0 → hookbridge-2.2.0}/.gitignore +0 -0
  13. {hookbridge-2.1.0 → hookbridge-2.2.0}/hookbridge/errors.py +0 -0
  14. {hookbridge-2.1.0 → hookbridge-2.2.0}/hookbridge/py.typed +0 -0
  15. {hookbridge-2.1.0 → hookbridge-2.2.0}/requirements-dev.txt +0 -0
  16. {hookbridge-2.1.0 → hookbridge-2.2.0}/requirements.txt +0 -0
  17. {hookbridge-2.1.0 → hookbridge-2.2.0}/tests/__init__.py +0 -0
  18. {hookbridge-2.1.0 → hookbridge-2.2.0}/tests/conftest.py +0 -0
  19. {hookbridge-2.1.0 → hookbridge-2.2.0}/tests/test_async_client.py +0 -0
  20. {hookbridge-2.1.0 → hookbridge-2.2.0}/tests/test_client.py +0 -0
  21. {hookbridge-2.1.0 → hookbridge-2.2.0}/tests/test_client_spec_parity.py +0 -0
  22. {hookbridge-2.1.0 → hookbridge-2.2.0}/tests/test_errors.py +0 -0
  23. {hookbridge-2.1.0 → hookbridge-2.2.0}/tests/test_openapi_sync_2026_11.py +0 -0
  24. {hookbridge-2.1.0 → hookbridge-2.2.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.0
3
+ Version: 2.2.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
@@ -165,6 +165,27 @@ for msg in dlq.messages:
165
165
  client.replay_from_dlq(msg.message_id)
166
166
  ```
167
167
 
168
+ ### Dry-Run a Bulk Replay
169
+
170
+ ```python
171
+ preview = client.replay_all_messages_dry_run(status="failed_permanent")
172
+ print(f"Would replay {preview.would_replay} messages")
173
+ ```
174
+
175
+ Use `replay_all_inbound_messages_dry_run` for inbound messages.
176
+
177
+ ### List Message Actions
178
+
179
+ ```python
180
+ page = client.list_message_actions(message_id, limit=50)
181
+ for action in page.actions:
182
+ print(action.action, action.via, action.created_at)
183
+ if page.has_more:
184
+ page = client.list_message_actions(message_id, cursor=page.next_cursor)
185
+ ```
186
+
187
+ Use `list_inbound_message_actions` for inbound messages.
188
+
168
189
  ### Manage Retries
169
190
 
170
191
  ```python
@@ -130,6 +130,27 @@ for msg in dlq.messages:
130
130
  client.replay_from_dlq(msg.message_id)
131
131
  ```
132
132
 
133
+ ### Dry-Run a Bulk Replay
134
+
135
+ ```python
136
+ preview = client.replay_all_messages_dry_run(status="failed_permanent")
137
+ print(f"Would replay {preview.would_replay} messages")
138
+ ```
139
+
140
+ Use `replay_all_inbound_messages_dry_run` for inbound messages.
141
+
142
+ ### List Message Actions
143
+
144
+ ```python
145
+ page = client.list_message_actions(message_id, limit=50)
146
+ for action in page.actions:
147
+ print(action.action, action.via, action.created_at)
148
+ if page.has_more:
149
+ page = client.list_message_actions(message_id, cursor=page.next_cursor)
150
+ ```
151
+
152
+ Use `list_inbound_message_actions` for inbound messages.
153
+
133
154
  ### Manage Retries
134
155
 
135
156
  ```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,
@@ -58,8 +59,12 @@ from hookbridge.types import (
58
59
  ListenInboundEndpointResponse,
59
60
  ListenMessage,
60
61
  ListInboundEndpointsResponse,
62
+ ListMessageActionsResponse,
61
63
  LogsResponse,
62
64
  Message,
65
+ MessageAction,
66
+ MessageActionType,
67
+ MessageActionVia,
63
68
  MessageStatus,
64
69
  MessageSummary,
65
70
  Metrics,
@@ -80,6 +85,7 @@ from hookbridge.types import (
80
85
  PullTimeSeriesMetrics,
81
86
  PullTimingBreakdown,
82
87
  ReplayableMessageStatus,
88
+ ReplayAllDryRunResponse,
83
89
  ReplayAllMessagesResponse,
84
90
  ReplayBatchMessagesResponse,
85
91
  ReplayBatchResult,
@@ -98,9 +104,8 @@ from hookbridge.types import (
98
104
  UsageHistoryRow,
99
105
  )
100
106
 
101
- __version__ = "2.1.0"
102
-
103
107
  __all__ = [
108
+ "__version__",
104
109
  "HookBridge",
105
110
  "AsyncHookBridge",
106
111
  "APIKeyInfo",
@@ -166,7 +171,12 @@ __all__ = [
166
171
  "PullTimeSeriesBucket",
167
172
  "PullTimeSeriesMetrics",
168
173
  "PullTimingBreakdown",
174
+ "ReplayAllDryRunResponse",
169
175
  "ReplayAllMessagesResponse",
176
+ "ListMessageActionsResponse",
177
+ "MessageAction",
178
+ "MessageActionType",
179
+ "MessageActionVia",
170
180
  "ReplayBatchMessagesResponse",
171
181
  "ReplayBatchResult",
172
182
  "ReplayErrorCode",
@@ -0,0 +1 @@
1
+ __version__ = "2.2.0"
@@ -6,10 +6,11 @@ import os
6
6
  import time
7
7
  from datetime import date, datetime
8
8
  from typing import Any, Optional, Union
9
- from urllib.parse import urlencode
9
+ from urllib.parse import quote, urlencode
10
10
 
11
11
  import httpx
12
12
 
13
+ from hookbridge._version import __version__
13
14
  from hookbridge.errors import (
14
15
  AuthenticationError,
15
16
  HookBridgeError,
@@ -63,10 +64,12 @@ from hookbridge.types import (
63
64
  ListenInboundEndpointResponse,
64
65
  ListenMessage,
65
66
  ListInboundEndpointsResponse,
67
+ ListMessageActionsResponse,
66
68
  ListPullEndpointsResponse,
67
69
  ListPullEventsResponse,
68
70
  LogsResponse,
69
71
  Message,
72
+ MessageAction,
70
73
  MessageStatus,
71
74
  MessageSummary,
72
75
  Metrics,
@@ -85,6 +88,7 @@ from hookbridge.types import (
85
88
  PullTimeSeriesMetrics,
86
89
  PullTimingBreakdown,
87
90
  ReplayableMessageStatus,
91
+ ReplayAllDryRunResponse,
88
92
  ReplayAllMessagesResponse,
89
93
  ReplayBatchMessagesResponse,
90
94
  ReplayBatchResult,
@@ -330,6 +334,30 @@ def _parse_replay_all_messages(data: dict[str, Any]) -> ReplayAllMessagesRespons
330
334
  )
331
335
 
332
336
 
337
+ def _parse_replay_all_dry_run(data: dict[str, Any]) -> ReplayAllDryRunResponse:
338
+ return ReplayAllDryRunResponse(would_replay=data["would_replay"])
339
+
340
+
341
+ def _parse_message_actions(response: dict[str, Any]) -> ListMessageActionsResponse:
342
+ meta = response.get("meta", {})
343
+ return ListMessageActionsResponse(
344
+ actions=[
345
+ MessageAction(
346
+ id=item["id"],
347
+ action=item["action"],
348
+ user_id=item.get("user_id"),
349
+ api_key_id=item.get("api_key_id"),
350
+ via=item["via"],
351
+ client_name=item.get("client_name"),
352
+ created_at=_parse_datetime(item["created_at"]),
353
+ )
354
+ for item in response.get("data", [])
355
+ ],
356
+ has_more=meta.get("has_more", False),
357
+ next_cursor=meta.get("next_cursor"),
358
+ )
359
+
360
+
333
361
  def _parse_replay_batch_messages(data: dict[str, Any]) -> ReplayBatchMessagesResponse:
334
362
  return ReplayBatchMessagesResponse(
335
363
  replayed=data["replayed"],
@@ -773,7 +801,7 @@ def _build_common_headers(api_key: str) -> dict[str, str]:
773
801
  "Authorization": f"Bearer {api_key}",
774
802
  "Content-Type": "application/json",
775
803
  "Accept": "application/json",
776
- "User-Agent": "hookbridge-python/1.2.0",
804
+ "User-Agent": f"hookbridge-python/{__version__}",
777
805
  }
778
806
 
779
807
 
@@ -887,6 +915,32 @@ class HookBridge:
887
915
  )
888
916
  return _parse_replay_all_messages(self._request("POST", path)["data"])
889
917
 
918
+ def replay_all_messages_dry_run(
919
+ self,
920
+ *,
921
+ status: ReplayableMessageStatus,
922
+ endpoint_id: Optional[str] = None,
923
+ limit: Optional[int] = None,
924
+ ) -> ReplayAllDryRunResponse:
925
+ path = _with_query(
926
+ "/v1/messages/replay-all",
927
+ {"status": status, "endpoint_id": endpoint_id, "limit": limit, "dry_run": "true"},
928
+ )
929
+ return _parse_replay_all_dry_run(self._request("POST", path)["data"])
930
+
931
+ def list_message_actions(
932
+ self,
933
+ message_id: str,
934
+ *,
935
+ cursor: Optional[str] = None,
936
+ limit: Optional[int] = None,
937
+ ) -> ListMessageActionsResponse:
938
+ path = _with_query(
939
+ f"/v1/messages/{quote(message_id, safe='')}/actions",
940
+ {"cursor": cursor, "limit": limit},
941
+ )
942
+ return _parse_message_actions(self._request("GET", path))
943
+
890
944
  def replay_batch_messages(self, message_ids: list[str]) -> ReplayBatchMessagesResponse:
891
945
  response = self._request(
892
946
  "POST", "/v1/messages/replay-batch", json={"message_ids": message_ids}
@@ -1465,6 +1519,37 @@ class HookBridge:
1465
1519
  )
1466
1520
  return _parse_replay_all_messages(self._request("POST", path)["data"])
1467
1521
 
1522
+ def replay_all_inbound_messages_dry_run(
1523
+ self,
1524
+ *,
1525
+ status: ReplayableMessageStatus,
1526
+ inbound_endpoint_id: Optional[str] = None,
1527
+ limit: Optional[int] = None,
1528
+ ) -> ReplayAllDryRunResponse:
1529
+ path = _with_query(
1530
+ "/v1/inbound-messages/replay-all",
1531
+ {
1532
+ "status": status,
1533
+ "inbound_endpoint_id": inbound_endpoint_id,
1534
+ "limit": limit,
1535
+ "dry_run": "true",
1536
+ },
1537
+ )
1538
+ return _parse_replay_all_dry_run(self._request("POST", path)["data"])
1539
+
1540
+ def list_inbound_message_actions(
1541
+ self,
1542
+ message_id: str,
1543
+ *,
1544
+ cursor: Optional[str] = None,
1545
+ limit: Optional[int] = None,
1546
+ ) -> ListMessageActionsResponse:
1547
+ path = _with_query(
1548
+ f"/v1/inbound-messages/{quote(message_id, safe='')}/actions",
1549
+ {"cursor": cursor, "limit": limit},
1550
+ )
1551
+ return _parse_message_actions(self._request("GET", path))
1552
+
1468
1553
  def replay_batch_inbound_messages(self, message_ids: list[str]) -> ReplayBatchMessagesResponse:
1469
1554
  response = self._request(
1470
1555
  "POST", "/v1/inbound-messages/replay-batch", json={"message_ids": message_ids}
@@ -1836,6 +1921,32 @@ class AsyncHookBridge:
1836
1921
  )
1837
1922
  return _parse_replay_all_messages((await self._request("POST", path))["data"])
1838
1923
 
1924
+ async def replay_all_messages_dry_run(
1925
+ self,
1926
+ *,
1927
+ status: ReplayableMessageStatus,
1928
+ endpoint_id: Optional[str] = None,
1929
+ limit: Optional[int] = None,
1930
+ ) -> ReplayAllDryRunResponse:
1931
+ path = _with_query(
1932
+ "/v1/messages/replay-all",
1933
+ {"status": status, "endpoint_id": endpoint_id, "limit": limit, "dry_run": "true"},
1934
+ )
1935
+ return _parse_replay_all_dry_run((await self._request("POST", path))["data"])
1936
+
1937
+ async def list_message_actions(
1938
+ self,
1939
+ message_id: str,
1940
+ *,
1941
+ cursor: Optional[str] = None,
1942
+ limit: Optional[int] = None,
1943
+ ) -> ListMessageActionsResponse:
1944
+ path = _with_query(
1945
+ f"/v1/messages/{quote(message_id, safe='')}/actions",
1946
+ {"cursor": cursor, "limit": limit},
1947
+ )
1948
+ return _parse_message_actions(await self._request("GET", path))
1949
+
1839
1950
  async def replay_batch_messages(self, message_ids: list[str]) -> ReplayBatchMessagesResponse:
1840
1951
  response = await self._request(
1841
1952
  "POST", "/v1/messages/replay-batch", json={"message_ids": message_ids}
@@ -2429,6 +2540,37 @@ class AsyncHookBridge:
2429
2540
  )
2430
2541
  return _parse_replay_all_messages((await self._request("POST", path))["data"])
2431
2542
 
2543
+ async def replay_all_inbound_messages_dry_run(
2544
+ self,
2545
+ *,
2546
+ status: ReplayableMessageStatus,
2547
+ inbound_endpoint_id: Optional[str] = None,
2548
+ limit: Optional[int] = None,
2549
+ ) -> ReplayAllDryRunResponse:
2550
+ path = _with_query(
2551
+ "/v1/inbound-messages/replay-all",
2552
+ {
2553
+ "status": status,
2554
+ "inbound_endpoint_id": inbound_endpoint_id,
2555
+ "limit": limit,
2556
+ "dry_run": "true",
2557
+ },
2558
+ )
2559
+ return _parse_replay_all_dry_run((await self._request("POST", path))["data"])
2560
+
2561
+ async def list_inbound_message_actions(
2562
+ self,
2563
+ message_id: str,
2564
+ *,
2565
+ cursor: Optional[str] = None,
2566
+ limit: Optional[int] = None,
2567
+ ) -> ListMessageActionsResponse:
2568
+ path = _with_query(
2569
+ f"/v1/inbound-messages/{quote(message_id, safe='')}/actions",
2570
+ {"cursor": cursor, "limit": limit},
2571
+ )
2572
+ return _parse_message_actions(await self._request("GET", path))
2573
+
2432
2574
  async def replay_batch_inbound_messages(
2433
2575
  self, message_ids: list[str]
2434
2576
  ) -> ReplayBatchMessagesResponse:
@@ -254,6 +254,35 @@ class ReplayAllMessagesResponse:
254
254
  stuck_message_ids: list[str]
255
255
 
256
256
 
257
+ @dataclass(frozen=True)
258
+ class ReplayAllDryRunResponse:
259
+ would_replay: int
260
+
261
+
262
+ MessageActionType = Literal[
263
+ "replay", "retry_now", "cancel", "replay_batch", "replay_all", "dlq_replay"
264
+ ]
265
+ MessageActionVia = Literal["console", "api", "mcp-local", "mcp-hosted"]
266
+
267
+
268
+ @dataclass(frozen=True)
269
+ class MessageAction:
270
+ id: str
271
+ action: MessageActionType
272
+ user_id: Optional[str]
273
+ api_key_id: Optional[str]
274
+ via: MessageActionVia
275
+ client_name: Optional[str]
276
+ created_at: datetime
277
+
278
+
279
+ @dataclass(frozen=True)
280
+ class ListMessageActionsResponse:
281
+ actions: list[MessageAction]
282
+ has_more: bool
283
+ next_cursor: Optional[str] = None
284
+
285
+
257
286
  @dataclass(frozen=True)
258
287
  class ReplayBatchResult:
259
288
  message_id: str
@@ -423,19 +452,77 @@ class PullEndpoint:
423
452
  token_query_param: Optional[str] = None
424
453
  verify_hmac: Optional[bool] = None
425
454
  hmac_header_name: Optional[str] = None
426
- hmac_signature_encoding: Optional[HMACSignatureEncoding] = None
427
455
  timestamp_header_name: Optional[str] = None
428
456
  timestamp_ttl_seconds: Optional[int] = None
429
457
  verify_ip_allowlist: Optional[bool] = None
430
458
  allowed_cidrs: Optional[list[str]] = None
431
459
  ingest_response_code: Optional[int] = None
432
460
  idempotency_header_names: Optional[list[str]] = None
461
+ hmac_signature_encoding: Optional[HMACSignatureEncoding] = None
433
462
 
434
463
 
435
- @dataclass(frozen=True)
464
+ @dataclass(frozen=True, init=False)
436
465
  class CreatePullEndpointResponse(PullEndpoint):
437
466
  secret_token: Optional[str] = None
438
467
 
468
+ def __init__(
469
+ self,
470
+ id: str,
471
+ mode: PullEndpointMode,
472
+ ingest_url: str,
473
+ active: bool,
474
+ paused: bool,
475
+ created_at: datetime,
476
+ updated_at: datetime,
477
+ name: Optional[str] = None,
478
+ description: Optional[str] = None,
479
+ retention_days: Optional[int] = None,
480
+ event_type_source: Optional[PullEventTypeSource] = None,
481
+ event_type_path: Optional[str] = None,
482
+ counts: Optional[PullEndpointCounts] = None,
483
+ verify_static_token: Optional[bool] = None,
484
+ token_header_name: Optional[str] = None,
485
+ token_query_param: Optional[str] = None,
486
+ verify_hmac: Optional[bool] = None,
487
+ hmac_header_name: Optional[str] = None,
488
+ timestamp_header_name: Optional[str] = None,
489
+ timestamp_ttl_seconds: Optional[int] = None,
490
+ verify_ip_allowlist: Optional[bool] = None,
491
+ allowed_cidrs: Optional[list[str]] = None,
492
+ ingest_response_code: Optional[int] = None,
493
+ idempotency_header_names: Optional[list[str]] = None,
494
+ secret_token: Optional[str] = None,
495
+ hmac_signature_encoding: Optional[HMACSignatureEncoding] = None,
496
+ ) -> None:
497
+ super().__init__(
498
+ id=id,
499
+ mode=mode,
500
+ ingest_url=ingest_url,
501
+ active=active,
502
+ paused=paused,
503
+ created_at=created_at,
504
+ updated_at=updated_at,
505
+ name=name,
506
+ description=description,
507
+ retention_days=retention_days,
508
+ event_type_source=event_type_source,
509
+ event_type_path=event_type_path,
510
+ counts=counts,
511
+ verify_static_token=verify_static_token,
512
+ token_header_name=token_header_name,
513
+ token_query_param=token_query_param,
514
+ verify_hmac=verify_hmac,
515
+ hmac_header_name=hmac_header_name,
516
+ timestamp_header_name=timestamp_header_name,
517
+ timestamp_ttl_seconds=timestamp_ttl_seconds,
518
+ verify_ip_allowlist=verify_ip_allowlist,
519
+ allowed_cidrs=allowed_cidrs,
520
+ ingest_response_code=ingest_response_code,
521
+ idempotency_header_names=idempotency_header_names,
522
+ hmac_signature_encoding=hmac_signature_encoding,
523
+ )
524
+ object.__setattr__(self, "secret_token", secret_token)
525
+
439
526
 
440
527
  @dataclass(frozen=True)
441
528
  class PullEndpointSummary:
@@ -650,14 +737,14 @@ class ExportRecord:
650
737
  created_at: datetime
651
738
  filter_status: Optional[str] = None
652
739
  filter_endpoint_id: Optional[str] = None
653
- filter_inbound_endpoint_id: Optional[str] = None
654
- direction: Optional[ExportDirection] = None
655
740
  row_count: Optional[int] = None
656
741
  file_size_bytes: Optional[int] = None
657
742
  error_message: Optional[str] = None
658
743
  started_at: Optional[datetime] = None
659
744
  completed_at: Optional[datetime] = None
660
745
  expires_at: Optional[datetime] = None
746
+ filter_inbound_endpoint_id: Optional[str] = None
747
+ direction: Optional[ExportDirection] = None
661
748
 
662
749
 
663
750
  @dataclass(frozen=True)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "hookbridge"
7
- version = "2.1.0"
7
+ version = "2.2.0"
8
8
  description = "Official HookBridge SDK for Python"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -0,0 +1,169 @@
1
+ """
2
+ Tests for replay-all dry run and message action listing (sync and async).
3
+ """
4
+
5
+ from datetime import UTC, datetime
6
+
7
+ from pytest_httpx import HTTPXMock
8
+
9
+ from hookbridge import AsyncHookBridge, HookBridge
10
+
11
+ ENDPOINT_ID = "ep_550e8400e29b41d4a716446655440000"
12
+ INBOUND_ENDPOINT_ID = "01935abc-def0-7123-4567-890abcdef099"
13
+
14
+ ACTIONS_BODY = {
15
+ "data": [
16
+ {
17
+ "id": "0190a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a5b",
18
+ "action": "replay",
19
+ "user_id": None,
20
+ "api_key_id": "01935abc-def0-7123-4567-890abcdef0aa",
21
+ "via": "mcp-local",
22
+ "client_name": "Claude Desktop",
23
+ "created_at": "2026-11-18T10:11:12.345Z",
24
+ },
25
+ {
26
+ "id": "0190a1b2-0000-7e5f-8a9b-0c1d2e3f4a5b",
27
+ "action": "retry_now",
28
+ "user_id": "6d1f0a52-2a43-4a4e-9d1e-3f4f6b7c8d90",
29
+ "api_key_id": None,
30
+ "via": "console",
31
+ "client_name": None,
32
+ "created_at": "2026-11-18T09:00:00.000Z",
33
+ },
34
+ ],
35
+ "meta": {"request_id": "req_1", "has_more": True, "next_cursor": "cur_2"},
36
+ }
37
+
38
+
39
+ def _dry_run_body(n: int) -> dict:
40
+ return {"data": {"would_replay": n}, "meta": {"request_id": "req_1"}}
41
+
42
+
43
+ def _assert_actions(result) -> None: # type: ignore[no-untyped-def]
44
+ assert result.has_more is True
45
+ assert result.next_cursor == "cur_2"
46
+ first, second = result.actions
47
+ assert first.id == "0190a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a5b"
48
+ assert first.action == "replay"
49
+ assert first.user_id is None
50
+ assert first.api_key_id == "01935abc-def0-7123-4567-890abcdef0aa"
51
+ assert first.via == "mcp-local"
52
+ assert first.client_name == "Claude Desktop"
53
+ assert first.created_at == datetime(2026, 11, 18, 10, 11, 12, 345000, tzinfo=UTC)
54
+ assert second.user_id == "6d1f0a52-2a43-4a4e-9d1e-3f4f6b7c8d90"
55
+ assert second.api_key_id is None
56
+ assert second.client_name is None
57
+
58
+
59
+ class TestSyncDryRun:
60
+ def test_outbound(self, client: HookBridge, httpx_mock: HTTPXMock) -> None:
61
+ httpx_mock.add_response(
62
+ method="POST",
63
+ url=(
64
+ f"{client._base_url}/v1/messages/replay-all"
65
+ f"?status=failed_permanent&endpoint_id={ENDPOINT_ID}&limit=50&dry_run=true"
66
+ ),
67
+ json=_dry_run_body(7),
68
+ )
69
+ result = client.replay_all_messages_dry_run(
70
+ status="failed_permanent", endpoint_id=ENDPOINT_ID, limit=50
71
+ )
72
+ assert result.would_replay == 7
73
+
74
+ def test_inbound(self, client: HookBridge, httpx_mock: HTTPXMock) -> None:
75
+ httpx_mock.add_response(
76
+ method="POST",
77
+ url=(
78
+ f"{client._base_url}/v1/inbound-messages/replay-all"
79
+ f"?status=pending_retry&inbound_endpoint_id={INBOUND_ENDPOINT_ID}&dry_run=true"
80
+ ),
81
+ json=_dry_run_body(3),
82
+ )
83
+ result = client.replay_all_inbound_messages_dry_run(
84
+ status="pending_retry", inbound_endpoint_id=INBOUND_ENDPOINT_ID
85
+ )
86
+ assert result.would_replay == 3
87
+
88
+
89
+ class TestSyncActions:
90
+ def test_list_message_actions(self, client: HookBridge, httpx_mock: HTTPXMock) -> None:
91
+ httpx_mock.add_response(
92
+ method="GET",
93
+ url=f"{client._base_url}/v1/messages/msg_1/actions?cursor=cur_1&limit=2",
94
+ json=ACTIONS_BODY,
95
+ )
96
+ _assert_actions(client.list_message_actions("msg_1", cursor="cur_1", limit=2))
97
+
98
+ def test_list_message_actions_encodes_id_and_defaults(
99
+ self, client: HookBridge, httpx_mock: HTTPXMock
100
+ ) -> None:
101
+ httpx_mock.add_response(
102
+ method="GET",
103
+ url=f"{client._base_url}/v1/messages/a%2Fb/actions",
104
+ json={"data": [], "meta": {"has_more": False}},
105
+ )
106
+ result = client.list_message_actions("a/b")
107
+ assert result.actions == []
108
+ assert result.has_more is False
109
+ assert result.next_cursor is None
110
+
111
+ def test_list_inbound_message_actions(self, client: HookBridge, httpx_mock: HTTPXMock) -> None:
112
+ httpx_mock.add_response(
113
+ method="GET",
114
+ url=f"{client._base_url}/v1/inbound-messages/a%2Fb/actions?limit=2",
115
+ json=ACTIONS_BODY,
116
+ )
117
+ _assert_actions(client.list_inbound_message_actions("a/b", limit=2))
118
+
119
+
120
+ class TestAsyncDryRun:
121
+ async def test_outbound(self, async_client: AsyncHookBridge, httpx_mock: HTTPXMock) -> None:
122
+ httpx_mock.add_response(
123
+ method="POST",
124
+ url=(
125
+ f"{async_client._base_url}/v1/messages/replay-all"
126
+ f"?status=failed_permanent&endpoint_id={ENDPOINT_ID}&limit=50&dry_run=true"
127
+ ),
128
+ json=_dry_run_body(7),
129
+ )
130
+ result = await async_client.replay_all_messages_dry_run(
131
+ status="failed_permanent", endpoint_id=ENDPOINT_ID, limit=50
132
+ )
133
+ assert result.would_replay == 7
134
+
135
+ async def test_inbound(self, async_client: AsyncHookBridge, httpx_mock: HTTPXMock) -> None:
136
+ httpx_mock.add_response(
137
+ method="POST",
138
+ url=(
139
+ f"{async_client._base_url}/v1/inbound-messages/replay-all"
140
+ f"?status=pending_retry&inbound_endpoint_id={INBOUND_ENDPOINT_ID}&dry_run=true"
141
+ ),
142
+ json=_dry_run_body(3),
143
+ )
144
+ result = await async_client.replay_all_inbound_messages_dry_run(
145
+ status="pending_retry", inbound_endpoint_id=INBOUND_ENDPOINT_ID
146
+ )
147
+ assert result.would_replay == 3
148
+
149
+
150
+ class TestAsyncActions:
151
+ async def test_list_message_actions(
152
+ self, async_client: AsyncHookBridge, httpx_mock: HTTPXMock
153
+ ) -> None:
154
+ httpx_mock.add_response(
155
+ method="GET",
156
+ url=f"{async_client._base_url}/v1/messages/a%2Fb/actions?cursor=cur_1&limit=2",
157
+ json=ACTIONS_BODY,
158
+ )
159
+ _assert_actions(await async_client.list_message_actions("a/b", cursor="cur_1", limit=2))
160
+
161
+ async def test_list_inbound_message_actions(
162
+ self, async_client: AsyncHookBridge, httpx_mock: HTTPXMock
163
+ ) -> None:
164
+ httpx_mock.add_response(
165
+ method="GET",
166
+ url=f"{async_client._base_url}/v1/inbound-messages/msg_1/actions",
167
+ json=ACTIONS_BODY,
168
+ )
169
+ _assert_actions(await async_client.list_inbound_message_actions("msg_1"))
@@ -0,0 +1,614 @@
1
+ import dataclasses
2
+ import inspect
3
+ from datetime import datetime, timedelta, timezone
4
+
5
+ import hookbridge.types as types_module
6
+ from hookbridge.types import CreatePullEndpointResponse, ExportRecord, PullEndpoint
7
+
8
+ NOW = datetime(2026, 1, 1, tzinfo=timezone.utc)
9
+
10
+
11
+ def at(day: int) -> datetime:
12
+ return NOW + timedelta(days=day)
13
+
14
+
15
+ def test_export_record_positional_2_0_0_order() -> None:
16
+ record = ExportRecord(
17
+ "id1",
18
+ "proj1",
19
+ "completed",
20
+ at(1),
21
+ at(2),
22
+ at(3),
23
+ "failed",
24
+ "ep1",
25
+ 42,
26
+ 1024,
27
+ "boom",
28
+ at(4),
29
+ at(5),
30
+ at(6),
31
+ )
32
+ assert record.id == "id1"
33
+ assert record.project_id == "proj1"
34
+ assert record.status == "completed"
35
+ assert record.filter_status == "failed"
36
+ assert record.filter_endpoint_id == "ep1"
37
+ assert record.row_count == 42
38
+ assert record.file_size_bytes == 1024
39
+ assert record.error_message == "boom"
40
+ assert record.filter_start_time == at(1)
41
+ assert record.filter_end_time == at(2)
42
+ assert record.created_at == at(3)
43
+ assert record.started_at == at(4)
44
+ assert record.completed_at == at(5)
45
+ assert record.expires_at == at(6)
46
+ assert record.filter_inbound_endpoint_id is None
47
+ assert record.direction is None
48
+
49
+
50
+ def test_pull_endpoint_positional_2_0_0_order() -> None:
51
+ counts = None
52
+ endpoint = PullEndpoint(
53
+ "id1",
54
+ "pull",
55
+ "https://ingest.example.com/x",
56
+ True,
57
+ False,
58
+ at(1),
59
+ at(2),
60
+ "name",
61
+ "desc",
62
+ 7,
63
+ "header",
64
+ "$.type",
65
+ counts,
66
+ True,
67
+ "X-Token",
68
+ "token",
69
+ True,
70
+ "X-Sig",
71
+ "X-Ts",
72
+ 300,
73
+ True,
74
+ ["10.0.0.0/8"],
75
+ 202,
76
+ ["X-Idem"],
77
+ )
78
+ assert endpoint.created_at == at(1)
79
+ assert endpoint.updated_at == at(2)
80
+ assert endpoint.hmac_header_name == "X-Sig"
81
+ assert endpoint.timestamp_header_name == "X-Ts"
82
+ assert endpoint.timestamp_ttl_seconds == 300
83
+ assert endpoint.verify_ip_allowlist is True
84
+ assert endpoint.allowed_cidrs == ["10.0.0.0/8"]
85
+ assert endpoint.ingest_response_code == 202
86
+ assert endpoint.idempotency_header_names == ["X-Idem"]
87
+ assert endpoint.hmac_signature_encoding is None
88
+
89
+
90
+ def test_create_pull_endpoint_response_positional_2_0_0_order() -> None:
91
+ resp = CreatePullEndpointResponse(
92
+ "id1",
93
+ "pull",
94
+ "https://ingest.example.com/x",
95
+ True,
96
+ False,
97
+ at(1),
98
+ at(2),
99
+ "name",
100
+ "desc",
101
+ 7,
102
+ "header",
103
+ "$.type",
104
+ None,
105
+ True,
106
+ "X-Token",
107
+ "token",
108
+ True,
109
+ "X-Sig",
110
+ "X-Ts",
111
+ 300,
112
+ True,
113
+ ["10.0.0.0/8"],
114
+ 202,
115
+ ["X-Idem"],
116
+ "sekret",
117
+ )
118
+ assert isinstance(resp, PullEndpoint)
119
+ assert resp.created_at == at(1)
120
+ assert resp.updated_at == at(2)
121
+ assert resp.idempotency_header_names == ["X-Idem"]
122
+ assert resp.secret_token == "sekret"
123
+ assert resp.hmac_signature_encoding is None
124
+
125
+
126
+ def test_create_pull_endpoint_response_keywords() -> None:
127
+ resp = CreatePullEndpointResponse(
128
+ id="id1",
129
+ mode="pull",
130
+ ingest_url="u",
131
+ active=True,
132
+ paused=False,
133
+ created_at=NOW,
134
+ updated_at=NOW,
135
+ hmac_signature_encoding="base64",
136
+ secret_token="s",
137
+ )
138
+ assert resp.hmac_signature_encoding == "base64"
139
+ assert resp.secret_token == "s"
140
+ assert resp.name is None
141
+ assert resp == CreatePullEndpointResponse(
142
+ id="id1",
143
+ mode="pull",
144
+ ingest_url="u",
145
+ active=True,
146
+ paused=False,
147
+ created_at=NOW,
148
+ updated_at=NOW,
149
+ hmac_signature_encoding="base64",
150
+ secret_token="s",
151
+ )
152
+
153
+
154
+ def test_create_pull_endpoint_response_init_covers_every_field() -> None:
155
+ params = set(inspect.signature(CreatePullEndpointResponse.__init__).parameters) - {"self"}
156
+ assert params == {f.name for f in dataclasses.fields(CreatePullEndpointResponse)}
157
+
158
+
159
+ def test_init_parameter_order_is_pinned() -> None:
160
+ actual = {
161
+ name: [p for p in inspect.signature(cls.__init__).parameters if p != "self"]
162
+ for name, cls in inspect.getmembers(types_module, inspect.isclass)
163
+ if dataclasses.is_dataclass(cls) and cls.__module__ == types_module.__name__
164
+ }
165
+ assert set(INIT_ORDER) <= set(actual)
166
+ for name, expected in INIT_ORDER.items():
167
+ assert actual[name][: len(expected)] == expected, name
168
+
169
+
170
+ INIT_ORDER: dict[str, list[str]] = {
171
+ "APIKeyInfo": ["key_id", "label", "prefix", "created_at", "last_used_at"],
172
+ "AckPullEventsResponse": ["acknowledged"],
173
+ "ActorLookupResult": ["users", "api_keys"],
174
+ "AttemptRecord": [
175
+ "id",
176
+ "attempt_no",
177
+ "created_at",
178
+ "response_status",
179
+ "response_latency_ms",
180
+ "processing_ms",
181
+ "error_text",
182
+ "response_headers",
183
+ "retry_type",
184
+ "retry_after_seconds",
185
+ "resolved_ip",
186
+ "request_headers",
187
+ "dns_ms",
188
+ "tcp_connect_ms",
189
+ "tls_handshake_ms",
190
+ "ttfb_ms",
191
+ "transfer_ms",
192
+ "conn_reused",
193
+ "response_body_url",
194
+ "response_body_truncated",
195
+ ],
196
+ "AttemptsResponse": ["attempts", "has_more"],
197
+ "CreateAPIKeyResponse": ["key_id", "key", "prefix", "label", "created_at"],
198
+ "CreateEndpointResponse": [
199
+ "id",
200
+ "url",
201
+ "signing_secret",
202
+ "created_at",
203
+ "description",
204
+ "signing_key_id",
205
+ "key_hint",
206
+ "ephemeral",
207
+ "expires_at",
208
+ ],
209
+ "CreateInboundEndpointResponse": [
210
+ "id",
211
+ "name",
212
+ "url",
213
+ "mode",
214
+ "ingest_url",
215
+ "secret_token",
216
+ "created_at",
217
+ "signing_key_id",
218
+ "signing_secret",
219
+ "key_hint",
220
+ "hmac_signature_encoding",
221
+ "ephemeral",
222
+ "expires_at",
223
+ ],
224
+ "CreatePullEndpointResponse": [
225
+ "id",
226
+ "mode",
227
+ "ingest_url",
228
+ "active",
229
+ "paused",
230
+ "created_at",
231
+ "updated_at",
232
+ "name",
233
+ "description",
234
+ "retention_days",
235
+ "event_type_source",
236
+ "event_type_path",
237
+ "counts",
238
+ "verify_static_token",
239
+ "token_header_name",
240
+ "token_query_param",
241
+ "verify_hmac",
242
+ "hmac_header_name",
243
+ "timestamp_header_name",
244
+ "timestamp_ttl_seconds",
245
+ "verify_ip_allowlist",
246
+ "allowed_cidrs",
247
+ "ingest_response_code",
248
+ "idempotency_header_names",
249
+ "secret_token",
250
+ "hmac_signature_encoding",
251
+ ],
252
+ "DLQMessagesResponse": ["messages", "has_more", "next_cursor"],
253
+ "DeleteAllResult": ["deleted", "deleted_message_ids", "error"],
254
+ "DeleteBatchItemResult": ["message_id", "outcome", "deleted_at"],
255
+ "DeleteBatchResult": ["results", "deleted_count", "already_deleted_count", "not_found_count"],
256
+ "DeleteEventBatchItemResult": ["event_id", "outcome", "deleted_at"],
257
+ "DeleteEventBatchResult": [
258
+ "results",
259
+ "deleted_count",
260
+ "already_deleted_count",
261
+ "not_found_count",
262
+ ],
263
+ "DeleteEventResult": ["event_id", "deleted_at", "already_deleted"],
264
+ "DeleteMessageResult": ["message_id", "deleted_at", "already_deleted"],
265
+ "DeletePartialError": ["code", "message"],
266
+ "DeletePullEventsAllResult": ["deleted", "deleted_event_ids", "error"],
267
+ "DeleteResult": ["deleted", "id"],
268
+ "Endpoint": [
269
+ "id",
270
+ "url",
271
+ "created_at",
272
+ "updated_at",
273
+ "paused",
274
+ "description",
275
+ "rate_limit_rps",
276
+ "burst",
277
+ "headers",
278
+ "ephemeral",
279
+ "expires_at",
280
+ ],
281
+ "EndpointSummary": [
282
+ "id",
283
+ "url",
284
+ "created_at",
285
+ "paused",
286
+ "description",
287
+ "ephemeral",
288
+ "expires_at",
289
+ ],
290
+ "ExportRecord": [
291
+ "id",
292
+ "project_id",
293
+ "status",
294
+ "filter_start_time",
295
+ "filter_end_time",
296
+ "created_at",
297
+ "filter_status",
298
+ "filter_endpoint_id",
299
+ "row_count",
300
+ "file_size_bytes",
301
+ "error_message",
302
+ "started_at",
303
+ "completed_at",
304
+ "expires_at",
305
+ "filter_inbound_endpoint_id",
306
+ "direction",
307
+ ],
308
+ "InboundEndpoint": [
309
+ "id",
310
+ "name",
311
+ "url",
312
+ "mode",
313
+ "active",
314
+ "paused",
315
+ "verify_static_token",
316
+ "verify_hmac",
317
+ "verify_ip_allowlist",
318
+ "ingest_response_code",
319
+ "idempotency_header_names",
320
+ "signing_enabled",
321
+ "created_at",
322
+ "updated_at",
323
+ "description",
324
+ "hmac_signature_encoding",
325
+ "ingest_url",
326
+ "ephemeral",
327
+ "expires_at",
328
+ ],
329
+ "InboundEndpointSummary": [
330
+ "id",
331
+ "name",
332
+ "url",
333
+ "mode",
334
+ "active",
335
+ "paused",
336
+ "created_at",
337
+ "ephemeral",
338
+ "expires_at",
339
+ ],
340
+ "InboundLogEntry": [
341
+ "message_id",
342
+ "inbound_endpoint_id",
343
+ "endpoint",
344
+ "status",
345
+ "attempt_count",
346
+ "received_at",
347
+ "delivered_at",
348
+ "response_status",
349
+ "response_latency_ms",
350
+ "last_error",
351
+ "total_delivery_ms",
352
+ "deleted_at",
353
+ ],
354
+ "InboundLogsResponse": ["entries", "has_more", "next_cursor"],
355
+ "InboundMessage": [
356
+ "id",
357
+ "project_id",
358
+ "inbound_endpoint_id",
359
+ "status",
360
+ "attempt_count",
361
+ "replay_count",
362
+ "received_at",
363
+ "updated_at",
364
+ "content_type",
365
+ "size_bytes",
366
+ "payload_sha256",
367
+ "idempotency_key",
368
+ "next_attempt_at",
369
+ "last_error",
370
+ "response_status",
371
+ "response_latency_ms",
372
+ "queue_wait_ms",
373
+ "total_delivery_ms",
374
+ "delivered_at",
375
+ "failed_at",
376
+ "deleted_at",
377
+ "deleted_by_user_id",
378
+ "deleted_by_api_key_id",
379
+ "retention_hours",
380
+ ],
381
+ "InboundMetrics": [
382
+ "window",
383
+ "total_messages",
384
+ "succeeded",
385
+ "failed",
386
+ "retries",
387
+ "success_rate",
388
+ "avg_latency_ms",
389
+ "avg_delivery_time_ms",
390
+ ],
391
+ "InboundRejection": [
392
+ "id",
393
+ "reason_code",
394
+ "received_at",
395
+ "inbound_endpoint_id",
396
+ "reason_detail",
397
+ "source_ip",
398
+ "headers_redacted",
399
+ ],
400
+ "InboundRejectionsResponse": ["entries", "has_more", "next_cursor"],
401
+ "Invoice": [
402
+ "id",
403
+ "status",
404
+ "amount_due",
405
+ "amount_paid",
406
+ "currency",
407
+ "period_start",
408
+ "period_end",
409
+ "created",
410
+ "lines",
411
+ "invoice_pdf",
412
+ "hosted_invoice_url",
413
+ ],
414
+ "InvoiceLine": ["description", "amount", "quantity"],
415
+ "InvoicesResponse": ["invoices", "has_more"],
416
+ "ListEndpointsResponse": ["endpoints", "has_more", "next_cursor"],
417
+ "ListInboundEndpointsResponse": ["endpoints", "has_more", "next_cursor"],
418
+ "ListPullEndpointsResponse": ["endpoints", "has_more", "next_cursor"],
419
+ "ListPullEventsResponse": ["events", "has_more", "next_cursor"],
420
+ "ListenInboundEndpointResponse": ["messages", "next_cursor"],
421
+ "ListenMessage": [
422
+ "message_id",
423
+ "content_type",
424
+ "headers",
425
+ "size_bytes",
426
+ "received_at",
427
+ "body",
428
+ "body_encoding",
429
+ "body_error",
430
+ ],
431
+ "LogsResponse": ["messages", "has_more", "next_cursor"],
432
+ "Message": [
433
+ "id",
434
+ "project_id",
435
+ "endpoint_id",
436
+ "status",
437
+ "attempt_count",
438
+ "replay_count",
439
+ "content_type",
440
+ "size_bytes",
441
+ "payload_sha256",
442
+ "created_at",
443
+ "updated_at",
444
+ "idempotency_key",
445
+ "next_attempt_at",
446
+ "last_error",
447
+ "response_status",
448
+ "response_latency_ms",
449
+ "deleted_at",
450
+ "deleted_by_user_id",
451
+ "deleted_by_api_key_id",
452
+ "first_attempt_at",
453
+ "delivered_at",
454
+ "processing_ms",
455
+ "total_delivery_ms",
456
+ "queue_wait_ms",
457
+ "retention_hours",
458
+ ],
459
+ "MessageSummary": [
460
+ "message_id",
461
+ "endpoint",
462
+ "status",
463
+ "attempt_count",
464
+ "created_at",
465
+ "delivered_at",
466
+ "next_attempt_at",
467
+ "response_status",
468
+ "response_latency_ms",
469
+ "last_error",
470
+ "deleted_at",
471
+ "first_attempt_at",
472
+ "processing_ms",
473
+ "total_delivery_ms",
474
+ "queue_wait_ms",
475
+ ],
476
+ "Metrics": [
477
+ "window",
478
+ "total_messages",
479
+ "succeeded",
480
+ "failed",
481
+ "retries",
482
+ "success_rate",
483
+ "avg_latency_ms",
484
+ "avg_delivery_time_ms",
485
+ "avg_queue_wait_ms",
486
+ ],
487
+ "PauseState": ["id", "paused", "messages_requeued"],
488
+ "PullEndpoint": [
489
+ "id",
490
+ "mode",
491
+ "ingest_url",
492
+ "active",
493
+ "paused",
494
+ "created_at",
495
+ "updated_at",
496
+ "name",
497
+ "description",
498
+ "retention_days",
499
+ "event_type_source",
500
+ "event_type_path",
501
+ "counts",
502
+ "verify_static_token",
503
+ "token_header_name",
504
+ "token_query_param",
505
+ "verify_hmac",
506
+ "hmac_header_name",
507
+ "timestamp_header_name",
508
+ "timestamp_ttl_seconds",
509
+ "verify_ip_allowlist",
510
+ "allowed_cidrs",
511
+ "ingest_response_code",
512
+ "idempotency_header_names",
513
+ "hmac_signature_encoding",
514
+ ],
515
+ "PullEndpointCounts": ["stored", "fetched", "delivered", "total"],
516
+ "PullEndpointSummary": ["id", "active", "paused", "ingest_url", "created_at", "name"],
517
+ "PullEvent": [
518
+ "id",
519
+ "status",
520
+ "content_type",
521
+ "payload",
522
+ "size_bytes",
523
+ "received_at",
524
+ "event_type",
525
+ "headers",
526
+ "fetched_at",
527
+ "delivered_at",
528
+ "timing",
529
+ "deleted_at",
530
+ "deleted_by_user_id",
531
+ "deleted_by_api_key_id",
532
+ ],
533
+ "PullEventSummary": [
534
+ "id",
535
+ "status",
536
+ "size_bytes",
537
+ "received_at",
538
+ "event_type",
539
+ "fetched_at",
540
+ "delivered_at",
541
+ "timing",
542
+ "deleted_at",
543
+ ],
544
+ "PullLogEntry": [
545
+ "event_id",
546
+ "pull_endpoint_id",
547
+ "status",
548
+ "size_bytes",
549
+ "received_at",
550
+ "endpoint_name",
551
+ "event_type",
552
+ "fetched_at",
553
+ "delivered_at",
554
+ "timing",
555
+ ],
556
+ "PullLogsResponse": ["entries", "has_more", "next_cursor"],
557
+ "PullTimeSeriesBucket": ["timestamp", "succeeded", "stored", "fetched", "total"],
558
+ "PullTimeSeriesMetrics": ["window", "buckets"],
559
+ "PullTimingBreakdown": [
560
+ "ingest_processing_ms",
561
+ "time_to_fetch_ms",
562
+ "time_to_ack_ms",
563
+ "total_lifecycle_ms",
564
+ ],
565
+ "ReplayAllMessagesResponse": [
566
+ "replayed",
567
+ "failed",
568
+ "stuck",
569
+ "replayed_message_ids",
570
+ "stuck_message_ids",
571
+ ],
572
+ "ReplayBatchMessagesResponse": ["replayed", "failed", "stuck", "results"],
573
+ "ReplayBatchResult": ["message_id", "status", "error", "error_code"],
574
+ "ReplayMessageResponse": ["message_id", "status"],
575
+ "RotateSecretResponse": ["id", "signing_secret", "key_hint", "created_at"],
576
+ "SendWebhookResponse": ["message_id", "status"],
577
+ "SigningKey": ["id", "key_hint", "created_at"],
578
+ "Subscription": [
579
+ "plan",
580
+ "status",
581
+ "limits",
582
+ "usage",
583
+ "cancel_at_period_end",
584
+ "current_period_end",
585
+ ],
586
+ "SubscriptionLimits": [
587
+ "plan",
588
+ "messages_per_month",
589
+ "max_projects",
590
+ "max_endpoints",
591
+ "retention_days",
592
+ "max_retries",
593
+ "overage_rate_per_message",
594
+ ],
595
+ "SubscriptionUsage": [
596
+ "messages_used",
597
+ "period_start",
598
+ "period_end",
599
+ "overage_count",
600
+ "overage_rate",
601
+ "estimated_overage_charge",
602
+ ],
603
+ "TimeSeriesBucket": ["timestamp", "total", "succeeded", "failed", "retrying", "avg_latency_ms"],
604
+ "TimeSeriesMetrics": ["window", "buckets"],
605
+ "UpdateResult": ["id", "updated"],
606
+ "UsageHistoryResponse": ["rows", "total", "limit", "offset", "has_more"],
607
+ "UsageHistoryRow": [
608
+ "period_start",
609
+ "period_end",
610
+ "message_count",
611
+ "overage_count",
612
+ "plan_limit",
613
+ ],
614
+ }
@@ -0,0 +1,42 @@
1
+ """Version consistency tests."""
2
+
3
+ import re
4
+ from pathlib import Path
5
+
6
+ import hookbridge
7
+ from hookbridge import AsyncHookBridge, HookBridge
8
+
9
+ PYPROJECT = Path(__file__).resolve().parent.parent / "pyproject.toml"
10
+
11
+
12
+ def _pyproject_version() -> str:
13
+ text = PYPROJECT.read_text()
14
+ try:
15
+ import tomllib
16
+ except ImportError:
17
+ match = re.search(r'^version\s*=\s*"([^"]+)"', text, re.MULTILINE)
18
+ assert match is not None
19
+ return match.group(1)
20
+ version: str = tomllib.loads(text)["project"]["version"]
21
+ return version
22
+
23
+
24
+ def test_dunder_version_matches_pyproject() -> None:
25
+ assert hookbridge.__version__ == _pyproject_version()
26
+
27
+
28
+ def test_sync_client_user_agent_matches_version() -> None:
29
+ with HookBridge(api_key="hb_test_key") as client:
30
+ expected = f"hookbridge-python/{_pyproject_version()}"
31
+ assert client._client.headers["User-Agent"] == expected
32
+ assert client._send_client.headers["User-Agent"] == expected
33
+
34
+
35
+ async def test_async_client_user_agent_matches_version() -> None:
36
+ client = AsyncHookBridge(api_key="hb_test_key")
37
+ try:
38
+ expected = f"hookbridge-python/{_pyproject_version()}"
39
+ assert client._client.headers["User-Agent"] == expected
40
+ assert client._send_client.headers["User-Agent"] == expected
41
+ finally:
42
+ await client.close()
File without changes
File without changes
File without changes
File without changes