hookbase 4.1.0__tar.gz → 4.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 (100) hide show
  1. {hookbase-4.1.0 → hookbase-4.3.0}/PKG-INFO +145 -5
  2. {hookbase-4.1.0 → hookbase-4.3.0}/README.md +144 -4
  3. {hookbase-4.1.0 → hookbase-4.3.0}/examples/basic_inbound.py +3 -1
  4. {hookbase-4.1.0 → hookbase-4.3.0}/examples/send_webhooks.py +3 -1
  5. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/_client.py +24 -3
  6. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/_pagination.py +6 -2
  7. hookbase-4.3.0/src/hookbase/_version.py +1 -0
  8. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/__init__.py +59 -0
  9. hookbase-4.3.0/src/hookbase/models/_base.py +20 -0
  10. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/api_keys.py +5 -3
  11. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/cron_jobs.py +13 -5
  12. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/deliveries.py +22 -2
  13. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/destinations.py +128 -15
  14. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/endpoints.py +37 -9
  15. hookbase-4.3.0/src/hookbase/models/events.py +245 -0
  16. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/messages.py +26 -0
  17. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/portal_tokens.py +7 -2
  18. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/routes.py +18 -0
  19. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/sources.py +275 -10
  20. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/transforms.py +49 -3
  21. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/tunnels.py +10 -6
  22. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/_base.py +9 -6
  23. hookbase-4.3.0/src/hookbase/resources/deliveries.py +186 -0
  24. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/destinations.py +82 -8
  25. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/sources.py +171 -0
  26. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/transforms.py +15 -0
  27. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_destinations.py +229 -1
  28. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_endpoints.py +73 -1
  29. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_inbound_contract.py +244 -0
  30. hookbase-4.3.0/tests/resources/test_open_types.py +94 -0
  31. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_outbound_contract.py +89 -1
  32. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_resource_contracts.py +141 -0
  33. hookbase-4.3.0/tests/resources/test_source_connections.py +539 -0
  34. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_source_fields.py +12 -3
  35. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_sources.py +50 -1
  36. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_sync_async_parity.py +181 -1
  37. {hookbase-4.1.0 → hookbase-4.3.0}/tests/test_models_exports.py +23 -0
  38. {hookbase-4.1.0 → hookbase-4.3.0}/tests/test_retry.py +2 -0
  39. hookbase-4.3.0/tests/test_secret_redaction.py +225 -0
  40. hookbase-4.1.0/src/hookbase/_version.py +0 -1
  41. hookbase-4.1.0/src/hookbase/models/_base.py +0 -14
  42. hookbase-4.1.0/src/hookbase/models/events.py +0 -116
  43. hookbase-4.1.0/src/hookbase/resources/deliveries.py +0 -99
  44. {hookbase-4.1.0 → hookbase-4.3.0}/.github/workflows/python-publish.yml +0 -0
  45. {hookbase-4.1.0 → hookbase-4.3.0}/.gitignore +0 -0
  46. {hookbase-4.1.0 → hookbase-4.3.0}/LICENSE +0 -0
  47. {hookbase-4.1.0 → hookbase-4.3.0}/examples/async_usage.py +0 -0
  48. {hookbase-4.1.0 → hookbase-4.3.0}/examples/error_handling.py +0 -0
  49. {hookbase-4.1.0 → hookbase-4.3.0}/examples/verify_webhooks.py +0 -0
  50. {hookbase-4.1.0 → hookbase-4.3.0}/pyproject.toml +0 -0
  51. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/__init__.py +0 -0
  52. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/_constants.py +0 -0
  53. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/client.py +0 -0
  54. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/errors.py +0 -0
  55. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/_wire.py +0 -0
  56. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/analytics.py +0 -0
  57. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/applications.py +0 -0
  58. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/catalog.py +0 -0
  59. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/common.py +0 -0
  60. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/dlq.py +0 -0
  61. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/event_types.py +0 -0
  62. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/filters.py +0 -0
  63. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/organizations.py +0 -0
  64. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/schemas.py +0 -0
  65. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/models/subscriptions.py +0 -0
  66. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/py.typed +0 -0
  67. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/__init__.py +0 -0
  68. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/analytics.py +0 -0
  69. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/api_keys.py +0 -0
  70. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/applications.py +0 -0
  71. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/cron_jobs.py +0 -0
  72. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/dlq.py +0 -0
  73. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/endpoints.py +0 -0
  74. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/event_types.py +0 -0
  75. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/events.py +0 -0
  76. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/filters.py +0 -0
  77. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/message_log.py +0 -0
  78. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/messages.py +0 -0
  79. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/organizations.py +0 -0
  80. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/portal_tokens.py +0 -0
  81. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/providers.py +0 -0
  82. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/routes.py +0 -0
  83. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/schemas.py +0 -0
  84. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/subscriptions.py +0 -0
  85. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/resources/tunnels.py +0 -0
  86. {hookbase-4.1.0 → hookbase-4.3.0}/src/hookbase/webhook.py +0 -0
  87. {hookbase-4.1.0 → hookbase-4.3.0}/tests/__init__.py +0 -0
  88. {hookbase-4.1.0 → hookbase-4.3.0}/tests/conftest.py +0 -0
  89. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/__init__.py +0 -0
  90. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_applications.py +0 -0
  91. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_cron_jobs.py +0 -0
  92. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_dlq.py +0 -0
  93. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_messages.py +0 -0
  94. {hookbase-4.1.0 → hookbase-4.3.0}/tests/resources/test_source_contract.py +0 -0
  95. {hookbase-4.1.0 → hookbase-4.3.0}/tests/test_client.py +0 -0
  96. {hookbase-4.1.0 → hookbase-4.3.0}/tests/test_errors.py +0 -0
  97. {hookbase-4.1.0 → hookbase-4.3.0}/tests/test_http_client.py +0 -0
  98. {hookbase-4.1.0 → hookbase-4.3.0}/tests/test_pagination.py +0 -0
  99. {hookbase-4.1.0 → hookbase-4.3.0}/tests/test_slug_contract.py +0 -0
  100. {hookbase-4.1.0 → hookbase-4.3.0}/tests/test_webhook.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: hookbase
