1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
mod branch_protection_rule;
mod check_run;
mod check_suite;
mod code_scanning_alert;
mod commit_comment;
mod create;
mod delete;
mod dependabot_alert;
mod deploy_key;
mod deployment;
mod deployment_protection_rule;
mod deployment_status;
mod discussion;
mod discussion_comment;
mod fork;
mod github_app_authorization;
mod gollum;
mod installation;
mod installation_repositories;
mod installation_target;
mod issue_comment;
mod issues;
mod label;
mod marketplace_purchase;
mod member;
mod membership;
mod merge_group;
mod meta;
mod milestone;
mod org_block;
mod organization;
mod package;
mod page_build;
mod personal_access_token_request;
mod ping;
mod project;
mod project_card;
mod project_column;
mod projects_v2;
mod projects_v2_item;
mod public;
mod pull_request;
mod pull_request_review;
mod pull_request_review_comment;
mod pull_request_review_thread;
mod push;
mod registry_package;
mod release;
mod repository;
mod repository_advisory;
mod repository_dispatch;
mod repository_import;
mod repository_vulnerability_alert;
mod schedule;
mod secret_scanning_alert;
mod secret_scanning_alert_location;
mod security_advisory;
mod security_and_analysis;
mod sponsorship;
mod star;
mod status;
mod team;
mod team_add;
mod watch;
mod workflow_dispatch;
mod workflow_job;
mod workflow_run;

pub use self::{
    branch_protection_rule::*, check_run::*, check_suite::*, code_scanning_alert::*,
    commit_comment::*, create::*, delete::*, dependabot_alert::*, deploy_key::*, deployment::*,
    deployment_protection_rule::*, deployment_status::*, discussion::*, discussion_comment::*,
    fork::*, github_app_authorization::*, gollum::*, installation::*, installation_repositories::*,
    installation_target::*, issue_comment::*, issues::*, label::*, marketplace_purchase::*,
    member::*, membership::*, merge_group::*, meta::*, milestone::*, org_block::*, organization::*,
    package::*, page_build::*, personal_access_token_request::*, ping::*, project::*,
    project_card::*, project_column::*, projects_v2::*, projects_v2_item::*, public::*,
    pull_request::*, pull_request_review::*, pull_request_review_comment::*,
    pull_request_review_thread::*, push::*, registry_package::*, release::*, repository::*,
    repository_advisory::*, repository_dispatch::*, repository_import::*,
    repository_vulnerability_alert::*, schedule::*, secret_scanning_alert::*,
    secret_scanning_alert_location::*, security_advisory::*, security_and_analysis::*,
    sponsorship::*, star::*, status::*, team::*, team_add::*, watch::*, workflow_dispatch::*,
    workflow_job::*, workflow_run::*,
};

use serde::{Deserialize, Serialize};

