Skip to main content

Routes bitbucket webhook API event payloads to easily consumable decorators with payload serialized to python objects.

Project description

bitbucket-webhooks-router

Build Status

Python library that makes webhook API event payloads available via decorators with payload serialized into python objects.

Installation

$ pip install bb-hooks-router

Quickstart

from bitbucket_webhooks_router import event_schemas
from bitbucket_webhooks_router import hooks
from bitbucket_webhooks_router import router
from flask import Flask
from flask import request

app = Flask(__name__)


@app.route("/hooks", methods=["POST"])
def bb_webhooks_handler():
    router.route(request.headers["X-Event-Key"], request.json)
    return ("", 204)


@hooks.repo_push
def _handle_repo_push(event: event_schemas.RepoPush):
    print(f"One or more commits pushed to: {event.repository.name}"

Here is the full example.

Bitbucket events supported

  • repo:push
  • pullrequest:created
  • pullrequest:updated
  • pullrequest:approved
  • pullrequest:unapproved
  • pullrequest:fulfilled
  • pullrequest:rejected

Links

PyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bb-hooks-router-0.0.6.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

bb_hooks_router-0.0.6-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page