3
- Version: 4.1.0
3
+ Version: 4.3.0
4
4
  Summary: Official Python SDK for the Hookbase webhook management platform
5
5
  Project-URL: Homepage, https://hookbase.app
6
6
  Project-URL: Documentation, https://www.hookbase.app/docs/send/sdk
@@ -140,28 +140,89 @@ client.sources.rotate_verify_token(wa.id)
140
140
  pending = client.sources.get_pending_verification("notion")
141
141
  client.sources.adopt_pending_verification("notion")
142
142
 
143
+ # Connected sources: give Hookbase a least-privilege provider key (Stripe, GitHub or Paddle) and
144
+ # it registers the webhook, holds its signing secret, and recovers events the provider failed to
145
+ # deliver (Pro and Business). The key is never returned or logged, and ConnectSourceParams
146
+ # leaves it out of repr().
147
+ result = client.sources.connect("src_id", {"provider": "stripe", "credential": "rk_live_..."})
148
+ result.connection.status, result.connection.credential_hint, result.warnings
149
+ client.sources.connect("src_gh", {"provider": "github", "credential": "github_pat_...",
150
+ "githubRepository": "acme/api", "events": ["push"]})
151
+ client.sources.get_connection("src_id") # None when not connected; .last_run, .recovered_total
152
+ client.sources.update_connection("src_id", {"credential": "rk_live_..."}) # replace the key
153
+ client.sources.update_connection("src_id", {"reconcileEnabled": False})
154
+ client.sources.run_recovery("src_id") # True; ConflictError with details["reason"] if refused
155
+ client.sources.list_recovery_items("src_id", status="gave_up", limit=20)
156
+ client.sources.disconnect("src_id") # .remote_removed, .retrying, .message
157
+ client.sources.get("src_id").connection # summary on list() and get(); None if not connected
158
+ client.events.get("evt_id").recovery # .method, .recovered_at when recovery delivered it
159
+
143
160
  # Provider catalog: which secret each provider needs (public, no auth needed)
144
161
  for p in client.providers.list(category="payments").providers:
145
162
  print(p.hookbase_provider, p.signature_verification and p.signature_verification.secret_source)
146
163
  client.providers.get("stripe").signature_verification
147
164
 
165
+ # Record the catalog entry a source is made from (create only). Entries with no verifier of
166
+ # their own, such as Salesforce, save as Custom HMAC:
167
+ client.sources.create({"name": "Salesforce", "slug": "salesforce", "provider": "custom",
168
+ "catalogProvider": "salesforce"})
169
+
148
170
  # Destinations
149
171
  client.destinations.list()
150
- client.destinations.create({"name": "Backend", "url": "https://..."})
172
+ dest = client.destinations.create({"name": "Backend", "url": "https://..."})
151
173
  client.destinations.test("dst_id")
152
174
 
175
+ # HTTP destinations sign every delivery (Standard Webhooks headers), so the receiver can check
176
+ # it with Webhook(secret).verify(). Create returns the secret once: put it in your secret store.
177
+ # repr() and str() leave it out, so logging the destination doesn't leak it.
178
+ signing_secret = dest.signing_secret # whsec_...; dest.has_signing_secret is True
179
+ client.destinations.reveal_secret("dst_id").signing_secret
180
+ rotated = client.destinations.rotate_secret("dst_id", grace_period_seconds=3600)
181
+ rotated.previous_secret_expires_at # until then the old secret signs too
182
+
183
+ # Bridge destinations publish each delivery they receive as an outbound event
184
+ from hookbase.models import BridgeConfig, CreateDestinationParams
185
+
186
+ bridge = client.destinations.create(CreateDestinationParams(
187
+ name="Orders to customers",
188
+ type="bridge",
189
+ config=BridgeConfig(event_type_source="field", event_type_field="type",
190
+ event_type_prefix="order."),
191
+ ))
192
+ # A bridge's test is a dry run: nothing is published
193
+ result = client.destinations.test(bridge.id, payload={"type": "created"})
194
+ result.event_type, result.event_type_exists, result.matching_endpoints
195
+
153
196
  # Routes
154
197
  client.routes.create({"name": "Route", "sourceId": "src_id", "destinationId": "dst_id"})
