txghbot._core.WebhookDispatchingResource(Resource) class documentationtxghbot._core
(View In Hierarchy)
A Resource
subclass that authenticates Github web hook requests and dispatches to IWebhook implementing
plugins.
| Parameters | signatureVerifier | a callable that accepts two arguments: a twisted.web.http_headers.Headers
instance and the bytes
body of the corresponding request, and returns True
if the request's signature passes verification and False
if not. (type: callable) |
| hooks | An iterable of web hooks to match and possibly run against a request. (type: an iterable of IWebhook-providing objects.) |
| Method | __init__ | Undocumented |
| Method | render_POST | Verify that request came from Github, then run any matching
IWebhooks from
self.hooks |
| Method | _extractHeader | Extract the first value for name in headers or
raise InvalidData. |
| Method | _deserializeContent | Deserialize the JSON stored in content. |
| Method | _matchHook | Determine if hook matches eventName and
eventData. |
| Method | _processHookResults | Traverse results and set the response code to 400 if any
hooks failed to run. |
Extract the first value for name in headers or
raise InvalidData.
| Parameters | headers | The headers from which to extract the desired value. (type: twisted.web.http_headers.Headers) |
| name | The name of the header to extract. (type: bytes) | |
| Returns | The first header value under name (type: str,
decoded as ASCII.) | |
| Raises | InvalidData if
the header is missing, or if its first value cannot be decoded as ASCII. | |
Deserialize the JSON stored in content.
| Parameters | content | The serialized JSON to deserialize (type: bytes) |
| Returns | the deserialized JSON object. (type: dict) | |
| Raises | InvalidData if a
JSON object cannot be decoded. | |
Determine if hook matches eventName and
eventData.
| Parameters | hook | the web hook to try to match against eventName and
eventData (type: an IWebhook-providing
object) |
| eventName | the name of the Github webhook event (type: str) | |
| eventData | the event data for this Github webhook event. (type: dict) | |
| Returns | True
if the hook matched and False
if not. | |
Traverse results and set the response code to 400 if any
hooks failed to run.
Intended to be run as added as a callback to a twisted.internet.defer.DeferredList
of hook results.
| Parameters | results | The results of running each hook in hooks against
request (type: A list of (index, (outcome, value)) tuples.) |
| hooks | an iterable of IWebhook-providing objects
that were run against request (type: iterable of IWebhook-providing objects.) | |
| request | the Github web hook request. (type: twisted.web.server.Request) | |
| requestID | the Github ID for request (type: str) |
Verify that request came from Github, then run any matching
IWebhooks from
self.hooks
| Parameters | request | The request to verify and match hooks against. (type: twisted.web.server.Request) |
| Returns | NOT_DONE_YET (type: NOT_DONE_YET) | |