forked from XAMPPRocky/octocrab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add installation related webhook app events (XAMPPRocky#420)
Breaking: the installation stored in WrappedEventPayload now contains 2 variants, depending on whether the event comes from an installation_ related webhook event, or something else.
- Loading branch information
Showing
7 changed files
with
332 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "octocrab" | ||
version = "0.27.0" | ||
version = "0.28.0" | ||
authors = ["XAMPPRocky <[email protected]>"] | ||
edition = "2018" | ||
readme = "README.md" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! This event occurs when there is activity relating to a GitHub App | ||
//! installation. All GitHub Apps receive this event by default. You cannot | ||
//! manually subscribe to this event. | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::InstallationEventRepository; | ||
use crate::models::Author; | ||
|
||
/// The payload in a webhook installation event type. | ||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[non_exhaustive] | ||
pub struct InstallationEventPayload { | ||
/// The action this event represents. | ||
pub action: InstallationEventAction, | ||
/// An enterprise on GitHub | ||
pub enterprise: Option<serde_json::Value>, | ||
/// An array of repositories that the installation can access | ||
pub repositories: Vec<InstallationEventRepository>, | ||
/// The initiator of the request, mainly for the [`created`](InstallationAction::Created) action | ||
pub requester: Option<Author>, | ||
} | ||
|
||
/// The action on an installation this event corresponds to. | ||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "snake_case")] | ||
#[non_exhaustive] | ||
pub enum InstallationEventAction { | ||
/// Someone installed a GitHub App on a user or organization account. | ||
Created, | ||
/// Someone uninstalled a GitHub App on a user or organization account. | ||
Deleted, | ||
/// Someone granted new permissions to a GitHub App. | ||
NewPermissionsAccepted, | ||
/// Someone blocked access by a GitHub App to their user or organization account. | ||
Suspend, | ||
/// A GitHub App that was blocked from accessing a user or organization account was given access the account again. | ||
Unsuspend, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//! This event occurs when there is activity relating to which repositories a | ||
//! GitHub App installation can access. All GitHub Apps receive this event by | ||
//! default. You cannot manually subscribe to this event. | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::InstallationEventRepository; | ||
use crate::models::Author; | ||
|
||
/// The payload in a webhook installation_repositories event type. | ||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[non_exhaustive] | ||
pub struct InstallationRepositoriesEventPayload { | ||
/// The action this event represents. | ||
pub action: InstallationRepositoriesEventAction, | ||
/// An enterprise on GitHub | ||
pub enterprise: Option<serde_json::Value>, | ||
/// An array of repositories, which were added to the installation | ||
pub repositories_added: Vec<InstallationEventRepository>, | ||
/// An array of repositories, which were removed from the installation | ||
pub repositories_removed: Vec<InstallationEventRepository>, | ||
/// Describe whether all repositories have been selected or there's a selection involved | ||
pub repository_selection: InstallationRepositoriesEventSelection, | ||
/// The initiator of the request, mainly for the [`created`](InstallationAction::Created) action | ||
pub requester: Option<Author>, | ||
} | ||
|
||
/// The action on an installation this event corresponds to. | ||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "snake_case")] | ||
#[non_exhaustive] | ||
pub enum InstallationRepositoriesEventAction { | ||
/// A GitHub App installation was granted access to one or more repositories. | ||
Added, | ||
/// Access to one or more repositories was revoked for a GitHub App installation. | ||
Removed, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(rename_all = "snake_case")] | ||
#[non_exhaustive] | ||
pub enum InstallationRepositoriesEventSelection { | ||
All, | ||
Selected, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//! This event occurs when there is activity relating to the user or | ||
//! organization account that a GitHub App is installed on. | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::models::orgs::Organization; | ||
|
||
/// The payload in a webhook installation_target event type. | ||
/// | ||
/// Somebody renamed the user or organization account that a GitHub App is installed on. | ||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[non_exhaustive] | ||
pub struct InstallationTargetEventPayload { | ||
pub account: Organization, | ||
pub changes: InstallationTargetChanges, | ||
pub target_type: String, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[non_exhaustive] | ||
pub struct InstallationTargetChanges { | ||
pub login: InstallationTargetLoginChanges, | ||
pub slug: InstallationTargetSlugChanges, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[non_exhaustive] | ||
pub struct InstallationTargetLoginChanges { | ||
pub from: String, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[non_exhaustive] | ||
pub struct InstallationTargetSlugChanges { | ||
pub from: String, | ||
} |
Oops, something went wrong.