Skip to content

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

License

Notifications You must be signed in to change notification settings

tiadevops/bitbucket-webhooks

 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 95.0%
  • Makefile 5.0%