API Docs¶
Invenio module for processing webhook events.
-
class
invenio_webhooks.ext.
InvenioWebhooks
(app=None, **kwargs)[source]¶ Invenio-Webhooks extension.
Extension initialization.
Models for webhook receivers.
-
class
invenio_webhooks.models.
CeleryReceiver
(receiver_id)[source]¶ Asynchronous receiver.
Receiver which will fire a celery task to handle payload instead of running it synchronously during the request.
Initialize a receiver identifier.
-
class
invenio_webhooks.models.
Event
(**kwargs)[source]¶ Incoming webhook event data.
Represents webhook event data which consists of a payload and a user id.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
id
¶ Event identifier.
-
payload
¶ Store payload in JSON format.
-
payload_headers
¶ Store payload headers in JSON format.
-
receiver
¶ Return registered receiver.
-
receiver_id
¶ Receiver identifier.
-
response
¶ Store response in JSON format.
-
response_headers
¶ Store response headers in JSON format.
-
user_id
¶ User identifier.
-
-
exception
invenio_webhooks.models.
InvalidSignature
[source]¶ Raised when the signature does not match.
-
class
invenio_webhooks.models.
Receiver
(receiver_id)[source]¶ Base class for a webhook receiver.
A receiver is responsible for receiving and extracting a payload from a request. You must implement
run
method that accepts the event instance.Initialize a receiver identifier.
-
get_hook_url
(access_token)[source]¶ Get URL for webhook.
In debug and testing mode the hook URL can be overwritten using
WEBHOOKS_DEBUG_RECEIVER_URLS
configuration variable to allow testing webhooks via services such as e.g. Ultrahook.WEBHOOKS_DEBUG_RECEIVER_URLS = dict( github='http://github.userid.ultrahook.com', )
-
signature
= ''¶ Default signature.
-
-
exception
invenio_webhooks.models.
ReceiverDoesNotExist
[source]¶ Raised when receiver does not exist.
Configuration¶
Webhooks module.
-
invenio_webhooks.config.
WEBHOOKS_DEBUG_RECEIVER_URLS
= {}¶ Mapping of receiver id to URL pattern.
This allows generating URLs to an intermediate webhook proxy service like Ultrahook for testing on development machines:
WEBHOOKS_DEBUG_RECEIVER_URLS = { 'github': 'https://hook.user.ultrahook.com/?access_token=%%(token)s' }
Signatures¶
Calculate signatures for payloads.
REST API¶
Invenio module for processing webhook events.
-
invenio_webhooks.views.
view
(*args, **kwargs)¶ Receiver event hook.
Proxies¶
Helper proxy to the state object.