Skip to main content

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

Project description

bitbucket-webhooks

Build Status

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

Installation

$ pip install bitbucket-webhooks

Quickstart

from flask import Flask
from flask import request

from bitbucket_webhooks import event_schemas
from bitbucket_webhooks import hooks
from bitbucket_webhooks import router

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.

Webhook events supported

  • repo:push
  • pullrequest:created
  • pullrequest:updated
  • pullrequest:approved
  • pullrequest:unapproved
  • pullrequest:fulfilled
  • pullrequest:rejected
  • pullrequest:comment_created
  • pullrequest:comment_updated
  • pullrequest:comment_deleted

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

bitbucket-webhooks-0.0.11.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

bitbucket_webhooks-0.0.11-py3-none-any.whl (5.7 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