From 858d4c0b7f96828f264df1fb8f84a831cb413346 Mon Sep 17 00:00:00 2001 From: Kyle Hornberg Date: Mon, 13 Apr 2020 15:13:23 -0500 Subject: [PATCH] Use octokitpy-routes webhook event names Fixes #91 --- README.rst | 11 ++-- src/octokit/data/events.json | 121 ----------------------------------- src/octokit/webhook.py | 6 +- 3 files changed, 7 insertions(+), 131 deletions(-) delete mode 100644 src/octokit/data/events.json diff --git a/README.rst b/README.rst index 1dbe68f..7bd95ab 100644 --- a/README.rst +++ b/README.rst @@ -98,6 +98,9 @@ Webhooks:: return_app_id boolean; whether or not you want to return the app id from the ping event for GitHub applications. This will only return the ``id`` if the event is the ``ping`` event. Otherwise the return value will be boolean. + +Note that webhook names are available at :code:`from octokit_routes import webhook_names` + Authentication -------------- @@ -150,13 +153,8 @@ GitHub APIs Data ---- -The :code:`octokit` client based on the available `route data `_ and `webhook data `_ +The :code:`octokit` client based on the available `route data `_ and `webhook data `_ -:: - - [x] Periodically, check if ``routes.json`` has changed and if so fetch and open a PR for it to be merged - - [ ] Periodically, check if ``webhook-names.json`` has changed and if so fetch and open a PR for it to be merged Tests ----- @@ -204,6 +202,7 @@ Deployment :: [x] Deploy wheels + [x] Make GitHub releases work diff --git a/src/octokit/data/events.json b/src/octokit/data/events.json deleted file mode 100644 index bc0aac8..0000000 --- a/src/octokit/data/events.json +++ /dev/null @@ -1,121 +0,0 @@ -[ - "*", - "error", - "commit_comment", - "commit_comment.created", - "create", - "delete", - "deployment", - "deployment_status", - "fork", - "gollum", - "installation", - "installation_repositories", - "installation_repositories.added", - "installation_repositories.removed", - "installation.created", - "installation.deleted", - "issue_comment", - "issue_comment.created", - "issue_comment.deleted", - "issue_comment.edited", - "issues", - "issues.assigned", - "issues.closed", - "issues.demilestoned", - "issues.edited", - "issues.labeled", - "issues.milestoned", - "issues.opened", - "issues.reopened", - "issues.unassigned", - "issues.unlabeled", - "label", - "label.created", - "label.deleted", - "label.edited", - "marketplace_purchase", - "marketplace_purchase.cancelled", - "marketplace_purchase.changed", - "marketplace_purchase.purchased", - "member", - "member.added", - "member.deleted", - "member.edited", - "membership", - "membership.added", - "membership.removed", - "milestone", - "milestone.closed", - "milestone.created", - "milestone.deleted", - "milestone.edited", - "milestone.opened", - "org_block", - "org_block.blocked", - "org_block.unblocked", - "organization", - "organization.member_added", - "organization.member_invited", - "organization.member_removed", - "page_build", - "ping", - "project", - "project_card", - "project_card.closed", - "project_card.created", - "project_card.deleted", - "project_card.edited", - "project_card.reopened", - "project_column", - "project_column.created", - "project_column.deleted", - "project_column.edited", - "project_column.moved", - "project.converted", - "project.created", - "project.deleted", - "project.edited", - "project.moved", - "public", - "pull_request", - "pull_request_review", - "pull_request_review_comment", - "pull_request_review_comment.created", - "pull_request_review_comment.deleted", - "pull_request_review_comment.edited", - "pull_request_review.dismissed", - "pull_request_review.edited", - "pull_request_review.submitted", - "pull_request.assigned", - "pull_request.closed", - "pull_request.edited", - "pull_request.labeled", - "pull_request.opened", - "pull_request.reopened", - "pull_request.review_request_removed", - "pull_request.review_requested", - "pull_request.synchronize", - "pull_request.unassigned", - "pull_request.unlabeled", - "push", - "release", - "release.published", - "repository", - "repository.archived", - "repository.created", - "repository.deleted", - "repository.privatized", - "repository.publicized", - "repository.unarchived", - "status", - "team", - "team_add", - "team.added_to_repository", - "team.created", - "team.deleted", - "team.edited", - "team.removed_from_repository", - "watch", - "watch.started" -] diff --git a/src/octokit/webhook.py b/src/octokit/webhook.py index 551a6a9..b82c45c 100644 --- a/src/octokit/webhook.py +++ b/src/octokit/webhook.py @@ -3,7 +3,7 @@ import hmac import json from uuid import UUID -from octokit import utils +from octokit_routes import webhook_names def valid_signature(headers, payload, secret): @@ -23,9 +23,7 @@ def valid_guid(guid): def valid_event(event, events): - return event in utils.get_json_data("events.json") and ( - event in events or "*" in events - ) + return event in webhook_names or "*" in webhook_names def valid_user_agent(ua):