Webhooks¶
Github¶
Handle GitHub webhooks.
-
class
app.controller.webhook.github.core.
GitHubWebhookHandler
(db_facade, config)¶ Encapsulate the handlers for all GitHub webhook events.
-
__init__
(db_facade, config)¶ Give handlers access to the database.
-
handle
(request_body, xhub_signature, payload)¶ Verify and handle the webhook event.
Parameters: - request_body (
bytes
) – Byte string of the request body - xhub_signature (
str
) – Hashed signature to validate
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]Returns: appropriate ResponseTuple depending on the validity and type of webhook
- request_body (
-
verify_hash
(request_body, xhub_signature)¶ Verify if a webhook event comes from GitHub.
Parameters: - request_body (
bytes
) – Byte string of the request body - xhub_signature (
str
) – Hashed signature to validate
Returns: Return True if the signature is valid, False otherwise
- request_body (
-
Define the abstract base class for a GitHub event handler.
-
class
app.controller.webhook.github.events.base.
GitHubEventHandler
(db_facade)¶ Define the properties and methods needed for a GitHub event handler.
-
__init__
(db_facade)¶ Give handler access to the database facade.
-
handle
(payload)¶ Handle a GitHub event.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
supported_action_list
¶ Provide a list of all actions this handler can handle.
Return type: List
[str
]
-
Handle GitHub membership events.
-
class
app.controller.webhook.github.events.membership.
MembershipEventHandler
(db_facade)¶ Encapsulate the handler methods for GitHub membership events.
-
handle
(payload)¶ Handle the event where a user is added or removed from a team.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
mem_added
(github_id, selected_team, team_name, github_username)¶ Help membership function if payload action is added.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
mem_remove
(github_id, selected_team, team_name)¶ Help membership function if payload action is removal.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
supported_action_list
¶ Provide a list of all actions this handler can handle.
Return type: List
[str
]
-
Handle GitHub organization events.
-
class
app.controller.webhook.github.events.organization.
OrganizationEventHandler
(db_facade)¶ Encapsulate the handler methods for GitHub organization events.
-
handle
(payload)¶ Handle when a user is added, removed, or invited to an organization.
If the member is removed, they are removed as a user from rocket’s db if they have not been removed already.
If the member is added or invited, do nothing.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
handle_added
(github_username, organization)¶ Help organization function if payload action is added.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
handle_invited
(github_username, organization)¶ Help organization function if payload action is invited.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
handle_remove
(member_list, github_id, github_username)¶ Help organization function if payload action is remove.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
supported_action_list
¶ Provide a list of all actions this handler can handle.
Return type: List
[str
]
-
Handle GitHub team events.
-
class
app.controller.webhook.github.events.team.
TeamEventHandler
(db_facade)¶ Encapsulate the handler methods for GitHub team events.
-
handle
(payload)¶ Handle team events of the organization.
This event is fired when a team is created, deleted, edited, or added or removed from a repository.
If a team is created, add or overwrite a team in rocket’s db.
If a team is deleted, delete the team from rocket’s db if it exists.
If a team is edited, overwrite the team’s fields or create the team if necessary.
If the team is added or removed from a repository, do nothing for now.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
supported_action_list
¶ Provide a list of all actions this handler can handle.
Return type: List
[str
]
-
team_added_to_repository
(github_id, github_team_name, payload)¶ Help team function if payload action is added_to_repository.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
team_created
(github_id, github_team_name, payload)¶ Help team function if payload action is created.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
team_deleted
(github_id, github_team_name, payload)¶ Help team function if payload action is deleted.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
team_edited
(github_id, github_team_name, payload)¶ Help team function if payload action is edited.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-
team_removed_from_repository
(github_id, github_team_name, payload)¶ Help team function if payload action is removed_from_repository.
Return type: Tuple
[Union
[Dict
[str
,List
[Dict
[str
,Any
]]],str
,Dict
[str
,Any
]],int
]
-