155
198
  client.routes.get_circuit_status("route_id")
156
199
  client.routes.reset_circuit("route_id")
157
200
 
201
+ # While a route's circuit is open its deliveries are held (status "held", hold_expires_at set)
202
+ # and go out when it closes. hold_on_circuit_open=False dead-letters them as soon as the circuit
203
+ # opens instead.
204
+ client.routes.update("route_id", {"holdOnCircuitOpen": False})
205
+ client.routes.get("route_id").held_count # get only; held_count_capped past 10,000
206
+
158
207
  # Events & Deliveries
159
208
  client.events.list(source_id="src_id", from_date="2024-01-01") # id or slug; unknown -> 404
160
209
  client.events.get("evt_id") # Includes payload and deliveries
210
+ client.events.debug("evt_id").curl_command # plus typed deliveries, pattern hints, circuit state
161
211
  client.deliveries.replay("del_id")
162
212
  client.deliveries.bulk_replay(["del_1", "del_2"])
163
213
 
214
+ # Replay with edits. payload_patch is an RFC 7386 merge patch on the stored payload (None
215
+ # removes a key), so it works on sources that mask fields; modified_payload replaces it. An
216
+ # argument left as None is not sent.
217
+ client.deliveries.replay(
218
+ "del_id",
219
+ payload_patch={"amount": 10, "coupon": None},
220
+ destination_override="backup-destination", # id or slug
221
+ headers_override={"X-Replay": "1"},
222
+ )
223
+
164
224
  # Transforms & Filters
225
+ client.transforms.engines() # languages this deployment runs, and which are available
165
226
  client.transforms.create({"name": "Extract", "transformType": "jsonata", "code": "$.data"})
166
227
  client.transforms.test(code="$.data", payload={"data": {"key": "value"}}) # .result