/// The specific part of the payload in a webhook event
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum WebhookEventPayload {
    BranchProtectionRule(Box<BranchProtectionRuleWebhookEventPayload>),
    CheckRun(Box<CheckRunWebhookEventPayload>),
    CheckSuite(Box<CheckSuiteWebhookEventPayload>),
    CodeScanningAlert(Box<CodeScanningAlertWebhookEventPayload>),
    CommitComment(Box<CommitCommentWebhookEventPayload>),
    Create(Box<CreateWebhookEventPayload>),
    Delete(Box<DeleteWebhookEventPayload>),
    DependabotAlert(Box<DependabotAlertWebhookEventPayload>),
    DeployKey(Box<DeployKeyWebhookEventPayload>),
    Deployment(Box<DeploymentWebhookEventPayload>),
    DeploymentProtectionRule(Box<DeploymentProtectionRuleWebhookEventPayload>),
    DeploymentStatus(Box<DeploymentStatusWebhookEventPayload>),
    Discussion(Box<DiscussionWebhookEventPayload>),
    DiscussionComment(Box<DiscussionCommentWebhookEventPayload>),
    Fork(Box<ForkWebhookEventPayload>),
    GithubAppAuthorization(Box<GithubAppAuthorizationWebhookEventPayload>),
    Gollum(Box<GollumWebhookEventPayload>),
    Installation(Box<InstallationWebhookEventPayload>),
    InstallationRepositories(Box<InstallationRepositoriesWebhookEventPayload>),
    InstallationTarget(Box<InstallationTargetWebhookEventPayload>),
    IssueComment(Box<IssueCommentWebhookEventPayload>),
    Issues(Box<IssuesWebhookEventPayload>),
    Label(Box<LabelWebhookEventPayload>),
    MarketplacePurchase(Box<MarketplacePurchaseWebhookEventPayload>),
    Member(Box<MemberWebhookEventPayload>),
    Membership(Box<MembershipWebhookEventPayload>),
    MergeGroup(Box<MergeGroupWebhookEventPayload>),
    Meta(Box<MetaWebhookEventPayload>),
    Milestone(Box<MilestoneWebhookEventPayload>),
    OrgBlock(Box<OrgBlockWebhookEventPayload>),
    Organization(Box<OrganizationWebhookEventPayload>),
    Package(Box<PackageWebhookEventPayload>),
    PageBuild(Box<PageBuildWebhookEventPayload>),
    PersonalAccessTokenRequest(Box<PersonalAccessTokenRequestWebhookEventPayload>),
    Ping(Box<PingWebhookEventPayload>),
    ProjectCard(Box<ProjectCardWebhookEventPayload>),
    Project(Box<ProjectWebhookEventPayload>),
    ProjectColumn(Box<ProjectColumnWebhookEventPayload>),
    ProjectsV2(Box<ProjectsV2WebhookEventPayload>),
    ProjectsV2Item(Box<ProjectsV2ItemWebhookEventPayload>),
    Public(Box<PublicWebhookEventPayload>),
    PullRequest(Box<PullRequestWebhookEventPayload>),
    PullRequestReview(Box<PullRequestReviewWebhookEventPayload>),
    PullRequestReviewComment(Box<PullRequestReviewCommentWebhookEventPayload>),
    PullRequestReviewThread(Box<PullRequestReviewThreadWebhookEventPayload>),
    Push(Box<PushWebhookEventPayload>),
    RegistryPackage(Box<RegistryPackageWebhookEventPayload>),
    Release(Box<ReleaseWebhookEventPayload>),
    RepositoryAdvisory(Box<RepositoryAdvisoryWebhookEventPayload>),
    Repository(Box<RepositoryWebhookEventPayload>),
    RepositoryDispatch(Box<RepositoryDispatchWebhookEventPayload>),
    RepositoryImport(Box<RepositoryImportWebhookEventPayload>),
    RepositoryVulnerabilityAlert(Box<RepositoryVulnerabilityAlertWebhookEventPayload>),
    Schedule(Box<ScheduleWebhookEventPayload>),
    SecretScanningAlert(Box<SecretScanningAlertWebhookEventPayload>),
    SecretScanningAlertLocation(Box<SecretScanningAlertLocationWebhookEventPayload>),
    SecurityAdvisory(Box<SecurityAdvisoryWebhookEventPayload>),
    SecurityAndAnalysis(Box<SecurityAndAnalysisWebhookEventPayload>),
    Sponsorship(Box<SponsorshipWebhookEventPayload>),
    Star(Box<StarWebhookEventPayload>),
    Status(Box<StatusWebhookEventPayload>),
    TeamAdd(Box<TeamAddWebhookEventPayload>),
    Team(Box<TeamWebhookEventPayload>),
    Watch(Box<WatchWebhookEventPayload>),
    WorkflowDispatch(Box<WorkflowDispatchWebhookEventPayload>),
    WorkflowJob(Box<WorkflowJobWebhookEventPayload>),
    WorkflowRun(Box<WorkflowRunWebhookEventPayload>),
    Unknown(Box<serde_json::Value>),
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum RefType {
    Tag,
    Branch,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum PusherType {
    User,
    #[serde(untagged)]
    DeployKey(String),
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum MembershipScope {
    Team,
    Organization,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct OldValue<T>
where
    T: Serialize,
    T: std::fmt::Debug + Clone + PartialEq,
{
    /// Old value, when the webhook payload is a change
    pub from: T,
}