1use derive_more::From;
26use serde::{
27 de::{self, Deserializer},
28 Deserialize,
29};
30
31use std::fmt;
32use std::str::FromStr;
33
34use crate::{
35 AppEvent, Comment, DateTime, Installation, Issue, Label, Oid, PullRequest,
36 Repository, Review, ShortRepo, User,
37};
38
39#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
41pub enum EventType {
42 Wildcard,
44
45 Ping,
47
48 CheckRun,
51
52 CheckSuite,
55
56 CommitComment,
58
59 ContentReference,
63
64 Create,
66
67 Delete,
69
70 Deployment,
72
73 DeploymentStatus,
76
77 Fork,
79
80 GitHubAppAuthorization,
82
83 Gollum,
85
86 Installation,
88
89 IntegrationInstallation,
92
93 InstallationRepositories,
95
96 IntegrationInstallationRepositories,
100
101 IssueComment,
103
104 Issues,
107
108 Label,
110
111 MarketplacePurchase,
114
115 Member,
118
119 Membership,
122
123 Milestone,
125
126 Organization,
129
130 OrgBlock,
133
134 PageBuild,
136
137 ProjectCard,
140
141 ProjectColumn,
143
144 Project,
146
147 Public,
149
150 PullRequest,
156
157 PullRequestReviewComment,
160
161 PullRequestReview,
163
164 Push,
168
169 Release,
171
172 Repository,
175
176 RepositoryImport,
182
183 RepositoryVulnerabilityAlert,
185
186 SecurityAdvisory,
191
192 Status,
194
195 Team,
198
199 TeamAdd,
201
202 Watch,
204}
205
206impl EventType {
207 pub fn name(self) -> &'static str {
209 match self {
210 EventType::Wildcard => "*",
211 EventType::Ping => "ping",
212 EventType::CheckRun => "check_run",
213 EventType::CheckSuite => "check_suite",
214 EventType::CommitComment => "commit_comment",
215 EventType::ContentReference => "content_reference",
216 EventType::Create => "create",
217 EventType::Delete => "delete",
218 EventType::Deployment => "deployment",
219 EventType::DeploymentStatus => "deployment_status",
220 EventType::Fork => "fork",
221 EventType::GitHubAppAuthorization => "github_app_authorization",
222 EventType::Gollum => "gollum",
223 EventType::Installation => "installation",
224 EventType::IntegrationInstallation => "integration_installation",
225 EventType::InstallationRepositories => "installation_repositories",
226 EventType::IntegrationInstallationRepositories => {
227 "integration_installation_repositories"
228 }
229 EventType::IssueComment => "issue_comment",
230 EventType::Issues => "issues",
231 EventType::Label => "label",
232 EventType::MarketplacePurchase => "marketplace_purchase",
233 EventType::Member => "member",
234 EventType::Membership => "membership",
235 EventType::Milestone => "milestone",
236 EventType::Organization => "organization",
237 EventType::OrgBlock => "org_block",
238 EventType::PageBuild => "page_build",
239 EventType::ProjectCard => "project_card",
240 EventType::ProjectColumn => "project_column",
241 EventType::Project => "project",
242 EventType::Public => "public",
243 EventType::PullRequest => "pull_request",
244 EventType::PullRequestReview => "pull_request_review",
245 EventType::PullRequestReviewComment => {
246 "pull_request_review_comment"
247 }
248 EventType::Push => "push",
249 EventType::Release => "release",
250 EventType::Repository => "repository",
251 EventType::RepositoryImport => "repository_import",
252 EventType::RepositoryVulnerabilityAlert => {
253 "repository_vulnerability_alert"
254 }
255 EventType::SecurityAdvisory => "security_advisory",
256 EventType::Status => "status",
257 EventType::Team => "team",
258 EventType::TeamAdd => "team_add",
259 EventType::Watch => "watch",
260 }
261 }
262}
263
264impl FromStr for EventType {
265 type Err = &'static str;
266
267 fn from_str(s: &str) -> Result<Self, Self::Err> {
268 match s {
269 "*" => Ok(EventType::Wildcard),
270 "ping" => Ok(EventType::Ping),
271 "check_run" => Ok(EventType::CheckRun),
272 "check_suite" => Ok(EventType::CheckSuite),
273 "commit_comment" => Ok(EventType::CommitComment),
274 "content_reference" => Ok(EventType::ContentReference),
275 "create" => Ok(EventType::Create),
276 "delete" => Ok(EventType::Delete),
277 "deployment" => Ok(EventType::Deployment),
278 "deployment_status" => Ok(EventType::DeploymentStatus),
279 "fork" => Ok(EventType::Fork),
280 "github_app_authorization" => Ok(EventType::GitHubAppAuthorization),
281 "gollum" => Ok(EventType::Gollum),
282 "installation" => Ok(EventType::Installation),
283 "integration_installation" => {
284 Ok(EventType::IntegrationInstallation)
285 }
286 "installation_repositories" => {
287 Ok(EventType::InstallationRepositories)
288 }
289 "integration_installation_repositories" => {
290 Ok(EventType::IntegrationInstallationRepositories)
291 }
292 "issue_comment" => Ok(EventType::IssueComment),
293 "issues" => Ok(EventType::Issues),
294 "label" => Ok(EventType::Label),
295 "marketplace_purchase" => Ok(EventType::MarketplacePurchase),
296 "member" => Ok(EventType::Member),
297 "membership" => Ok(EventType::Membership),
298 "milestone" => Ok(EventType::Milestone),
299 "organization" => Ok(EventType::Organization),
300 "org_block" => Ok(EventType::OrgBlock),
301 "page_build" => Ok(EventType::PageBuild),
302 "project_card" => Ok(EventType::ProjectCard),
303 "project_column" => Ok(EventType::ProjectColumn),
304 "project" => Ok(EventType::Project),
305 "public" => Ok(EventType::Public),
306 "pull_request" => Ok(EventType::PullRequest),
307 "pull_request_review_comment" => {
308 Ok(EventType::PullRequestReviewComment)
309 }
310 "pull_request_review" => Ok(EventType::PullRequestReview),
311 "push" => Ok(EventType::Push),
312 "release" => Ok(EventType::Release),
313 "repository" => Ok(EventType::Repository),
314 "repository_import" => Ok(EventType::RepositoryImport),
315 "repository_vulnerability_alert" => {
316 Ok(EventType::RepositoryVulnerabilityAlert)
317 }
318 "security_advisory" => Ok(EventType::SecurityAdvisory),
319 "status" => Ok(EventType::Status),
320 "team" => Ok(EventType::Team),
321 "team_add" => Ok(EventType::TeamAdd),
322 "watch" => Ok(EventType::Watch),
323 _ => Err("invalid GitHub event"),
324 }
325 }
326}
327
328impl<'de> Deserialize<'de> for EventType {
329 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
330 where
331 D: Deserializer<'de>,
332 {
333 let s = String::deserialize(deserializer)?;
334 FromStr::from_str(&s).map_err(de::Error::custom)
335 }
336}
337
338impl fmt::Display for EventType {
339 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
340 f.write_str(self.name())
341 }
342}
343
344#[derive(
349 Deserialize, From, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
350)]
351#[allow(clippy::large_enum_variant)]
352pub enum Event {
353 Ping(PingEvent),
354 CommitComment(CommitCommentEvent),
357 Create(CreateEvent),
359 Delete(DeleteEvent),
360 GitHubAppAuthorization(GitHubAppAuthorizationEvent),
364 Gollum(GollumEvent),
365 Installation(InstallationEvent),
366 InstallationRepositories(InstallationRepositoriesEvent),
367 IntegrationInstallation(IntegrationInstallationEvent),
368 IntegrationInstallationRepositories(
369 IntegrationInstallationRepositoriesEvent,
370 ),
371 IssueComment(IssueCommentEvent),
372 Issues(IssuesEvent),
373 Label(LabelEvent),
374 PullRequest(PullRequestEvent),
386 PullRequestReview(PullRequestReviewEvent),
387 PullRequestReviewComment(PullRequestReviewCommentEvent),
388 Push(PushEvent),
389 Repository(RepositoryEvent),
391 Watch(WatchEvent),
398}
399
400impl AppEvent for Event {
401 fn installation(&self) -> Option<u64> {
402 match self {
403 Event::Ping(e) => e.installation(),
404 Event::CommitComment(e) => e.installation(),
405 Event::Create(e) => e.installation(),
406 Event::Delete(e) => e.installation(),
407 Event::GitHubAppAuthorization(e) => e.installation(),
408 Event::Gollum(e) => e.installation(),
409 Event::Installation(e) => e.installation(),
410 Event::InstallationRepositories(e) => e.installation(),
411 Event::IntegrationInstallation(e) => e.installation(),
412 Event::IntegrationInstallationRepositories(e) => e.installation(),
413 Event::IssueComment(e) => e.installation(),
414 Event::Issues(e) => e.installation(),
415 Event::Label(e) => e.installation(),
416 Event::PullRequest(e) => e.installation(),
417 Event::PullRequestReview(e) => e.installation(),
418 Event::PullRequestReviewComment(e) => e.installation(),
419 Event::Push(e) => e.installation(),
420 Event::Repository(e) => e.installation(),
421 Event::Watch(e) => e.installation(),
422 }
423 }
424}
425
426#[derive(
428 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
429)]
430pub struct InstallationId {
431 pub id: u64,
432}
433
434#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
435#[serde(tag = "type")]
436pub enum Hook {
437 Repository(RepoHook),
438 App(AppHook),
439}
440
441#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
442pub struct RepoHook {
443 pub id: u64,
444 pub name: String,
445 pub active: bool,
446 pub events: Vec<EventType>,
447 pub config: HookConfig,
448 pub updated_at: DateTime,
449 pub created_at: DateTime,
450 pub url: String,
451 pub test_url: String,
452 pub ping_url: String,
453}
454
455#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
456pub struct HookConfig {
457 pub content_type: String,
458 pub insecure_ssl: String,
459 pub secret: String,
460 pub url: String,
461}
462
463#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
464pub struct AppHook {
465 pub id: u64,
466 pub name: String,
467 pub active: bool,
468 pub events: Vec<Event>,
469 pub config: HookConfig,
470 pub updated_at: DateTime,
471 pub created_at: DateTime,
472 pub integration_id: u64,
473 pub app_id: u64,
474}
475
476#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
477pub struct PingEvent {
478 pub zen: String,
479 pub hook_id: u64,
480 pub hook: Hook,
481 pub repository: Option<Repository>,
482 pub sender: Option<User>,
483}
484
485impl AppEvent for PingEvent {}
486
487#[derive(
488 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
489)]
490#[serde(rename_all = "snake_case")]
491pub enum CommitCommentAction {
492 Created,
493}
494
495#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
496pub struct CommitCommentEvent {
497 pub action: CommitCommentAction,
498
499 pub comment: Comment,
501
502 pub repository: Repository,
504
505 pub sender: User,
507
508 pub installation: Option<InstallationId>,
510}
511
512impl AppEvent for CommitCommentEvent {
513 fn installation(&self) -> Option<u64> {
514 self.installation.map(|i| i.id)
515 }
516}
517
518#[derive(
519 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
520)]
521#[serde(rename_all = "snake_case")]
522pub enum CreateRefType {
523 Repository,
524 Branch,
525 Tag,
526}
527
528#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
529pub struct CreateEvent {
530 pub ref_type: CreateRefType,
532
533 #[serde(rename = "ref")]
537 pub git_ref: Option<String>,
538
539 pub master_branch: String,
541
542 pub description: Option<String>,
544
545 pub repository: Repository,
547
548 pub sender: User,
550
551 pub installation: Option<InstallationId>,
553}
554
555impl AppEvent for CreateEvent {
556 fn installation(&self) -> Option<u64> {
557 self.installation.map(|i| i.id)
558 }
559}
560
561#[derive(
562 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
563)]
564#[serde(rename_all = "snake_case")]
565pub enum DeleteRefType {
566 Branch,
567 Tag,
568}
569
570#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
571pub struct DeleteEvent {
572 pub ref_type: DeleteRefType,
574
575 #[serde(rename = "ref")]
577 pub git_ref: String,
578
579 pub repository: Repository,
581
582 pub sender: User,
584
585 pub installation: Option<InstallationId>,
587}
588
589impl AppEvent for DeleteEvent {
590 fn installation(&self) -> Option<u64> {
591 self.installation.map(|i| i.id)
592 }
593}
594
595#[derive(
596 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
597)]
598#[serde(rename_all = "snake_case")]
599pub enum GitHubAppAuthorizationAction {
600 Revoked,
601}
602
603#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
606pub struct GitHubAppAuthorizationEvent {
607 pub action: GitHubAppAuthorizationAction,
608
609 pub sender: User,
611
612 pub installation: InstallationId,
614}
615
616impl AppEvent for GitHubAppAuthorizationEvent {
617 fn installation(&self) -> Option<u64> {
618 Some(self.installation.id)
619 }
620}
621
622#[derive(
623 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
624)]
625#[serde(rename_all = "snake_case")]
626pub enum PageAction {
627 Created,
628 Edited,
629}
630
631#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
632pub struct PageEvent {
633 pub page_name: String,
634 pub title: String,
635 pub summary: Option<String>,
636 pub action: PageAction,
637 pub sha: Oid,
638 pub html_url: String,
639}
640
641#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
642pub struct GollumEvent {
643 pub pages: Vec<PageEvent>,
645
646 pub repository: Repository,
648
649 pub sender: User,
651
652 pub installation: Option<InstallationId>,
654}
655
656impl AppEvent for GollumEvent {
657 fn installation(&self) -> Option<u64> {
658 self.installation.map(|i| i.id)
659 }
660}
661
662#[derive(
663 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
664)]
665#[serde(rename_all = "snake_case")]
666pub enum InstallationAction {
667 Created,
668 Deleted,
669 NewPermissionsAccepted,
670}
671
672#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
673pub struct InstallationEvent {
674 pub action: InstallationAction,
675 pub installation: Installation,
676 pub sender: User,
677}
678
679impl AppEvent for InstallationEvent {
680 fn installation(&self) -> Option<u64> {
681 Some(self.installation.id)
682 }
683}
684
685#[derive(
686 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
687)]
688#[serde(rename_all = "snake_case")]
689pub enum InstallationRepositoriesAction {
690 Added,
691 Removed,
692}
693
694#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
695pub struct InstallationRepositoriesEvent {
696 pub action: InstallationRepositoriesAction,
697 pub installation: Installation,
698 pub repository_selection: String,
699 pub repositories_added: Vec<ShortRepo>,
700 pub repositories_removed: Vec<ShortRepo>,
701 pub sender: User,
702}
703
704impl AppEvent for InstallationRepositoriesEvent {
705 fn installation(&self) -> Option<u64> {
706 Some(self.installation.id)
707 }
708}
709
710#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
712pub struct IntegrationInstallationEvent;
713
714impl AppEvent for IntegrationInstallationEvent {
715 fn installation(&self) -> Option<u64> {
716 None
717 }
718}
719
720#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
722pub struct IntegrationInstallationRepositoriesEvent;
723
724impl AppEvent for IntegrationInstallationRepositoriesEvent {
725 fn installation(&self) -> Option<u64> {
726 None
727 }
728}
729
730#[derive(
731 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
732)]
733#[serde(rename_all = "snake_case")]
734pub enum IssueCommentAction {
735 Created,
736 Edited,
737 Deleted,
738}
739
740#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
741pub struct IssueCommentEvent {
742 pub action: IssueCommentAction,
744
745 pub issue: Issue,
747
748 pub comment: Comment,
750
751 pub repository: Repository,
753
754 pub sender: User,
756
757 pub installation: Option<InstallationId>,
759}
760
761impl AppEvent for IssueCommentEvent {
762 fn installation(&self) -> Option<u64> {
763 self.installation.map(|i| i.id)
764 }
765}
766
767#[derive(
768 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
769)]
770#[serde(rename_all = "snake_case")]
771pub enum IssueAction {
772 Opened,
773 Edited,
774 Deleted,
775 Transferred,
776 Pinned,
777 Unpinned,
778 Closed,
779 Reopened,
780 Assigned,
781 Unassigned,
782 Labeled,
783 Unlabeled,
784 Milestoned,
785 Demilestoned,
786}
787
788#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
789pub struct ChangeFrom {
790 pub from: String,
791}
792
793#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
794pub struct IssueChanges {
795 pub body: Option<ChangeFrom>,
797
798 pub title: Option<ChangeFrom>,
800}
801
802#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
803pub struct IssuesEvent {
804 pub action: IssueAction,
806
807 pub issue: Issue,
809
810 pub changes: Option<IssueChanges>,
812
813 pub label: Option<Label>,
816
817 pub assignee: Option<User>,
820
821 pub repository: Repository,
823
824 pub sender: User,
826
827 pub installation: Option<InstallationId>,
829}
830
831impl AppEvent for IssuesEvent {
832 fn installation(&self) -> Option<u64> {
833 self.installation.map(|i| i.id)
834 }
835}
836
837#[derive(
838 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
839)]
840#[serde(rename_all = "snake_case")]
841pub enum LabelAction {
842 Created,
843 Edited,
844 Deleted,
845}
846
847#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
848pub struct LabelChanges {
849 pub color: Option<ChangeFrom>,
851
852 pub name: Option<ChangeFrom>,
854}
855
856#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
857pub struct LabelEvent {
858 pub action: LabelAction,
860
861 pub label: Label,
863
864 pub changes: Option<LabelChanges>,
866
867 pub repository: Repository,
869
870 pub sender: User,
872
873 pub installation: Option<InstallationId>,
875}
876
877impl AppEvent for LabelEvent {
878 fn installation(&self) -> Option<u64> {
879 self.installation.map(|i| i.id)
880 }
881}
882
883#[derive(
884 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
885)]
886#[serde(rename_all = "snake_case")]
887pub enum PullRequestAction {
888 Assigned,
889 Unassigned,
890 ReviewRequested,
891 ReviewRequestRemoved,
892 Labeled,
893 Unlabeled,
894 Opened,
895 Edited,
896 Closed,
897 ReadyForReview,
898 Locked,
899 Unlocked,
900 Reopened,
901 Synchronize,
902}
903
904#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
905pub struct PullRequestEvent {
906 pub action: PullRequestAction,
915
916 pub number: u64,
918
919 pub pull_request: PullRequest,
921
922 pub repository: Repository,
924
925 pub sender: User,
927
928 pub installation: Option<InstallationId>,
930}
931
932impl AppEvent for PullRequestEvent {
933 fn installation(&self) -> Option<u64> {
934 self.installation.map(|i| i.id)
935 }
936}
937
938#[derive(
939 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
940)]
941#[serde(rename_all = "snake_case")]
942pub enum PullRequestReviewAction {
943 Submitted,
944 Edited,
945 Dismissed,
946}
947
948#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
949pub struct PullRequestReviewChanges {
950 pub body: Option<ChangeFrom>,
951}
952
953#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
954pub struct PullRequestReviewEvent {
955 pub action: PullRequestReviewAction,
957
958 pub review: Review,
960
961 pub changes: Option<PullRequestReviewChanges>,
963
964 pub pull_request: PullRequest,
966
967 pub repository: Repository,
969
970 pub sender: User,
972
973 pub installation: Option<InstallationId>,
975}
976
977impl AppEvent for PullRequestReviewEvent {
978 fn installation(&self) -> Option<u64> {
979 self.installation.map(|i| i.id)
980 }
981}
982
983#[derive(
984 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
985)]
986#[serde(rename_all = "snake_case")]
987pub enum PullRequestReviewCommentAction {
988 Created,
989 Edited,
990 Deleted,
991}
992
993#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
994pub struct PullRequestReviewCommentChanges {
995 pub body: Option<ChangeFrom>,
997}
998
999#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1000pub struct PullRequestReviewCommentEvent {
1001 pub action: PullRequestReviewCommentAction,
1002
1003 pub changes: Option<PullRequestReviewCommentChanges>,
1005
1006 pub pull_request: PullRequest,
1008
1009 pub repository: Repository,
1011
1012 pub comment: Comment,
1014
1015 pub sender: User,
1017
1018 pub installation: Option<InstallationId>,
1020}
1021
1022impl AppEvent for PullRequestReviewCommentEvent {
1023 fn installation(&self) -> Option<u64> {
1024 self.installation.map(|i| i.id)
1025 }
1026}
1027
1028#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1029pub struct Pusher {
1030 pub name: String,
1031 pub email: Option<String>,
1032}
1033
1034#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1035pub struct PushAuthor {
1036 pub name: String,
1037 pub email: Option<String>,
1038 pub username: Option<String>,
1039}
1040
1041#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1042pub struct PushCommit {
1043 pub id: Oid,
1044 pub tree_id: Oid,
1045 pub distinct: bool,
1046 pub message: String,
1047 pub timestamp: DateTime,
1048 pub url: String,
1049 pub author: PushAuthor,
1050 pub committer: PushAuthor,
1051 pub added: Vec<String>,
1052 pub removed: Vec<String>,
1053 pub modified: Vec<String>,
1054}
1055
1056#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1057pub struct PushEvent {
1058 #[serde(rename = "ref")]
1060 pub git_ref: String,
1061
1062 pub before: Oid,
1064
1065 pub after: Oid,
1067
1068 pub created: bool,
1070
1071 pub deleted: bool,
1073
1074 pub forced: bool,
1076
1077 pub base_ref: Option<String>,
1078
1079 pub compare: String,
1081
1082 pub commits: Vec<PushCommit>,
1084
1085 pub head_commit: Option<PushCommit>,
1087
1088 pub repository: Repository,
1090
1091 pub pusher: Pusher,
1094
1095 pub sender: User,
1097
1098 pub installation: Option<InstallationId>,
1100}
1101
1102impl AppEvent for PushEvent {
1103 fn installation(&self) -> Option<u64> {
1104 self.installation.map(|i| i.id)
1105 }
1106}
1107
1108#[derive(
1109 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
1110)]
1111#[serde(rename_all = "snake_case")]
1112pub enum RepositoryAction {
1113 Created,
1114 Deleted,
1115 Archived,
1116 Unarchived,
1117 Publicized,
1118 Privatized,
1119}
1120
1121#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1122pub struct RepositoryEvent {
1123 pub action: RepositoryAction,
1125
1126 pub repository: Repository,
1128
1129 pub sender: User,
1131
1132 pub installation: Option<InstallationId>,
1134}
1135
1136impl AppEvent for RepositoryEvent {
1137 fn installation(&self) -> Option<u64> {
1138 self.installation.map(|i| i.id)
1139 }
1140}
1141
1142#[derive(
1143 Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
1144)]
1145#[serde(rename_all = "snake_case")]
1146pub enum WatchAction {
1147 Started,
1148}
1149
1150#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1151pub struct WatchEvent {
1152 pub action: WatchAction,
1154
1155 pub repository: Repository,
1157
1158 pub sender: User,
1160
1161 pub installation: Option<InstallationId>,
1163}
1164
1165impl AppEvent for WatchEvent {
1166 fn installation(&self) -> Option<u64> {
1167 self.installation.map(|i| i.id)
1168 }
1169}