167
228
  client.filters.test(
@@ -189,18 +250,26 @@ client.outbound.endpoints.rotate_secret("ep_id", grace_period=3600)
189
250
  # this". Name the setting in `clear` to send an explicit null for it:
190
251
  client.outbound.endpoints.update("ep_id", {"clear": ["retryDelays"]})
191
252
 
253
+ # While an endpoint's circuit is open its messages are held (status "held") and go out when it
254
+ # recovers; hold_on_circuit_open=False dead-letters them instead. FIFO endpoints never hold.
255
+ client.outbound.endpoints.update("ep_id", {"holdOnCircuitOpen": False})
256
+ client.outbound.endpoints.get("ep_id").held_count
257
+
192
258
  # Event Types & Subscriptions
193
259
  client.outbound.event_types.create({"name": "order.created", "category": "orders"})
194
260
  client.outbound.subscriptions.create({"endpointId": "ep_id", "eventTypeId": "et_id"})
195
261
  client.outbound.subscriptions.bulk_create("ep_id", ["et_1", "et_2"])
196
262
 
197
263
  # Send Events
198
- client.outbound.messages.send("app_id", event_type="order.created", payload={"orderId": "ord_1"})
264
+ sent = client.outbound.messages.send("app_id", event_type="order.created",
265
+ payload={"orderId": "ord_1"})
266
+ sent.messages_held # of messages_queued, those held behind an open circuit (None if none)
199
267
 
200
268
  # Message Log
201
- client.outbound.message_log.list(application_id="app_id")
269
+ client.outbound.message_log.list(application_id="app_id", status="held") # .hold_expires_at
270
+ client.outbound.message_log.get("msg_id").bridge # set when a bridge destination published it
202
271
  client.outbound.message_log.list_attempts("msg_id")
203
- client.outbound.message_log.stats()
272
+ client.outbound.message_log.stats() # .held among the counts
204
273
 
205
274
  # Dead Letter Queue
206
275
  client.outbound.dlq.list()
@@ -366,6 +435,10 @@ Up to `max_retries` retries (default 3):
366
435
  is retried only when it carries an idempotency key (`outbound.messages.send` always does).
367
436
  - **A connection that was never made** is always retried.
368
437
  - **Other 4xx** responses are never retried.
438
+ - `sources.connect()`, and `sources.update_connection()` with a `credential`, are not retried
439
+ after a 5xx, a read timeout or a dropped connection, since a second attempt could register the
440
+ provider webhook twice. A 429 is still retried. After such a failure (or a 503 with code
441
+ `CONNECT_OUTCOME_UNKNOWN`), call `sources.get_connection()` before connecting again.
369
442
 
370
443
  ### Pydantic Models
371
444
 
@@ -385,6 +458,73 @@ source = client.sources.create({"name": "GitHub", "slug": "github", "provider":
385
458
  # source with a provider newer than this package still parses.
386
459
  ```
387
460
 
461
+ ## Upgrading to 4.3
462
+
463
+ - Connected sources: `sources.connect()`, `get_connection()`, `update_connection()`,
464
+ `disconnect()`, `run_recovery()` and `list_recovery_items()`, with the models
465
+ `ConnectSourceParams`, `UpdateSourceConnectionParams`, `SourceConnection`,
466
+ `ConnectSourceResult`, `DisconnectSourceResult`, `RecoveryRun` and `RecoveryItem`.
467
+ `credential` is left out of `repr()`, `str()` and validation errors, and is never logged.
468
+ `connect()` (and `update_connection()` with a `credential`) is not retried after a 5xx, a
469
+ timeout or a dropped connection; see [Retries](#retries).
470
+ - `Source.connection` (`SourceConnectionSummary`: provider, status, environment,
471
+ reconcile_enabled) on `list()` and `get()`, None when the source isn't connected.
472
+ - `EventDetail.recovery` and `events.debug().event.recovery` (`EventRecovery`: method,
473
+ recovered_at), set when recovery got the event to its source.
474
+ - The connection error codes (`INVALID_CREDENTIAL`, `PROVIDER_CREDENTIAL_INVALID`,
475
+ `CONNECTION_CONFLICT`, `CONNECT_OUTCOME_UNKNOWN`, ...) arrive in `APIError.code`; a refused
476
+ `run_recovery()` carries its `reason` in `details`, and a 429 its `retryAfter` there too.
477
+
478
+ ## Upgrading to 4.2
479
+
480
+ - **Fix:** `destinations.list()` and `get()` raised a `ValidationError` when the organization had
481
+ a destination of a type other than `http`, `s3`, `r2`, `gcs` or `azure_blob` (`sqs`,
482
+ `eventbridge`, `servicebus`, `pubsub`, `oci_queue`, `bridge`). `DestinationType`,
483
+ `TransformType` and `ContentFormat` now accept any string, as `MessageStatus` does, so types
484
+ added later parse too. `"form"`, which the API never accepted, is gone from `ContentFormat`.
485
+ - **Fix:** `events.debug()` returned an empty `curl_command`, `event.headers` and
486
+ `event.payload`; they are filled in now. Its `deliveries` are typed (`EventDebugDelivery`).
487
+ - `destinations.create()` returns a `DestinationWithSecret`, whose `signing_secret` is the only
488
+ time the secret is returned; afterwards use `reveal_secret()`. `rotate_secret()` takes
489
+ `grace_period_seconds`. `Destination.has_signing_secret` says whether deliveries are signed.
490
+ - Bridge destinations: `BridgeConfig` for `config`, `Destination.bridge_config` to read it,
491
+ `destinations.test(id, payload=...)` for a dry run, and the dry-run fields on `TestResult`.
492
+ - `deliveries.replay()` takes `modified_payload`, `payload_patch`, `destination_override`,
493
+ `transform_override`, `headers_override` and `persist_transform`; `ReplayResult` reports what
494
+ changed. Passing both payload edits raises `ValueError`. An argument left as None is not sent,
495
+ so `modified_payload` can be any JSON value but null. The same goes for `payload` on
496
+ `destinations.test()`.
497
+ - Holds: the `held` status on deliveries and outbound messages, with `hold_expires_at`;
498
+ `hold_on_circuit_open`, `held_count` and `held_count_capped` on routes and webhook endpoints;
499
+ `messages_held` on `SendEventResponse` and `held` on `StatsSummary`. `MessageStatus` also
500
+ gains `awaiting_pull` and `fifo_waiting`.
501
+ - `transforms.engines()` lists the transform languages the deployment runs.
502
+ - `catalog_provider` on sources (set on create only).
503
+ - `sources.export()` returns a raw dict, and the API now sends its `ipAllowlist`, `ipDenylist`,
504
+ `encryptFields` and `maskFields` as JSON arrays; they used to be JSON-encoded strings. Code
505
+ that calls `json.loads` on them must stop. The `Source` model already read either form.
506
+ - Secrets and credentials no longer appear in `repr()` or `str()`:
507
+ - The secrets the API returns, on `DestinationWithSecret`, `DestinationSecret`,
508
+ `SourceWithSecret`, `PendingVerification`, `WebhookEndpoint`, `EndpointWithSecret`,
509
+ `RotateSecretResult`, `ApiKeyWithSecret`, `Tunnel`, `TunnelToken` and `PortalToken`.
510
+ - The headers and auth configs the API returns in full to a key with the `write` scope:
511
+ `Destination.headers` and `auth_config`, `WebhookEndpoint.headers` (and each
512
+ `CustomHeader.value`), and `CronJob.headers`.
513
+ - The credentials you pass in: `signing_secret` and `verify_token` on `CreateSourceParams`
514
+ and `UpdateSourceParams`; `headers`, `auth_config` and `config` on `CreateDestinationParams`
515
+ and `UpdateDestinationParams`; `headers` on the endpoint and cron job params; and the keys
516
+ on `S3Config`, `GCSConfig` and `AzureBlobConfig`.
517
+
518
+ A `pydantic.ValidationError` from one of these models, or from a list of them, leaves out the
519
+ input it was given. The values are still sent and still readable from their attributes
520
+ (`dest.signing_secret`).
521
+ - **Typing:** `CreateDestinationParams.config` and `UpdateDestinationParams.config` are now
522
+ `dict[str, Any] | BridgeConfig | None`, so `params.config["bucket"]` no longer type-checks
523
+ until you narrow it with `isinstance(params.config, dict)`. Because `DestinationType`,
524
+ `TransformType` and `ContentFormat` now include `str`, mypy reads `Destination.type`,
525
+ `Transform.transform_type`, `input_format` and `output_format` as plain `str`. An exhaustive
526
+ `match` or `assert_never` over their literals no longer type-checks.
527
+
388
528
  ## Upgrading to 4.1
389
529
 
390
530
  - `APIError.code` now carries the API's `code` from the response body (for example
@@ -102,28 +102,89 @@ client.sources.rotate_verify_token(wa.id)
102
102
  pending = client.sources.get_pending_verification("notion")
103
103
  client.sources.adopt_pending_verification("notion")
104
104
 
105
+ # Connected sources: give Hookbase a least-privilege provider key (Stripe, GitHub or Paddle) and
106
+ # it registers the webhook, holds its signing secret, and recovers events the provider failed to
107
+ # deliver (Pro and Business). The key is never returned or logged, and ConnectSourceParams
108
+ # leaves it out of repr().
109
+ result = client.sources.connect("src_id", {"provider": "stripe", "credential": "rk_live_..."})
110
+ result.connection.status, result.connection.credential_hint, result.warnings
111
+ client.sources.connect("src_gh", {"provider": "github", "credential": "github_pat_...",
112
+ "githubRepository": "acme/api", "events": ["push"]})
113
+ client.sources.get_connection("src_id") # None when not connected; .last_run, .recovered_total
114
+ client.sources.update_connection("src_id", {"credential": "rk_live_..."}) # replace the key
115
+ client.sources.update_connection("src_id", {"reconcileEnabled": False})
116
+ client.sources.run_recovery("src_id") # True; ConflictError with details["reason"] if refused
117
+ client.sources.list_recovery_items("src_id", status="gave_up", limit=20)
118
+ client.sources.disconnect("src_id") # .remote_removed, .retrying, .message
119
+ client.sources.get("src_id").connection # summary on list() and get(); None if not connected
120
+ client.events.get("evt_id").recovery # .method, .recovered_at when recovery delivered it
121
+
105
122
  # Provider catalog: which secret each provider needs (public, no auth needed)
106
123
  for p in client.providers.list(category="payments").providers:
107
124
  print(p.hookbase_provider, p.signature_verification and p.signature_verification.secret_source)
108
125
  client.providers.get("stripe").signature_verification
109
126
 
127
+ # Record the catalog entry a source is made from (create only). Entries with no verifier of
128
+ # their own, such as Salesforce, save as Custom HMAC:
129
+ client.sources.create({"name": "Salesforce", "slug": "salesforce", "provider": "custom",
130
+ "catalogProvider": "salesforce"})
131
+
110
132
  # Destinations
111
133
  client.destinations.list()
112
- client.destinations.create({"name": "Backend", "url": "https://..."})
134
+ dest = client.destinations.create({"name": "Backend", "url": "https://..."})
113
135
  client.destinations.test("dst_id")
114
136
 
137
+ # HTTP destinations sign every delivery (Standard Webhooks headers), so the receiver can check
138
+ # it with Webhook(secret).verify(). Create returns the secret once: put it in your secret store.
139
+ # repr() and str() leave it out, so logging the destination doesn't leak it.
140
+ signing_secret = dest.signing_secret # whsec_...; dest.has_signing_secret is True
141
+ client.destinations.reveal_secret("dst_id").signing_secret
142
+ rotated = client.destinations.rotate_secret("dst_id", grace_period_seconds=3600)
143
+ rotated.previous_secret_expires_at # until then the old secret signs too
144
+
145
+ # Bridge destinations publish each delivery they receive as an outbound event
146
+ from hookbase.models import BridgeConfig, CreateDestinationParams
147
+
148
+ bridge = client.destinations.create(CreateDestinationParams(
149
+ name="Orders to customers",
150
+ type="bridge",
151
+ config=BridgeConfig(event_type_source="field", event_type_field="type",
152
+ event_type_prefix="order."),
153
+ ))
154
+ # A bridge's test is a dry run: nothing is published
155
+ result = client.destinations.test(bridge.id, payload={"type": "created"})
156
+ result.event_type, result.event_type_exists, result.matching_endpoints
157
+
115
158
  # Routes
116
159
  client.routes.create({"name": "Route", "sourceId": "src_id", "destinationId": "dst_id"})
117
160
  client.routes.get_circuit_status("route_id")
118
161
  client.routes.reset_circuit("route_id")
119
162
 
163
+ # While a route's circuit is open its deliveries are held (status "held", hold_expires_at set)
164
+ # and go out when it closes. hold_on_circuit_open=False dead-letters them as soon as the circuit
165
+ # opens instead.
166
+ client.routes.update("route_id", {"holdOnCircuitOpen": False})
167
+ client.routes.get("route_id").held_count # get only; held_count_capped past 10,000
168
+
120
169
  # Events & Deliveries
121
170
  client.events.list(source_id="src_id", from_date="2024-01-01") # id or slug; unknown -> 404
122
171
  client.events.get("evt_id") # Includes payload and deliveries
172
+ client.events.debug("evt_id").curl_command # plus typed deliveries, pattern hints, circuit state
123
173
  client.deliveries.replay("del_id")
124
174
  client.deliveries.bulk_replay(["del_1", "del_2"])
125
175
 
176
+ # Replay with edits. payload_patch is an RFC 7386 merge patch on the stored payload (None
177
+ # removes a key), so it works on sources that mask fields; modified_payload replaces it. An
178
+ # argument left as None is not sent.
179
+ client.deliveries.replay(
180
+ "del_id",
181
+ payload_patch={"amount": 10, "coupon": None},
182
+ destination_override="backup-destination", # id or slug
183
+ headers_override={"X-Replay": "1"},
184
+ )
185
+
126
186
  # Transforms & Filters
187
+ client.transforms.engines() # languages this deployment runs, and which are available
127
188
  client.transforms.create({"name": "Extract", "transformType": "jsonata", "code": "$.data"})
128
189
  client.transforms.test(code="$.data", payload={"data": {"key": "value"}}) # .result
129
190
  client.filters.test(
@@ -151,18 +212,26 @@ client.outbound.endpoints.rotate_secret("ep_id", grace_period=3600)
151
212
  # this". Name the setting in `clear` to send an explicit null for it:
152
213
  client.outbound.endpoints.update("ep_id", {"clear": ["retryDelays"]})
153
214
 
215
+ # While an endpoint's circuit is open its messages are held (status "held") and go out when it
216
+ # recovers; hold_on_circuit_open=False dead-letters them instead. FIFO endpoints never hold.
217
+ client.outbound.endpoints.update("ep_id", {"holdOnCircuitOpen": False})
218
+ client.outbound.endpoints.get("ep_id").held_count
219
+
154
220
  # Event Types & Subscriptions
155
221
  client.outbound.event_types.create({"name": "order.created", "category": "orders"})
156
222
  client.outbound.subscriptions.create({"endpointId": "ep_id", "eventTypeId": "et_id"})
157
223
  client.outbound.subscriptions.bulk_create("ep_id", ["et_1", "et_2"])
158
224
 
159
225
  # Send Events
160
- client.outbound.messages.send("app_id", event_type="order.created", payload={"orderId": "ord_1"})
226
+ sent = client.outbound.messages.send("app_id", event_type="order.created",
227
+ payload={"orderId": "ord_1"})
228
+ sent.messages_held # of messages_queued, those held behind an open circuit (None if none)
161
229
 
162
230
  # Message Log
163
- client.outbound.message_log.list(application_id="app_id")
231
+ client.outbound.message_log.list(application_id="app_id", status="held") # .hold_expires_at
232
+ client.outbound.message_log.get("msg_id").bridge # set when a bridge destination published it
164
233
  client.outbound.message_log.list_attempts("msg_id")
165
- client.outbound.message_log.stats()
234
+ client.outbound.message_log.stats() # .held among the counts
166
235
 
167
236
  # Dead Letter Queue
168
237
  client.outbound.dlq.list()
@@ -328,6 +397,10 @@ Up to `max_retries` retries (default 3):
328
397
  is retried only when it carries an idempotency key (`outbound.messages.send` always does).
329
398
  - **A connection that was never made** is always retried.
330
399
  - **Other 4xx** responses are never retried.
400
+ - `sources.connect()`, and `sources.update_connection()` with a `credential`, are not retried
401
+ after a 5xx, a read timeout or a dropped connection, since a second attempt could register the
402
+ provider webhook twice. A 429 is still retried. After such a failure (or a 503 with code
403
+ `CONNECT_OUTCOME_UNKNOWN`), call `sources.get_connection()` before connecting again.
331
404
 
332
405
  ### Pydantic Models
333
406
 
@@ -347,6 +420,73 @@ source = client.sources.create({"name": "GitHub", "slug": "github", "provider":
347
420
  # source with a provider newer than this package still parses.
348
421
  ```
349
422
 
423
+ ## Upgrading to 4.3
424
+
425
+ - Connected sources: `sources.connect()`, `get_connection()`, `update_connection()`,
426
+ `disconnect()`, `run_recovery()` and `list_recovery_items()`, with the models
427
+ `ConnectSourceParams`, `UpdateSourceConnectionParams`, `SourceConnection`,
428
+ `ConnectSourceResult`, `DisconnectSourceResult`, `RecoveryRun` and `RecoveryItem`.
429
+ `credential` is left out of `repr()`, `str()` and validation errors, and is never logged.
430
+ `connect()` (and `update_connection()` with a `credential`) is not retried after a 5xx, a
431
+ timeout or a dropped connection; see [Retries](#retries).
432
+ - `Source.connection` (`SourceConnectionSummary`: provider, status, environment,
433
+ reconcile_enabled) on `list()` and `get()`, None when the source isn't connected.
434
+ - `EventDetail.recovery` and `events.debug().event.recovery` (`EventRecovery`: method,
435
+ recovered_at), set when recovery got the event to its source.
436
+ - The connection error codes (`INVALID_CREDENTIAL`, `PROVIDER_CREDENTIAL_INVALID`,
437
+ `CONNECTION_CONFLICT`, `CONNECT_OUTCOME_UNKNOWN`, ...) arrive in `APIError.code`; a refused
438
+ `run_recovery()` carries its `reason` in `details`, and a 429 its `retryAfter` there too.
439
+
440
+ ## Upgrading to 4.2
441
+
442
+ - **Fix:** `destinations.list()` and `get()` raised a `ValidationError` when the organization had
443
+ a destination of a type other than `http`, `s3`, `r2`, `gcs` or `azure_blob` (`sqs`,
444
+ `eventbridge`, `servicebus`, `pubsub`, `oci_queue`, `bridge`). `DestinationType`,
445
+ `TransformType` and `ContentFormat` now accept any string, as `MessageStatus` does, so types
446
+ added later parse too. `"form"`, which the API never accepted, is gone from `ContentFormat`.
447
+ - **Fix:** `events.debug()` returned an empty `curl_command`, `event.headers` and
448
+ `event.payload`; they are filled in now. Its `deliveries` are typed (`EventDebugDelivery`).
449
+ - `destinations.create()` returns a `DestinationWithSecret`, whose `signing_secret` is the only
450
+ time the secret is returned; afterwards use `reveal_secret()`. `rotate_secret()` takes
451
+ `grace_period_seconds`. `Destination.has_signing_secret` says whether deliveries are signed.
452
+ - Bridge destinations: `BridgeConfig` for `config`, `Destination.bridge_config` to read it,
453
+ `destinations.test(id, payload=...)` for a dry run, and the dry-run fields on `TestResult`.
454
+ - `deliveries.replay()` takes `modified_payload`, `payload_patch`, `destination_override`,
455
+ `transform_override`, `headers_override` and `persist_transform`; `ReplayResult` reports what
456
+ changed. Passing both payload edits raises `ValueError`. An argument left as None is not sent,
457
+ so `modified_payload` can be any JSON value but null. The same goes for `payload` on
458
+ `destinations.test()`.
459
+ - Holds: the `held` status on deliveries and outbound messages, with `hold_expires_at`;
460
+ `hold_on_circuit_open`, `held_count` and `held_count_capped` on routes and webhook endpoints;
461
+ `messages_held` on `SendEventResponse` and `held` on `StatsSummary`. `MessageStatus` also
462
+ gains `awaiting_pull` and `fifo_waiting`.
463
+ - `transforms.engines()` lists the transform languages the deployment runs.
464
+ - `catalog_provider` on sources (set on create only).
465
+ - `sources.export()` returns a raw dict, and the API now sends its `ipAllowlist`, `ipDenylist`,
466
+ `encryptFields` and `maskFields` as JSON arrays; they used to be JSON-encoded strings. Code
467
+ that calls `json.loads` on them must stop. The `Source` model already read either form.
468
+ - Secrets and credentials no longer appear in `repr()` or `str()`:
469
+ - The secrets the API returns, on `DestinationWithSecret`, `DestinationSecret`,
470
+ `SourceWithSecret`, `PendingVerification`, `WebhookEndpoint`, `EndpointWithSecret`,
471
+ `RotateSecretResult`, `ApiKeyWithSecret`, `Tunnel`, `TunnelToken` and `PortalToken`.
472
+ - The headers and auth configs the API returns in full to a key with the `write` scope:
473
+ `Destination.headers` and `auth_config`, `WebhookEndpoint.headers` (and each
474
+ `CustomHeader.value`), and `CronJob.headers`.
475
+ - The credentials you pass in: `signing_secret` and `verify_token` on `CreateSourceParams`
476
+ and `UpdateSourceParams`; `headers`, `auth_config` and `config` on `CreateDestinationParams`
477
+ and `UpdateDestinationParams`; `headers` on the endpoint and cron job params; and the keys
478
+ on `S3Config`, `GCSConfig` and `AzureBlobConfig`.
479
+
480
+ A `pydantic.ValidationError` from one of these models, or from a list of them, leaves out the
481
+ input it was given. The values are still sent and still readable from their attributes
482
+ (`dest.signing_secret`).
483
+ - **Typing:** `CreateDestinationParams.config` and `UpdateDestinationParams.config` are now
484
+ `dict[str, Any] | BridgeConfig | None`, so `params.config["bucket"]` no longer type-checks
485
+ until you narrow it with `isinstance(params.config, dict)`. Because `DestinationType`,
486
+ `TransformType` and `ContentFormat` now include `str`, mypy reads `Destination.type`,
487
+ `Transform.transform_type`, `input_format` and `output_format` as plain `str`. An exhaustive
488
+ `match` or `assert_never` over their literals no longer type-checks.
489
+
350
490
  ## Upgrading to 4.1
351
491
 
352
492
  - `APIError.code` now carries the API's `code` from the response body (for example
@@ -13,7 +13,9 @@ source = client.sources.create({
13
13
  })
14
14
  print(f"Source created: {source.id}")
15
15
  print(f"Ingest URL: {source.ingest_url}")
16
- print(f"Signing secret: {source.signing_secret}")
16
+ # The signing secret is returned this once. Put it in your secret store (and GitHub's webhook
17
+ # settings) instead of printing or logging it; client.sources.reveal_secret() shows it again.
18
+ github_signing_secret = source.signing_secret
17
19
 
18
20
  # Create a destination to forward webhooks to
19
21
  dest = client.destinations.create({
@@ -18,7 +18,9 @@ endpoint = client.outbound.endpoints.create(app.id, {
18
18
  "description": "Production webhook endpoint",
19
19
  })
20
20
  print(f"Endpoint: {endpoint.id}")
21
- print(f"Endpoint secret: {endpoint.secret}")
21
+ # The endpoint's signing secret is returned this once. Put it in your secret store, and hand it to
22
+ # the customer to verify deliveries with, instead of printing or logging it.
23
+ endpoint_secret = endpoint.secret
22
24
 
23
25
  # Create event types
24
26
  order_type = client.outbound.event_types.create({
@@ -74,11 +74,18 @@ def _parse_retry_after(header: str | None, now: float | None = None) -> float:
74
74
  # server (a 5xx, a read timeout, a dropped connection) can do it twice. Only retry those when the
75
75
  # request carries an idempotency key the server can deduplicate on. A 429 was rejected before any
76
76
  # work was done, and a connect failure never reached the server, so those stay retryable.
77
+ #
78
+ # A few requests that are not POSTs have the same problem, and the resource opts them out with
79
+ # `retry_ambiguous=False`: a source connect (PUT /connection, or a PATCH that carries a new key)
80
+ # registers a webhook at the provider and spends the hourly connect limit, so sending it again after
81
+ # an unknown outcome can register the webhook twice.
77
82
  _NON_IDEMPOTENT_METHODS = frozenset({"POST"})
78
83
 
79
84
 
80
- def _may_repeat(method: str, idempotency_key: str | None) -> bool:
85
+ def _may_repeat(method: str, idempotency_key: str | None, retry_ambiguous: bool = True) -> bool:
81
86
  """Whether a request that may already have been processed is safe to send again."""
87
+ if not retry_ambiguous:
88
+ return False
82
89
  return method.upper() not in _NON_IDEMPOTENT_METHODS or bool(idempotency_key)
83
90
 
84
91
 
@@ -252,10 +259,17 @@ class SyncTransport(_BaseTransport):
252
259
  json: Any = None,
253
260
  params: dict[str, Any] | None = None,
254
261
  idempotency_key: str | None = None,
262
+ retry_ambiguous: bool = True,
255
263
  ) -> Any:
264
+ """Send one request, retrying as the module's retry policy allows.
265
+
266
+ ``retry_ambiguous=False`` never resends after a failure the server may have acted on (a
267
+ 5xx, a read timeout, a dropped connection), whatever the method. A 429, and a connection
268
+ that was never made, are still retried.
269
+ """
256
270
  kwargs = self._request_kwargs(json, params, idempotency_key)
257
271
  url = self._url(path)
258
- repeatable = _may_repeat(method, idempotency_key)
272
+ repeatable = _may_repeat(method, idempotency_key, retry_ambiguous)
259
273
  self._log(method, path, kwargs["params"])
260
274
 
261
275
  last_exc: Exception | None = None
@@ -337,12 +351,19 @@ class AsyncTransport(_BaseTransport):
337
351
  json: Any = None,
338
352
  params: dict[str, Any] | None = None,
339
353
  idempotency_key: str | None = None,
354
+ retry_ambiguous: bool = True,
340
355
  ) -> Any:
356
+ """Send one request, retrying as the module's retry policy allows.
357
+
358
+ ``retry_ambiguous=False`` never resends after a failure the server may have acted on (a
359
+ 5xx, a read timeout, a dropped connection), whatever the method. A 429, and a connection
360
+ that was never made, are still retried.
361
+ """
341
362
  import asyncio
342
363
 
343
364
  kwargs = self._request_kwargs(json, params, idempotency_key)
344
365
  url = self._url(path)
345
- repeatable = _may_repeat(method, idempotency_key)
366
+ repeatable = _may_repeat(method, idempotency_key, retry_ambiguous)
346
367
  self._log(method, path, kwargs["params"])
347
368
 
348
369
  last_exc: Exception | None = None
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  from collections.abc import AsyncIterator, Iterator
4
4
  from typing import Any, Generic, TypeVar
5
5
 
6
- from pydantic import TypeAdapter
6
+ from pydantic import ConfigDict, TypeAdapter
7
7
 
8
8
  from ._client import AsyncTransport, SyncTransport
9
9
 
@@ -360,7 +360,11 @@ class AsyncLimitOffsetPage(Generic[T]):
360
360
 
361
361
 
362
362
  def _parse_list(raw: Any, model: type[T]) -> list[T]:
363
- adapter = TypeAdapter(list[model]) # type: ignore[valid-type]
363
+ # pydantic takes hide_input_in_errors from the outermost type, so a list of a model that
364
+ # carries a secret has to ask for it too (models/_base.py SECRET_MODEL_CONFIG).
365
+ hides_input = getattr(model, "model_config", {}).get("hide_input_in_errors", False)
366
+ config = ConfigDict(hide_input_in_errors=True) if hides_input else None
367
+ adapter = TypeAdapter(list[model], config=config) # type: ignore[valid-type]
364
368
  return adapter.validate_python(raw)
365
369
 
366
370
 
@@ -0,0 +1 @@
1
+ __version__ = "4.3.0"