Webhooks
zenml.webhooks
Webhook provider and trusted event contracts.
Attributes
__all__ = ['BaseWebhookProvider', 'DynamicWebhookTargetEvent', 'ParsedWebhookDelivery', 'ParsedWebhookEvent', 'WebhookConfiguration', 'WebhookAuthenticationError', 'WebhookEvent', 'WebhookEventHandler', 'WebhookIntakeConfig', 'WebhookIntakeResponse', 'WebhookPayloadError', 'WebhookPreValidationResult', 'WebhookProviderRegistry', 'WebhookTargetEvent', 'WebhookTriggerMatch', 'get_webhook_provider', 'webhook_provider_registry']
module-attribute
webhook_provider_registry = WebhookProviderRegistry()
module-attribute
Classes
BaseWebhookProvider
Bases: ABC
Stateless provider behavior used by intake and trigger matching.
Methods:
authenticate(body: bytes, headers: Mapping[str, str], secret: str) -> None
abstractmethod
Authenticate the exact raw request body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
secret
|
str
|
The webhook signing secret. |
required |
Raises:
| Type | Description |
|---|---|
WebhookAuthenticationError
|
If authentication fails. |
Source code in src/zenml/webhooks/providers/base.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
get_delivery_id(payload: dict[str, Any], headers: Mapping[str, str]) -> str | None
Extract the optional delivery ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed JSON payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The delivery ID, if present. |
Source code in src/zenml/webhooks/providers/base.py
412 413 414 415 416 417 418 419 420 421 422 423 424 | |
get_event_type(payload: dict[str, Any], headers: Mapping[str, str]) -> str
abstractmethod
Extract the provider event type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed JSON payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The provider event type. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the type is missing or invalid. |
Source code in src/zenml/webhooks/providers/base.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
match_triggers(*, event: WebhookEvent, candidates: Sequence[WebhookTriggerResponse]) -> WebhookTriggerMatch[WebhookTriggerResponse]
abstractmethod
Match candidates and return the parsed semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted webhook event. |
required |
candidates
|
Sequence[WebhookTriggerResponse]
|
Triggers selected by generic orchestration. |
required |
Returns:
| Type | Description |
|---|---|
WebhookTriggerMatch[WebhookTriggerResponse]
|
The matching triggers and any parsed semantic event. |
Source code in src/zenml/webhooks/providers/base.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
parse(body: bytes, headers: Mapping[str, str]) -> ParsedWebhookEvent
Parse a delivery into provider-neutral event data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
ParsedWebhookEvent
|
The parsed delivery. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the body or metadata is invalid. |
Source code in src/zenml/webhooks/providers/base.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
parse_delivery(body: bytes, headers: Mapping[str, str]) -> ParsedWebhookDelivery
Parse a successful delivery and select its intake response.
Existing providers can continue to implement :meth:parse; providers
with control deliveries or custom responses can override this method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
ParsedWebhookDelivery
|
The parsed delivery and provider-owned response. |
Source code in src/zenml/webhooks/providers/base.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
pre_validate(headers: Mapping[str, str]) -> WebhookPreValidationResult
async
Validate headers before webhook lookup and body reading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers
|
Mapping[str, str]
|
The untrusted request headers. |
required |
Returns:
| Type | Description |
|---|---|
WebhookPreValidationResult
|
Whether generic intake should process or ignore the delivery. |
Source code in src/zenml/webhooks/providers/base.py
318 319 320 321 322 323 324 325 326 327 328 329 330 | |
validate_configuration(configuration: WebhookConfiguration | Mapping[str, Any]) -> WebhookConfiguration
Strictly validate a configuration for persistence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration
|
WebhookConfiguration | Mapping[str, Any]
|
The provider-neutral configuration. |
required |
Returns:
| Type | Description |
|---|---|
WebhookConfiguration
|
A normalized provider-neutral configuration. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a configuration for another provider is supplied. |
Source code in src/zenml/webhooks/providers/base.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
DynamicWebhookTargetEvent
Bases: WebhookTargetEvent
User-defined webhook event filter over an authenticated JSON body.
Methods:
matches(*, event_type: str, payload: Mapping[str, Any]) -> bool
Match a provider event type and authenticated JSON body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
The provider-specific raw event type. |
required |
payload
|
Mapping[str, Any]
|
The complete authenticated JSON body. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the event satisfies every configured filter. |
Source code in src/zenml/webhooks/providers/dynamic.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
validate_dynamic_filters() -> DynamicWebhookTargetEvent
Validate body filters and compile their paths.
Returns:
| Type | Description |
|---|---|
DynamicWebhookTargetEvent
|
The validated dynamic target event. |
Source code in src/zenml/webhooks/providers/dynamic.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
ParsedWebhookDelivery
Bases: BaseModel
A successful provider delivery and its intake response.
ParsedWebhookEvent
Bases: BaseModel
Provider delivery parsed into provider-neutral metadata.
WebhookAuthenticationError(message: Optional[str] = None, url: Optional[str] = None)
Bases: CredentialsNotValid
Raised when a webhook request cannot be authenticated.
Source code in src/zenml/exceptions.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
WebhookConfiguration
WebhookEvent
WebhookEventHandler
Bases: EventHandler
Base handler for trusted webhook events.
Methods:
handle_event(event: Event) -> None
Route trusted webhook events to the specialized handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Event
|
The dispatched event envelope. |
required |
Source code in src/zenml/webhooks/handler.py
25 26 27 28 29 30 31 32 | |
handle_webhook_event(event: WebhookEvent) -> None
abstractmethod
Handle a trusted webhook event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted webhook event. |
required |
Source code in src/zenml/webhooks/handler.py
34 35 36 37 38 39 40 | |
WebhookIntakeConfig
Bases: BaseModel
Configuration required to authenticate one webhook delivery.
WebhookIntakeResponse
Bases: BaseModel
Provider-owned successful webhook intake response.
WebhookPayloadError
Bases: ValueError
Raised when a webhook payload fails fundamental validation.
WebhookPreValidationResult
WebhookProviderRegistry()
Registry for webhook provider implementations.
Initialize the webhook provider registry.
Source code in src/zenml/webhooks/providers/registry.py
27 28 29 30 31 | |
Methods:
get(webhook_type: str) -> BaseWebhookProvider
Instantiate the provider registered for a webhook type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webhook_type
|
str
|
The webhook type identifier. |
required |
Returns:
| Type | Description |
|---|---|
BaseWebhookProvider
|
A new provider instance. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no provider is registered for the webhook type. |
Source code in src/zenml/webhooks/providers/registry.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
register(provider_class: type[BaseWebhookProvider], *, overwrite: bool = False) -> None
Register a webhook provider class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_class
|
type[BaseWebhookProvider]
|
The provider class to register. |
required |
overwrite
|
bool
|
Whether to replace an existing registration. |
False
|
Source code in src/zenml/webhooks/providers/registry.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
register_builtin_providers() -> None
Register the built-in webhook providers once, on demand.
Source code in src/zenml/webhooks/providers/registry.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
WebhookTargetEvent
Bases: BaseModel
Shared shape of a provider-specific target event.
Methods:
validate_filters() -> WebhookTargetEvent
Validate all configured string filters.
Returns:
| Type | Description |
|---|---|
WebhookTargetEvent
|
The validated target event. |
Source code in src/zenml/webhooks/providers/base.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
WebhookTriggerMatch
Bases: BaseModel, Generic[WebhookTriggerT]
Result of matching one trusted event to webhook triggers.
Functions:
get_webhook_provider(webhook_type: str) -> BaseWebhookProvider
Get the provider registered for a webhook type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webhook_type
|
str
|
The webhook type identifier. |
required |
Returns:
| Type | Description |
|---|---|
BaseWebhookProvider
|
A new provider instance. |
Source code in src/zenml/webhooks/providers/registry.py
105 106 107 108 109 110 111 112 113 114 | |
Modules
events
Provider-neutral trusted webhook event models.
Classes
WebhookEvent
handler
Event handler contract for trusted webhook events.
Classes
WebhookEventHandler
Bases: EventHandler
Base handler for trusted webhook events.
handle_event(event: Event) -> None
Route trusted webhook events to the specialized handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
Event
|
The dispatched event envelope. |
required |
Source code in src/zenml/webhooks/handler.py
25 26 27 28 29 30 31 32 | |
handle_webhook_event(event: WebhookEvent) -> None
abstractmethod
Handle a trusted webhook event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted webhook event. |
required |
Source code in src/zenml/webhooks/handler.py
34 35 36 37 38 39 40 | |
intake
Internal contracts for webhook intake.
Classes
WebhookIntakeConfig
Bases: BaseModel
Configuration required to authenticate one webhook delivery.
providers
Webhook provider contracts and registry.
Classes
BaseWebhookProvider
Bases: ABC
Stateless provider behavior used by intake and trigger matching.
authenticate(body: bytes, headers: Mapping[str, str], secret: str) -> None
abstractmethod
Authenticate the exact raw request body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
secret
|
str
|
The webhook signing secret. |
required |
Raises:
| Type | Description |
|---|---|
WebhookAuthenticationError
|
If authentication fails. |
Source code in src/zenml/webhooks/providers/base.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
get_delivery_id(payload: dict[str, Any], headers: Mapping[str, str]) -> str | None
Extract the optional delivery ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed JSON payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The delivery ID, if present. |
Source code in src/zenml/webhooks/providers/base.py
412 413 414 415 416 417 418 419 420 421 422 423 424 | |
get_event_type(payload: dict[str, Any], headers: Mapping[str, str]) -> str
abstractmethod
Extract the provider event type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed JSON payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The provider event type. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the type is missing or invalid. |
Source code in src/zenml/webhooks/providers/base.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
match_triggers(*, event: WebhookEvent, candidates: Sequence[WebhookTriggerResponse]) -> WebhookTriggerMatch[WebhookTriggerResponse]
abstractmethod
Match candidates and return the parsed semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted webhook event. |
required |
candidates
|
Sequence[WebhookTriggerResponse]
|
Triggers selected by generic orchestration. |
required |
Returns:
| Type | Description |
|---|---|
WebhookTriggerMatch[WebhookTriggerResponse]
|
The matching triggers and any parsed semantic event. |
Source code in src/zenml/webhooks/providers/base.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
parse(body: bytes, headers: Mapping[str, str]) -> ParsedWebhookEvent
Parse a delivery into provider-neutral event data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
ParsedWebhookEvent
|
The parsed delivery. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the body or metadata is invalid. |
Source code in src/zenml/webhooks/providers/base.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
parse_delivery(body: bytes, headers: Mapping[str, str]) -> ParsedWebhookDelivery
Parse a successful delivery and select its intake response.
Existing providers can continue to implement :meth:parse; providers
with control deliveries or custom responses can override this method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
ParsedWebhookDelivery
|
The parsed delivery and provider-owned response. |
Source code in src/zenml/webhooks/providers/base.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
pre_validate(headers: Mapping[str, str]) -> WebhookPreValidationResult
async
Validate headers before webhook lookup and body reading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers
|
Mapping[str, str]
|
The untrusted request headers. |
required |
Returns:
| Type | Description |
|---|---|
WebhookPreValidationResult
|
Whether generic intake should process or ignore the delivery. |
Source code in src/zenml/webhooks/providers/base.py
318 319 320 321 322 323 324 325 326 327 328 329 330 | |
validate_configuration(configuration: WebhookConfiguration | Mapping[str, Any]) -> WebhookConfiguration
Strictly validate a configuration for persistence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration
|
WebhookConfiguration | Mapping[str, Any]
|
The provider-neutral configuration. |
required |
Returns:
| Type | Description |
|---|---|
WebhookConfiguration
|
A normalized provider-neutral configuration. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a configuration for another provider is supplied. |
Source code in src/zenml/webhooks/providers/base.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
BuiltinWebhookType
DynamicWebhookTargetEvent
Bases: WebhookTargetEvent
User-defined webhook event filter over an authenticated JSON body.
matches(*, event_type: str, payload: Mapping[str, Any]) -> bool
Match a provider event type and authenticated JSON body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
The provider-specific raw event type. |
required |
payload
|
Mapping[str, Any]
|
The complete authenticated JSON body. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the event satisfies every configured filter. |
Source code in src/zenml/webhooks/providers/dynamic.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
validate_dynamic_filters() -> DynamicWebhookTargetEvent
Validate body filters and compile their paths.
Returns:
| Type | Description |
|---|---|
DynamicWebhookTargetEvent
|
The validated dynamic target event. |
Source code in src/zenml/webhooks/providers/dynamic.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
ParsedWebhookDelivery
Bases: BaseModel
A successful provider delivery and its intake response.
ParsedWebhookEvent
Bases: BaseModel
Provider delivery parsed into provider-neutral metadata.
WebhookAuthenticationError(message: Optional[str] = None, url: Optional[str] = None)
Bases: CredentialsNotValid
Raised when a webhook request cannot be authenticated.
Source code in src/zenml/exceptions.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
WebhookConfiguration
WebhookIntakeResponse
Bases: BaseModel
Provider-owned successful webhook intake response.
WebhookPayloadError
Bases: ValueError
Raised when a webhook payload fails fundamental validation.
WebhookPreValidationResult
WebhookProviderRegistry()
Registry for webhook provider implementations.
Initialize the webhook provider registry.
Source code in src/zenml/webhooks/providers/registry.py
27 28 29 30 31 | |
get(webhook_type: str) -> BaseWebhookProvider
Instantiate the provider registered for a webhook type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webhook_type
|
str
|
The webhook type identifier. |
required |
Returns:
| Type | Description |
|---|---|
BaseWebhookProvider
|
A new provider instance. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no provider is registered for the webhook type. |
Source code in src/zenml/webhooks/providers/registry.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
register(provider_class: type[BaseWebhookProvider], *, overwrite: bool = False) -> None
Register a webhook provider class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_class
|
type[BaseWebhookProvider]
|
The provider class to register. |
required |
overwrite
|
bool
|
Whether to replace an existing registration. |
False
|
Source code in src/zenml/webhooks/providers/registry.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
register_builtin_providers() -> None
Register the built-in webhook providers once, on demand.
Source code in src/zenml/webhooks/providers/registry.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
WebhookTargetEvent
Bases: BaseModel
Shared shape of a provider-specific target event.
validate_filters() -> WebhookTargetEvent
Validate all configured string filters.
Returns:
| Type | Description |
|---|---|
WebhookTargetEvent
|
The validated target event. |
Source code in src/zenml/webhooks/providers/base.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
WebhookTriggerMatch
Bases: BaseModel, Generic[WebhookTriggerT]
Result of matching one trusted event to webhook triggers.
Functions:
get_webhook_provider(webhook_type: str) -> BaseWebhookProvider
Get the provider registered for a webhook type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webhook_type
|
str
|
The webhook type identifier. |
required |
Returns:
| Type | Description |
|---|---|
BaseWebhookProvider
|
A new provider instance. |
Source code in src/zenml/webhooks/providers/registry.py
105 106 107 108 109 110 111 112 113 114 | |
Modules
base
Shared contracts for stateless webhook providers.
BaseWebhookProvider
Bases: ABC
Stateless provider behavior used by intake and trigger matching.
authenticate(body: bytes, headers: Mapping[str, str], secret: str) -> None
abstractmethod
Authenticate the exact raw request body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
secret
|
str
|
The webhook signing secret. |
required |
Raises:
| Type | Description |
|---|---|
WebhookAuthenticationError
|
If authentication fails. |
Source code in src/zenml/webhooks/providers/base.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
get_delivery_id(payload: dict[str, Any], headers: Mapping[str, str]) -> str | None
Extract the optional delivery ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed JSON payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The delivery ID, if present. |
Source code in src/zenml/webhooks/providers/base.py
412 413 414 415 416 417 418 419 420 421 422 423 424 | |
get_event_type(payload: dict[str, Any], headers: Mapping[str, str]) -> str
abstractmethod
Extract the provider event type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed JSON payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The provider event type. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the type is missing or invalid. |
Source code in src/zenml/webhooks/providers/base.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
match_triggers(*, event: WebhookEvent, candidates: Sequence[WebhookTriggerResponse]) -> WebhookTriggerMatch[WebhookTriggerResponse]
abstractmethod
Match candidates and return the parsed semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted webhook event. |
required |
candidates
|
Sequence[WebhookTriggerResponse]
|
Triggers selected by generic orchestration. |
required |
Returns:
| Type | Description |
|---|---|
WebhookTriggerMatch[WebhookTriggerResponse]
|
The matching triggers and any parsed semantic event. |
Source code in src/zenml/webhooks/providers/base.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
parse(body: bytes, headers: Mapping[str, str]) -> ParsedWebhookEvent
Parse a delivery into provider-neutral event data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
ParsedWebhookEvent
|
The parsed delivery. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the body or metadata is invalid. |
Source code in src/zenml/webhooks/providers/base.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |
parse_delivery(body: bytes, headers: Mapping[str, str]) -> ParsedWebhookDelivery
Parse a successful delivery and select its intake response.
Existing providers can continue to implement :meth:parse; providers
with control deliveries or custom responses can override this method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
ParsedWebhookDelivery
|
The parsed delivery and provider-owned response. |
Source code in src/zenml/webhooks/providers/base.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
pre_validate(headers: Mapping[str, str]) -> WebhookPreValidationResult
async
Validate headers before webhook lookup and body reading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers
|
Mapping[str, str]
|
The untrusted request headers. |
required |
Returns:
| Type | Description |
|---|---|
WebhookPreValidationResult
|
Whether generic intake should process or ignore the delivery. |
Source code in src/zenml/webhooks/providers/base.py
318 319 320 321 322 323 324 325 326 327 328 329 330 | |
validate_configuration(configuration: WebhookConfiguration | Mapping[str, Any]) -> WebhookConfiguration
Strictly validate a configuration for persistence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration
|
WebhookConfiguration | Mapping[str, Any]
|
The provider-neutral configuration. |
required |
Returns:
| Type | Description |
|---|---|
WebhookConfiguration
|
A normalized provider-neutral configuration. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a configuration for another provider is supplied. |
Source code in src/zenml/webhooks/providers/base.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
ParsedWebhookDelivery
Bases: BaseModel
A successful provider delivery and its intake response.
ParsedWebhookEvent
Bases: BaseModel
Provider delivery parsed into provider-neutral metadata.
WebhookAuthenticationError(message: Optional[str] = None, url: Optional[str] = None)
Bases: CredentialsNotValid
Raised when a webhook request cannot be authenticated.
Source code in src/zenml/exceptions.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
WebhookConfiguration
WebhookIntakeResponse
Bases: BaseModel
Provider-owned successful webhook intake response.
WebhookPayloadError
Bases: ValueError
Raised when a webhook payload fails fundamental validation.
WebhookPreValidationResult
WebhookTargetEvent
Bases: BaseModel
Shared shape of a provider-specific target event.
validate_filters() -> WebhookTargetEvent
Validate all configured string filters.
Returns:
| Type | Description |
|---|---|
WebhookTargetEvent
|
The validated target event. |
Source code in src/zenml/webhooks/providers/base.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
WebhookTriggerMatch
Bases: BaseModel, Generic[WebhookTriggerT]
Result of matching one trusted event to webhook triggers.
authenticate_hmac_sha256(*, body: bytes, headers: Mapping[str, str], secret: str, header: str, prefixed: bool = True) -> None
Authenticate an HMAC-SHA256 signature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The exact request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
secret
|
str
|
The signing secret. |
required |
header
|
str
|
The signature header name. |
required |
prefixed
|
bool
|
If |
True
|
Raises:
| Type | Description |
|---|---|
WebhookAuthenticationError
|
If the signature is invalid. |
Source code in src/zenml/webhooks/providers/base.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
matches_string_collection_filter(*, actual: Sequence[str], configured: StringFilterOption) -> bool
Match a collection against a configured string filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
actual
|
Sequence[str]
|
Values extracted from the webhook event. |
required |
configured
|
StringFilterOption
|
The configured string filter or OR-list of filters. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether any value satisfies a positive filter or every value satisfies |
bool
|
a negative filter. |
Source code in src/zenml/webhooks/providers/base.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
matches_string_filter(*, actual: str | None, configured: StringFilterOption) -> bool
Match an extracted value against a supported string filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
actual
|
str | None
|
The value extracted from the webhook event. |
required |
configured
|
StringFilterOption
|
The configured string filter or OR-list of filters. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the extracted value matches the configured filter. |
Source code in src/zenml/webhooks/providers/base.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
clickup
ClickUp webhook provider and semantic target event catalog.
ClickUpListCreatedEvent
ClickUpListDeletedEvent
ClickUpListSemanticEvent
Bases: ClickUpSemanticEvent
Normalized ClickUp list event with shared location filters.
matches(target: ClickUpWebhookTargetEvent) -> bool
Return whether this event matches a typed list target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
ClickUpWebhookTargetEvent
|
The typed target event configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this event matches the target. |
Source code in src/zenml/webhooks/providers/clickup.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
ClickUpListUpdatedEvent
ClickUpSemanticEvent
Bases: BaseModel
Normalized ClickUp event used for trigger matching.
matches(target: ClickUpWebhookTargetEvent) -> bool
abstractmethod
Return whether the semantic event matches its typed target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
ClickUpWebhookTargetEvent
|
The typed target event configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the semantic event matches the target. |
Source code in src/zenml/webhooks/providers/clickup.py
320 321 322 323 324 325 326 327 328 329 | |
ClickUpTaskAssigneeUpdatedEvent
ClickUpTaskCommentPostedEvent
ClickUpTaskCreatedEvent
ClickUpTaskDeletedEvent
ClickUpTaskMovedEvent
ClickUpTaskSemanticEvent
Bases: ClickUpSemanticEvent
Normalized ClickUp task event with shared location filters.
matches(target: ClickUpWebhookTargetEvent) -> bool
Return whether this event matches a typed task target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
ClickUpWebhookTargetEvent
|
The typed target event configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this event matches the target. |
Source code in src/zenml/webhooks/providers/clickup.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
ClickUpTaskStatusUpdatedEvent
Bases: ClickUpTaskSemanticEvent
Normalized task-status-updated event.
matches(target: ClickUpWebhookTargetEvent) -> bool
Return whether this event matches a status-updated target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
ClickUpWebhookTargetEvent
|
The typed target event configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this event matches the target. |
Source code in src/zenml/webhooks/providers/clickup.py
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
ClickUpTaskUpdatedEvent
ClickUpWebhookConfiguration
ClickUpWebhookEvent
ClickUpWebhookProvider
Bases: BaseWebhookProvider
Provider for authenticated and semantically matched ClickUp webhooks.
authenticate(body: bytes, headers: Mapping[str, str], secret: str) -> None
Authenticate a ClickUp delivery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The exact raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
secret
|
str
|
The webhook signing secret. |
required |
Source code in src/zenml/webhooks/providers/clickup.py
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
get_delivery_id(payload: dict[str, Any], headers: Mapping[str, str]) -> str | None
Build ClickUp's documented idempotency key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed ClickUp payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The documented history-based delivery ID, if available. Intake |
str | None
|
generates a unique ID for history-less events. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If webhook_id is missing. |
Source code in src/zenml/webhooks/providers/clickup.py
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | |
get_event_type(payload: dict[str, Any], headers: Mapping[str, str]) -> str
Extract the ClickUp event name from the JSON body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed ClickUp payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The ClickUp event name. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the event field is missing or empty. |
Source code in src/zenml/webhooks/providers/clickup.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | |
match_triggers(*, event: WebhookEvent, candidates: Sequence[WebhookTriggerResponse]) -> WebhookTriggerMatch[WebhookTriggerResponse]
Match ClickUp triggers and return the parsed semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted ClickUp webhook event. |
required |
candidates
|
Sequence[WebhookTriggerResponse]
|
The candidate webhook triggers. |
required |
Returns:
| Type | Description |
|---|---|
WebhookTriggerMatch[WebhookTriggerResponse]
|
Matching triggers and their shared semantic event. |
Source code in src/zenml/webhooks/providers/clickup.py
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | |
parse_semantic_event(event: WebhookEvent) -> ClickUpSemanticEvent | None
Parse a trusted delivery into a normalized semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted ClickUp webhook event. |
required |
Returns:
| Type | Description |
|---|---|
ClickUpSemanticEvent | None
|
The normalized semantic event, or |
Source code in src/zenml/webhooks/providers/clickup.py
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | |
ListCreated
Bases: _ClickUpListTarget
Filters for a created ClickUp list.
ListDeleted
Bases: _ClickUpListTarget
Filters for a deleted ClickUp list.
ListUpdated
Bases: _ClickUpListTarget
Filters for an updated ClickUp list.
TaskAssigneeUpdated
Bases: _ClickUpTaskTarget
Filters for a ClickUp task assignee change.
TaskCommentPosted
Bases: _ClickUpTaskTarget
Filters for a comment posted on a ClickUp task.
TaskCreated
Bases: _ClickUpTaskTarget
Filters for a created ClickUp task.
TaskDeleted
Bases: _ClickUpTaskTarget
Filters for a deleted ClickUp task.
TaskMoved
Bases: _ClickUpTaskTarget
Filters for a ClickUp task moved to another list.
TaskStatusUpdated
Bases: _ClickUpTaskStatusTarget
Filters for a ClickUp task status change.
TaskUpdated
Bases: _ClickUpTaskTarget
Filters for an updated ClickUp task.
custom
Custom webhook provider.
CustomWebhookConfiguration
CustomWebhookProvider
Bases: BaseWebhookProvider
Provider for signed custom JSON webhook deliveries.
authenticate(body: bytes, headers: Mapping[str, str], secret: str) -> None
Authenticate a custom delivery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
secret
|
str
|
The signing secret. |
required |
Source code in src/zenml/webhooks/providers/custom.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
get_delivery_id(payload: dict[str, Any], headers: Mapping[str, str]) -> str | None
Extract the optional custom delivery ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The delivery ID, if present. |
Source code in src/zenml/webhooks/providers/custom.py
88 89 90 91 92 93 94 95 96 97 98 99 100 | |
get_event_type(payload: dict[str, Any], headers: Mapping[str, str]) -> str
Extract the custom event type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The event type. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the event header is missing. |
Source code in src/zenml/webhooks/providers/custom.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
match_triggers(*, event: WebhookEvent, candidates: Sequence[WebhookTriggerResponse]) -> WebhookTriggerMatch[WebhookTriggerResponse]
Match candidates using optional dynamic custom filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted custom event. |
required |
candidates
|
Sequence[WebhookTriggerResponse]
|
The associated candidate triggers. |
required |
Returns:
| Type | Description |
|---|---|
WebhookTriggerMatch[WebhookTriggerResponse]
|
Matching candidates without semantic event metadata. |
Source code in src/zenml/webhooks/providers/custom.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
dynamic
Dynamic webhook target filters over authenticated JSON payloads.
DynamicWebhookTargetEvent
Bases: WebhookTargetEvent
User-defined webhook event filter over an authenticated JSON body.
matches(*, event_type: str, payload: Mapping[str, Any]) -> bool
Match a provider event type and authenticated JSON body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
The provider-specific raw event type. |
required |
payload
|
Mapping[str, Any]
|
The complete authenticated JSON body. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the event satisfies every configured filter. |
Source code in src/zenml/webhooks/providers/dynamic.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
validate_dynamic_filters() -> DynamicWebhookTargetEvent
Validate body filters and compile their paths.
Returns:
| Type | Description |
|---|---|
DynamicWebhookTargetEvent
|
The validated dynamic target event. |
Source code in src/zenml/webhooks/providers/dynamic.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
matches_webhook_target(*, target: WebhookTargetEvent, event_type: str, payload: Mapping[str, Any], semantic_matcher: Callable[[Any], bool] | None) -> bool
Dispatch matching to a dynamic or provider-semantic target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
WebhookTargetEvent
|
The configured webhook target. |
required |
event_type
|
str
|
The provider-specific raw event type. |
required |
payload
|
Mapping[str, Any]
|
The complete authenticated JSON body. |
required |
semantic_matcher
|
Callable[[Any], bool] | None
|
Provider semantic matching, when parsing succeeded. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the provider event matches the target. |
Source code in src/zenml/webhooks/providers/dynamic.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
github
GitHub webhook provider and semantic target event catalog.
GitHubCommit
Bases: BaseModel
Commit metadata associated with a GitHub semantic event.
GitHubIssueOpenedEvent
Bases: GitHubSemanticEvent
Normalized newly opened issue event.
matches(target: GitHubWebhookTargetEvent) -> bool
Return whether this event matches an opened-issue target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
GitHubWebhookTargetEvent
|
The typed target event configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this event matches the target. |
Source code in src/zenml/webhooks/providers/github.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
GitHubMergedPullRequestEvent
Bases: GitHubSemanticEvent
Normalized merged pull request event.
matches(target: GitHubWebhookTargetEvent) -> bool
Return whether this event matches a merged-pull-request target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
GitHubWebhookTargetEvent
|
The typed target event configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this event matches the target. |
Source code in src/zenml/webhooks/providers/github.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
GitHubPushEvent
Bases: GitHubSemanticEvent
Normalized branch push event.
matches(target: GitHubWebhookTargetEvent) -> bool
Return whether this event matches a push target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
GitHubWebhookTargetEvent
|
The typed target event configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this event matches the target. |
Source code in src/zenml/webhooks/providers/github.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
GitHubReleasePublishedEvent
Bases: GitHubSemanticEvent
Normalized published release event.
matches(target: GitHubWebhookTargetEvent) -> bool
Return whether this event matches a published-release target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
GitHubWebhookTargetEvent
|
The typed target event configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this event matches the target. |
Source code in src/zenml/webhooks/providers/github.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
GitHubSemanticEvent
Bases: BaseModel
Provider event normalized for semantic trigger matching.
matches(target: GitHubWebhookTargetEvent) -> bool
abstractmethod
Return whether the semantic event matches its typed target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
GitHubWebhookTargetEvent
|
The typed target event configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the semantic event matches the target. |
Source code in src/zenml/webhooks/providers/github.py
190 191 192 193 194 195 196 197 198 199 | |
GitHubWebhookConfiguration
GitHubWebhookEvent
GitHubWebhookEventType
GitHubWebhookProvider
Bases: BaseWebhookProvider
Provider for authenticated and semantically matched GitHub webhooks.
authenticate(body: bytes, headers: Mapping[str, str], secret: str) -> None
Authenticate a GitHub delivery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The exact raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
secret
|
str
|
The webhook signing secret. |
required |
Source code in src/zenml/webhooks/providers/github.py
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
get_delivery_id(payload: dict[str, Any], headers: Mapping[str, str]) -> str | None
Extract the optional GitHub delivery ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed GitHub payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The delivery ID, if present. |
Source code in src/zenml/webhooks/providers/github.py
482 483 484 485 486 487 488 489 490 491 492 493 494 | |
get_event_type(payload: dict[str, Any], headers: Mapping[str, str]) -> str
Extract the raw GitHub event family.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed GitHub payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The raw GitHub event family. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the GitHub event header is missing. |
Source code in src/zenml/webhooks/providers/github.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |
match_triggers(*, event: WebhookEvent, candidates: Sequence[WebhookTriggerResponse]) -> WebhookTriggerMatch[WebhookTriggerResponse]
Match GitHub triggers and return the parsed semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted GitHub webhook event. |
required |
candidates
|
Sequence[WebhookTriggerResponse]
|
The candidate webhook triggers. |
required |
Returns:
| Type | Description |
|---|---|
WebhookTriggerMatch[WebhookTriggerResponse]
|
Matching triggers and their shared semantic event. |
Source code in src/zenml/webhooks/providers/github.py
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
parse_semantic_event(event: WebhookEvent) -> GitHubSemanticEvent | None
Parse a trusted delivery into a normalized semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted GitHub webhook event. |
required |
Returns:
| Type | Description |
|---|---|
GitHubSemanticEvent | None
|
The normalized semantic event, or |
Source code in src/zenml/webhooks/providers/github.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | |
pre_validate(headers: Mapping[str, str]) -> WebhookPreValidationResult
async
Reject missing event metadata before processing a GitHub delivery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers
|
Mapping[str, str]
|
The untrusted request headers. |
required |
Returns:
| Type | Description |
|---|---|
WebhookPreValidationResult
|
Whether generic intake should process or ignore the delivery. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the GitHub event header is missing. |
Source code in src/zenml/webhooks/providers/github.py
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | |
GitHubWorkflowRunCompletedEvent
Bases: GitHubSemanticEvent
Normalized completed workflow run event.
matches(target: GitHubWebhookTargetEvent) -> bool
Return whether this event matches a workflow-run target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
GitHubWebhookTargetEvent
|
The typed target event configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this event matches the target. |
Source code in src/zenml/webhooks/providers/github.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
IssueOpened
MergedPullRequest
PushEvent
ReleasePublished
WorkflowRunCompleted
registry
Registry for webhook provider implementations.
WebhookProviderRegistry()
Registry for webhook provider implementations.
Initialize the webhook provider registry.
Source code in src/zenml/webhooks/providers/registry.py
27 28 29 30 31 | |
get(webhook_type: str) -> BaseWebhookProvider
Instantiate the provider registered for a webhook type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webhook_type
|
str
|
The webhook type identifier. |
required |
Returns:
| Type | Description |
|---|---|
BaseWebhookProvider
|
A new provider instance. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no provider is registered for the webhook type. |
Source code in src/zenml/webhooks/providers/registry.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
register(provider_class: type[BaseWebhookProvider], *, overwrite: bool = False) -> None
Register a webhook provider class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider_class
|
type[BaseWebhookProvider]
|
The provider class to register. |
required |
overwrite
|
bool
|
Whether to replace an existing registration. |
False
|
Source code in src/zenml/webhooks/providers/registry.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
register_builtin_providers() -> None
Register the built-in webhook providers once, on demand.
Source code in src/zenml/webhooks/providers/registry.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
get_webhook_provider(webhook_type: str) -> BaseWebhookProvider
Get the provider registered for a webhook type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webhook_type
|
str
|
The webhook type identifier. |
required |
Returns:
| Type | Description |
|---|---|
BaseWebhookProvider
|
A new provider instance. |
Source code in src/zenml/webhooks/providers/registry.py
105 106 107 108 109 110 111 112 113 114 | |
slack
Slack Events API webhook provider.
AppMentionEventFilter
FileSharedEventFilter
MessageEventFilter
Bases: SlackEventFilter
Filters for a Slack message event.
validate_subtype_filters() -> MessageEventFilter
Reject competing broad and targeted subtype selection.
Returns:
| Type | Description |
|---|---|
MessageEventFilter
|
The validated message event filter. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If all subtypes and named subtypes are both selected. |
Source code in src/zenml/webhooks/providers/slack.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
MessageMetadataPostedEventFilter
Bases: _MessageMetadataEventFilter
Filters for Slack message metadata being posted.
MessageMetadataUpdatedEventFilter
Bases: _MessageMetadataEventFilter
Filters for Slack message metadata being updated.
ReactionAddedEventFilter
Bases: _ReactionEventFilter
Filters for a Slack reaction being added.
ReactionRemovedEventFilter
Bases: _ReactionEventFilter
Filters for a Slack reaction being removed.
SlackAppMentionEvent
Bases: SlackChannelEvent
Normalized Slack app mention.
matches(target: SlackSemanticEventFilter) -> bool
Return whether this mention matches an app-mention target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
SlackSemanticEventFilter
|
The typed Slack target event. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this mention matches the target. |
Source code in src/zenml/webhooks/providers/slack.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
SlackChannelEvent
Bases: SlackUserEvent
Base event with a required Slack channel identifier.
matches(target: SlackSemanticEventFilter) -> bool
Match the required channel identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
SlackSemanticEventFilter
|
The typed Slack target event. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the event's team, user, and channel match the target. |
Source code in src/zenml/webhooks/providers/slack.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
SlackEventFilter
SlackFileSharedEvent
Bases: SlackChannelEvent
Normalized Slack file-shared event.
matches(target: SlackSemanticEventFilter) -> bool
Return whether this file share matches a file-share target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
SlackSemanticEventFilter
|
The typed Slack target event. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this file share matches the target. |
Source code in src/zenml/webhooks/providers/slack.py
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | |
SlackMessageEvent
Bases: SlackSemanticEvent
Normalized Slack message event.
matches(target: SlackSemanticEventFilter) -> bool
Return whether this message matches a message target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
SlackSemanticEventFilter
|
The typed Slack target event. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this message matches the target. |
Source code in src/zenml/webhooks/providers/slack.py
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | |
SlackMessageMetadata
Bases: BaseModel
Structured metadata attached to a Slack message.
SlackMessageMetadataEvent
Bases: SlackChannelEvent
Shared normalized fields for a Slack message-metadata event.
matches(target: SlackSemanticEventFilter) -> bool
Return whether this metadata event matches its typed target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
SlackSemanticEventFilter
|
The typed Slack target event. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this metadata event matches the target. |
Source code in src/zenml/webhooks/providers/slack.py
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |
SlackMessageMetadataPostedEvent
SlackMessageMetadataUpdatedEvent
SlackReactionAddedEvent
SlackReactionEvent
Bases: SlackUserEvent
Shared normalized fields for a Slack reaction event.
matches(target: SlackSemanticEventFilter) -> bool
Return whether this reaction matches its reaction target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
SlackSemanticEventFilter
|
The typed Slack target event. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether this reaction matches the target. |
Source code in src/zenml/webhooks/providers/slack.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
SlackReactionItem
Bases: BaseModel
Normalized item referenced by a Slack reaction event.
SlackReactionRemovedEvent
SlackSemanticEvent
Bases: BaseModel
Provider event normalized for semantic trigger matching.
matches(target: SlackSemanticEventFilter) -> bool
Match identifiers shared by all Slack semantic events.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
SlackSemanticEventFilter
|
The typed Slack target event. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the event's team matches the target. |
Source code in src/zenml/webhooks/providers/slack.py
233 234 235 236 237 238 239 240 241 242 243 244 | |
SlackUserEvent
Bases: SlackSemanticEvent
Base event with a required Slack user identifier.
matches(target: SlackSemanticEventFilter) -> bool
Match the required user identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
SlackSemanticEventFilter
|
The typed Slack target event. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Whether the event's team and user match the target. |
Source code in src/zenml/webhooks/providers/slack.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
SlackWebhookConfiguration
SlackWebhookEventType
SlackWebhookProvider
Bases: BaseWebhookProvider
Provider for signed Slack Events API deliveries.
authenticate(body: bytes, headers: Mapping[str, str], secret: str) -> None
Authenticate a Slack delivery using its exact raw body.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
secret
|
str
|
The Slack app signing secret. |
required |
Raises:
| Type | Description |
|---|---|
WebhookAuthenticationError
|
If the request cannot be authenticated. |
Source code in src/zenml/webhooks/providers/slack.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
get_event_type(payload: dict[str, Any], headers: Mapping[str, str]) -> str
Reject direct event parsing in favor of delivery parsing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict[str, Any]
|
The parsed Slack payload. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
str
|
This method never returns successfully. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always, because Slack has control deliveries. |
Source code in src/zenml/webhooks/providers/slack.py
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | |
match_triggers(*, event: WebhookEvent, candidates: Sequence[WebhookTriggerResponse]) -> WebhookTriggerMatch[WebhookTriggerResponse]
Match candidates and return the parsed semantic event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted webhook event. |
required |
candidates
|
Sequence[WebhookTriggerResponse]
|
Triggers selected by generic orchestration. |
required |
Returns:
| Type | Description |
|---|---|
WebhookTriggerMatch[WebhookTriggerResponse]
|
The matching triggers and any parsed semantic event. |
Source code in src/zenml/webhooks/providers/slack.py
781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | |
parse_delivery(body: bytes, headers: Mapping[str, str]) -> ParsedWebhookDelivery
Parse a Slack event or control delivery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
body
|
bytes
|
The raw request body. |
required |
headers
|
Mapping[str, str]
|
The request headers. |
required |
Returns:
| Type | Description |
|---|---|
ParsedWebhookDelivery
|
The optional event and Slack-compatible response. |
Raises:
| Type | Description |
|---|---|
WebhookPayloadError
|
If the Slack envelope is malformed. |
Source code in src/zenml/webhooks/providers/slack.py
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | |
parse_semantic_event(event: WebhookEvent) -> SlackSemanticEvent | None
Normalize a trusted Slack event for trigger matching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
WebhookEvent
|
The trusted Slack webhook event. |
required |
Returns:
| Type | Description |
|---|---|
SlackSemanticEvent | None
|
The normalized supported event, or |
Source code in src/zenml/webhooks/providers/slack.py
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 | |
types
Identifiers for webhook providers bundled with ZenML.
BuiltinWebhookType