-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathEvents.hs
More file actions
1628 lines (1402 loc) · 62.2 KB
/
Events.hs
File metadata and controls
1628 lines (1402 loc) · 62.2 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{-# LANGUAGE Trustworthy #-}
{-|
Module : Github.Data.Webhooks.Events
Copyright : (c) Cuedo Control Engineering 2017-2022
License : MIT
Maintainer : Kyle Van Berendonck <foss@cuedo.com.au>
This module contains types that represent GitHub webhook's events.
-}
module GitHub.Data.Webhooks.Events
( EventHasSender(..)
, EventHasMaybeSender(..)
, EventHasRepo(..)
--
, CheckSuiteEventAction(..)
, CheckSuiteEvent(..)
--
, CheckRunEventAction(..)
, CheckRunEvent(..)
--
, CommitCommentEvent(..)
, CommitCommentEventAction(..)
--
, CreateEvent(..)
--
, DeleteEvent(..)
--
, DeploymentEvent(..)
--
, DeploymentStatusEvent(..)
-- Deprecated events
, DownloadEvent(..)
, FollowEvent(..)
, ForkEvent(..)
, ForkApplyEvent(..)
, GistEvent(..)
--
, GollumEvent(..)
--
, InstallationEvent(..)
, InstallationEventAction(..)
--
, InstallationRepositoriesEvent(..)
, InstallationRepoEventAction(..)
--
, IssueCommentEvent(..)
, IssueCommentEventAction(..)
--
, IssuesEvent(..)
, IssuesEventAction(..)
--
, LabelEvent(..)
, LabelEventAction(..)
--
, MarketplacePurchaseEvent(..)
, MarketplacePurchaseEventAction(..)
--
, MemberEvent(..)
, MemberEventAction(..)
--
, MembershipEvent(..)
, MembershipEventAction(..)
--
, MilestoneEvent(..)
, MilestoneEventAction(..)
--
, OrganizationEvent(..)
, OrganizationEventAction(..)
--
, OrgBlockEvent(..)
, OrgBlockEventAction(..)
--
, PageBuildEvent(..)
--
, ProjectCardEvent(..)
, ProjectCardEventAction(..)
--
, ProjectColumnEvent(..)
, ProjectColumnEventAction(..)
--
, ProjectEvent(..)
, ProjectEventAction(..)
--
, PublicEvent(..)
--
, PullRequestEvent(..)
, PullRequestEventAction(..)
--
, PullRequestReviewEvent(..)
, PullRequestReviewEventAction(..)
--
, PullRequestReviewCommentEvent(..)
, PullRequestReviewCommentEventAction(..)
--
, PushEvent(..)
--
, ReleaseEvent(..)
, ReleaseEventAction(..)
--
, RepositoryEvent(..)
, RepositoryEventAction(..)
--
, StatusEvent(..)
, StatusEventState(..)
--
, TeamEvent(..)
, TeamEventAction(..)
--
, TeamAddEvent(..)
--
, WatchEvent(..)
, WatchEventAction(..)
) where
import Data.Aeson (FromJSON(..), withObject, withText, (.:), (.:?), (.!=))
import Control.Applicative ((<*>), pure)
import Control.DeepSeq (NFData(..))
import Control.DeepSeq.Generics (genericRnf)
import Data.Data (Data, Typeable)
import Data.Functor ((<$>))
import Data.Monoid (mempty)
import Data.Time (UTCTime)
import Data.Time.LocalTime (zonedTimeToUTC)
import Data.Text (Text)
import Data.Vector (Vector)
import GHC.Generics (Generic)
import GitHub.Data.Webhooks.Payload
-- | Represents an event that contains its sender information.
class EventHasSender eventKind where
-- | Provides the sender context of a Webhook event.
senderOfEvent :: eventKind -> HookUser
-- | Represents an event that may contain its sender information.
class EventHasMaybeSender eventKind where
-- | Provides the sender context of a Webhook event.
maybeSenderOfEvent :: eventKind -> Maybe HookUser
-- | Represents an event that contains its repository information.
class EventHasRepo eventKind where
-- | Provides the repository context of a Webhook event.
repoForEvent :: eventKind -> HookRepository
-- | Represents the "action" field in the
-- 'CheckSuiteEvent' payload.
data CheckSuiteEventAction
-- | Decodes from "completed"
= CheckSuiteEventActionCompleted
-- | Decodes from "requested"
| CheckSuiteEventActionRequested
-- | Decodes from "rerequested"
| CheckSuiteEventActionRerequested
-- | The result of decoding an unknown check suite event action type
| CheckSuiteEventActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData CheckSuiteEventAction where rnf = genericRnf
instance FromJSON CheckSuiteEventAction where
parseJSON = withText "Check suite event action" $ \t ->
case t of
"completed" -> pure CheckSuiteEventActionCompleted
"requested" -> pure CheckSuiteEventActionRequested
"rerequested" -> pure CheckSuiteEventActionRerequested
_ -> pure (CheckSuiteEventActionOther t)
-- | Triggered when a check suite is completed, requested, or rerequested.
-- See <https://developer.github.com/v3/activity/events/types/#checksuiteevent>.
data CheckSuiteEvent = CheckSuiteEvent
{ evCheckSuiteAction :: !CheckSuiteEventAction
, evCheckSuiteCheckSuite :: !HookCheckSuite
, evCheckSuiteRepository :: !HookRepository
, evCheckSuiteOrganization :: !(Maybe HookOrganization)
, evCheckSuiteSender :: !HookUser
, evCheckSuiteInstallation :: !(Maybe HookChecksInstallation)
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender CheckSuiteEvent where senderOfEvent = evCheckSuiteSender
instance EventHasRepo CheckSuiteEvent where repoForEvent = evCheckSuiteRepository
instance NFData CheckSuiteEvent where rnf = genericRnf
-- | Represents the "action" field in the
-- 'CheckRunEvent' payload.
data CheckRunEventAction
-- | Decodes from "created"
= CheckRunEventActionCreated
-- | Decodes from "completed"
| CheckRunEventActionCompleted
-- | Decodes from "rerequested"
| CheckRunEventActionRerequested
-- | Decodes from "requested_action"
| CheckRunEventActionRequestedAction
-- | The result of decoding an unknown check run event action type
| CheckRunEventActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData CheckRunEventAction where rnf = genericRnf
instance FromJSON CheckRunEventAction where
parseJSON = withText "Check run event action" $ \t ->
case t of
"created" -> pure CheckRunEventActionCreated
"completed" -> pure CheckRunEventActionCompleted
"rerequested" -> pure CheckRunEventActionRerequested
"requested_action" -> pure CheckRunEventActionRequestedAction
_ -> pure (CheckRunEventActionOther t)
-- | Triggered when a check run is created, rerequested, completed, or has a requested_action.
-- See <https://developer.github.com/v3/activity/events/types/#checkrunevent>.
data CheckRunEvent = CheckRunEvent
{ evCheckRunAction :: !CheckRunEventAction
, evCheckRunCheckRun :: !HookCheckRun
, evCheckRunRequestedAction :: !(Maybe HookCheckRunRequestedAction)
, evCheckRunRepository :: !HookRepository
, evCheckRunOrganization :: !(Maybe HookOrganization)
, evCheckRunSender :: !HookUser
, evCheckRunInstallation :: !(Maybe HookChecksInstallation)
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender CheckRunEvent where senderOfEvent = evCheckRunSender
instance EventHasRepo CheckRunEvent where repoForEvent = evCheckRunRepository
instance NFData CheckRunEvent where rnf = genericRnf
-- | Represents the "action" field in the
-- 'CommitCommentEvent' payload.
data CommitCommentEventAction
-- | Decodes from "created"
= CommitCommentActionCreated
-- | The result of decoding an unknown commit comment event action type
| CommitCommentActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData CommitCommentEventAction where rnf = genericRnf
instance FromJSON CommitCommentEventAction where
parseJSON = withText "Commit comment event action" $ \t ->
case t of
"created" -> pure CommitCommentActionCreated
_ -> pure (CommitCommentActionOther t)
-- | Triggered when a commit comment is created.
-- See <https://developer.github.com/v3/activity/events/types/#commitcommentevent>.
data CommitCommentEvent = CommitCommentEvent
{ evCommitCommentAction :: !CommitCommentEventAction
, evCommitCommentPayload :: !HookCommitComment
, evCommitCommentRepo :: !HookRepository
, evCommitCommentSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender CommitCommentEvent where senderOfEvent = evCommitCommentSender
instance EventHasRepo CommitCommentEvent where repoForEvent = evCommitCommentRepo
instance NFData CommitCommentEvent where rnf = genericRnf
-- | Represents a created repository, branch, or tag.
-- Note: webhooks will not receive this event for created repositories.
-- Additionally, webhooks will not receive this event for tags if more than three tags are pushed at once.
-- See <https://developer.github.com/v3/activity/events/types/#createevent>.
data CreateEvent = CreateEvent
{ evCreateRef :: !Text
, evCreateRefType :: !Text
, evCreateMasterBranch :: !Text
, evCreateDescription :: !Text
, evCreatePusherType :: !OwnerType
, evCreateRepo :: !HookRepository
, evCreateSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender CreateEvent where senderOfEvent = evCreateSender
instance EventHasRepo CreateEvent where repoForEvent = evCreateRepo
instance NFData CreateEvent where rnf = genericRnf
-- | Represents a deleted branch or tag.
-- Note: webhooks will not receive this event for tags if more than three tags are deleted at once.
-- See <https://developer.github.com/v3/activity/events/types/#deleteevent>.
data DeleteEvent = DeleteEvent
{ evDeleteRef :: !Text
, evDeleteRefType :: !Text
, evDeletePusherType :: !OwnerType
, evDeleteRepo :: !HookRepository
, evDeleteSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender DeleteEvent where senderOfEvent = evDeleteSender
instance EventHasRepo DeleteEvent where repoForEvent = evDeleteRepo
instance NFData DeleteEvent where rnf = genericRnf
-- | Represents a deployment.
-- Events of this type are not visible in timelines. These events are only used to trigger hooks.
-- See <https://developer.github.com/v3/activity/events/types/#deploymentevent>.
data DeploymentEvent = DeploymentEvent
{ evDeploymentInfo :: !HookDeployment
, evDeploymentRepo :: !HookRepository
, evDeploymentSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender DeploymentEvent where senderOfEvent = evDeploymentSender
instance EventHasRepo DeploymentEvent where repoForEvent = evDeploymentRepo
instance NFData DeploymentEvent where rnf = genericRnf
-- | Represents a deployment status.
-- Events of this type are not visible in timelines. These events are only used to trigger hooks.
-- See <https://developer.github.com/v3/activity/events/types/#deploymentstatusevent>.
data DeploymentStatusEvent = DeploymentStatusEvent
{ evDeplStatusInfo :: !HookDeploymentStatus
, evDeplStatusDeployment :: !HookDeployment
, evDeplStatusRepo :: !HookRepository
, evDeplStatusSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender DeploymentStatusEvent where senderOfEvent = evDeplStatusSender
instance EventHasRepo DeploymentStatusEvent where repoForEvent = evDeplStatusRepo
instance NFData DeploymentStatusEvent where rnf = genericRnf
-- | Triggered when a new download is created.
-- Events of this kind are no longer delivered.
-- See <https://developer.github.com/v3/activity/events/types/#downloadevent>.
data DownloadEvent = DownloadEvent
-- | Triggered when a user follows another user.
-- Events of this kind are no longer delivered.
-- See <https://developer.github.com/v3/activity/events/types/#downloadevent>.
data FollowEvent = FollowEvent
-- | Triggered when a user forks a repository.
-- See <https://developer.github.com/v3/activity/events/types/#forkevent>.
data ForkEvent = ForkEvent
{ evForkDestination :: !HookRepository
, evForkSource :: !HookRepository
, evForkSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender ForkEvent where senderOfEvent = evForkSender
instance EventHasRepo ForkEvent where repoForEvent = evForkSource
instance NFData ForkEvent where rnf = genericRnf
-- | Triggered when a patch is applied in the Fork Queue.
-- Events of this kind are no longer delivered.
-- See <https://developer.github.com/v3/activity/events/types/#forkapplyevent>.
data ForkApplyEvent = ForkApplyEvent
-- | Triggered when a Gist is created or updated.
-- Events of this kind are no longer delivered.
-- See <https://developer.github.com/v3/activity/events/types/#gistevent>.
data GistEvent = GistEvent
-- | Triggered when a Wiki page is created or updated.
-- See <https://developer.github.com/v3/activity/events/types/#gollumevent>.
data GollumEvent = GollumEvent
{ evGollumPages :: !(Vector HookWikiPage)
, evGollumRepo :: !HookRepository
, evGollumSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender GollumEvent where senderOfEvent = evGollumSender
instance EventHasRepo GollumEvent where repoForEvent = evGollumRepo
instance NFData GollumEvent where rnf = genericRnf
data InstallationEventAction
-- | Decodes from "created"
= InstallationCreatedAction
-- | Decodes from "deleted"
| InstallationDeletedAction
-- | Decodes from "suspend"
| InstallationSuspendAction
-- | Decodes from "unsuspend"
| InstallationUnsuspendAction
-- | Decodes from "new_permissions_accepted"
| InstallationNewPermissionsAcceptedAction
-- | The result of decoding an unknown installation event action type
| InstallationActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData InstallationEventAction where rnf = genericRnf
instance FromJSON InstallationEventAction where
parseJSON = withText "Installation event action" $ \t ->
case t of
"created" -> pure InstallationCreatedAction
"deleted" -> pure InstallationDeletedAction
"suspend" -> pure InstallationSuspendAction
"unsuspend" -> pure InstallationUnsuspendAction
"new_permissions_accepted" -> pure InstallationNewPermissionsAcceptedAction
_ -> pure (InstallationActionOther t)
-- | Triggered when a GitHub App has been installed or uninstalled.
-- See <https://developer.github.com/v3/activity/events/types/#installationevent>.
data InstallationEvent = InstallationEvent
{ evInstallationAction :: !InstallationEventAction
, evInstallationInfo :: !HookInstallation
, evInstallationRepos :: !(Vector HookRepositorySimple)
, evInstallationSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender InstallationEvent where senderOfEvent = evInstallationSender
instance NFData InstallationEvent where rnf = genericRnf
data InstallationRepoEventAction
-- | Decodes from "added"
= InstallationRepoAddedAction
-- | Decodes from "removed"
| InstallationRepoRemovedAction
-- | The result of decoding an unknown installation repo event action type
| InstallationRepoActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData InstallationRepoEventAction where rnf = genericRnf
instance FromJSON InstallationRepoEventAction where
parseJSON = withText "Installation repo event action" $ \t ->
case t of
"added" -> pure InstallationRepoAddedAction
"removed" -> pure InstallationRepoRemovedAction
_ -> pure (InstallationRepoActionOther t)
-- | Triggered when a repository is added or removed from an installation.
-- See <https://developer.github.com/v3/activity/events/types/#installationrepositoriesevent>.
data InstallationRepositoriesEvent = InstallationRepositoriesEvent
{ evInstallationRepoAction :: !InstallationRepoEventAction
, evInstallationRepoInfo :: !HookInstallation
, evInstallationRepoSel :: !Text
, evInstallationReposAdd :: !(Vector HookRepositorySimple)
, evInstallationReposRemove :: !(Vector HookRepositorySimple)
, evInstallationReposSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender InstallationRepositoriesEvent where senderOfEvent = evInstallationReposSender
instance NFData InstallationRepositoriesEvent where rnf = genericRnf
data IssueCommentEventAction
-- | Decodes from "created"
= IssueCommentCreatedAction
-- | Decodes from "edited"
| IssueCommentEditedAction
-- | Decodes from "deleted"
| IssueCommentDeletedAction
-- | The result of decoding an unknown issue comment event action type
| IssueCommentActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData IssueCommentEventAction where rnf = genericRnf
instance FromJSON IssueCommentEventAction where
parseJSON = withText "Issue comment event action" $ \t ->
case t of
"created" -> pure IssueCommentCreatedAction
"edited" -> pure IssueCommentEditedAction
"deleted" -> pure IssueCommentDeletedAction
_ -> pure (IssueCommentActionOther t)
-- | Triggered when an issue comment is created, edited, or deleted.
-- See <https://developer.github.com/v3/activity/events/types/#issuecommentevent>.
data IssueCommentEvent = IssueCommentEvent
{ evIssueCommentAction :: !IssueCommentEventAction
, evIssueCommentIssue :: !HookIssue
, evIssueCommentPayload :: !HookIssueComment
, evIssueCommentRepo :: !HookRepository
, evIssueCommentSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender IssueCommentEvent where senderOfEvent = evIssueCommentSender
instance EventHasRepo IssueCommentEvent where repoForEvent = evIssueCommentRepo
instance NFData IssueCommentEvent where rnf = genericRnf
data IssuesEventAction
-- | Decodes from "assigned"
= IssuesAssignedAction
-- | Decodes from "unassigned"
| IssuesUnassignedAction
-- | Decodes from "labeled"
| IssuesLabeledAction
-- | Decodes from "unlabeled"
| IssuesUnlabeledAction
-- | Decodes from "opened"
| IssuesOpenedAction
-- | Decodes from "edited"
| IssuesEditedAction
-- | Decodes from "milestoned"
| IssuesMilestonedAction
-- | Decodes from "demilestoned"
| IssuesDemilestonedAction
-- | Decodes from "closed"
| IssuesClosedAction
-- | Decodes from "reopened"
| IssuesReopenedAction
-- | The result of decoding an unknown issue comment event action type
| IssuesActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData IssuesEventAction where rnf = genericRnf
instance FromJSON IssuesEventAction where
parseJSON = withText "Issue comment event action" $ \t ->
case t of
"assigned" -> pure IssuesAssignedAction
"unassigned" -> pure IssuesUnassignedAction
"labeled" -> pure IssuesLabeledAction
"unlabeled" -> pure IssuesUnlabeledAction
"opened" -> pure IssuesOpenedAction
"edited" -> pure IssuesEditedAction
"milestoned" -> pure IssuesMilestonedAction
"demilestoned" -> pure IssuesDemilestonedAction
"closed" -> pure IssuesClosedAction
"reopened" -> pure IssuesReopenedAction
_ -> pure (IssuesActionOther t)
-- | Triggered when an issue is assigned, unassigned, labeled,
-- unlabeled, opened, edited, milestoned, demilestoned, closed, or reopened.
-- See <https://developer.github.com/v3/activity/events/types/#issuesevent>.
data IssuesEvent = IssuesEvent
{ evIssuesEventAction :: !IssuesEventAction
, evIssuesEventIssue :: !HookIssue
, evIssuesEventRepo :: !HookRepository
, evIssuesEventSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender IssuesEvent where senderOfEvent = evIssuesEventSender
instance EventHasRepo IssuesEvent where repoForEvent = evIssuesEventRepo
instance NFData IssuesEvent where rnf = genericRnf
data LabelEventAction
-- | Decodes from "created"
= LabelCreatedAction
-- | Decodes from "edited"
| LabelEditedAction
-- | Decodes from "deleted"
| LabelDeletedAction
-- | The result of decoding an unknown label event action type
| LabelActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData LabelEventAction where rnf = genericRnf
instance FromJSON LabelEventAction where
parseJSON = withText "Label event action" $ \t ->
case t of
"created" -> pure LabelCreatedAction
"edited" -> pure LabelEditedAction
"deleted" -> pure LabelDeletedAction
_ -> pure (LabelActionOther t)
-- | Triggered when a repository's label is created, edited, or deleted.
-- Events of this type are not visible in timelines. These events are only used to trigger hooks.
-- See <https://developer.github.com/v3/activity/events/types/#labelevent>.
data LabelEvent = LabelEvent
{ evLabelEventAction :: !LabelEventAction
, evLabelEventPayload :: !HookRepositoryLabel
, evLabelEventRepo :: !HookRepository
, evLabelEventOrganization :: !(Maybe HookOrganization)
, evLabelEventSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender LabelEvent where senderOfEvent = evLabelEventSender
instance EventHasRepo LabelEvent where repoForEvent = evLabelEventRepo
instance NFData LabelEvent where rnf = genericRnf
data MarketplacePurchaseEventAction
-- | Decodes from "purchased"
= MarketplacePurchasePurchasedAction
-- | Decodes from "cancelled"
| MarketplacePurchaseCancelledAction
-- | Decodes from "pending_change"
| MarketplacePurchasePendingChangeAction
-- | Decodes from "pending_change_cancelled"
| MarketplacePurchasePendingChangeCancelledAction
-- | Decodes from "changed"
| MarketplacePurchaseChangedAction
-- | The result of decoding an unknown marketplace purchase event action type
| MarketplacePurchaseActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData MarketplacePurchaseEventAction where rnf = genericRnf
instance FromJSON MarketplacePurchaseEventAction where
parseJSON = withText "Marketplace purchase event action" $ \t ->
case t of
"purchased" -> pure MarketplacePurchasePurchasedAction
"cancelled" -> pure MarketplacePurchaseCancelledAction
"pending_change" -> pure MarketplacePurchasePendingChangeAction
"pending_change_cancelled" -> pure MarketplacePurchasePendingChangeCancelledAction
"changed" -> pure MarketplacePurchaseChangedAction
_ -> pure (MarketplacePurchaseActionOther t)
-- | A GitHub Marketplace app receives information about changes to a user's plan from the Marketplace purchase event webhook. A Marketplace purchase event is triggered when a user purchases, cancels, or changes their payment plan.
-- See <https://docs.github.com/en/developers/github-marketplace/using-the-github-marketplace-api-in-your-app/webhook-events-for-the-github-marketplace-api#github-marketplace-purchase-webhook-payload>.
data MarketplacePurchaseEvent = MarketplacePurchaseEvent
{ evMarketplacePurchaseAction :: !MarketplacePurchaseEventAction
, evMarketplacePurchaseEffectiveDate :: !UTCTime
, evMarketplacePurchaseSender :: !HookUser
, evMarketplacePurchaseNew :: !HookMarketplacePurchase
, evMarketplacePurchasePrevious :: !(Maybe HookMarketplacePurchase)
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender MarketplacePurchaseEvent where senderOfEvent = evMarketplacePurchaseSender
instance NFData MarketplacePurchaseEvent where rnf = genericRnf
data MemberEventAction
-- | Decodes from "added"
= MemberAddedAction
-- | Decodes from "edited"
| MemberEditedAction
-- | Decodes from "deleted"
| MemberDeletedAction
-- | The result of decoding an unknown label event action type
| MemberActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData MemberEventAction where rnf = genericRnf
instance FromJSON MemberEventAction where
parseJSON = withText "Member event action" $ \t ->
case t of
"added" -> pure MemberAddedAction
"edited" -> pure MemberEditedAction
"deleted" -> pure MemberDeletedAction
_ -> pure (MemberActionOther t)
-- | Triggered when a user is added or removed as a collaborator to a repository, or has their permissions changed.
-- See <https://developer.github.com/v3/activity/events/types/#memberevent>.
data MemberEvent = MemberEvent
{ evMemberAction :: !MemberEventAction
, evMemberUser :: !HookUser
, evMemberRepo :: !HookRepository
, evMemberSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender MemberEvent where senderOfEvent = evMemberSender
instance EventHasRepo MemberEvent where repoForEvent = evMemberRepo
instance NFData MemberEvent where rnf = genericRnf
data MembershipEventAction
-- | Decodes from "added"
= MembershipAddedAction
-- | Decodes from "removed"
| MembershipRemovedAction
-- | The result of decoding an unknown label event action type
| MembershipActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData MembershipEventAction where rnf = genericRnf
instance FromJSON MembershipEventAction where
parseJSON = withText "Membership event action" $ \t ->
case t of
"added" -> pure MembershipAddedAction
"removed" -> pure MembershipRemovedAction
_ -> pure (MembershipActionOther t)
-- | Triggered when a user is added or removed from a team.
-- Events of this type are not visible in timelines. These events are only used to trigger hooks.
-- See <https://developer.github.com/v3/activity/events/types/#membershipevent>.
data MembershipEvent = MembershipEvent
{ evMembershipAction :: !MembershipEventAction
, evMembershipScope :: !Text -- ^ Current can only be "team"
, evMembershipUser :: !HookUser
, evMembershipTeam :: !HookTeam
, evMembershipOrg :: !HookOrganization
, evMembershipSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender MembershipEvent where senderOfEvent = evMembershipSender
instance NFData MembershipEvent where rnf = genericRnf
data MilestoneEventAction
-- | Decodes from "created"
= MilestoneCreatedAction
-- | Decodes from "closed"
| MilestoneClosedAction
-- | Decodes from "opened"
| MilestoneOpenedAction
-- | Decodes from "edited"
| MilestoneEditedAction
-- | Decodes from "deleted"
| MilestoneDeletedAction
-- | The result of decoding an unknown label event action type
| MilestoneActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData MilestoneEventAction where rnf = genericRnf
instance FromJSON MilestoneEventAction where
parseJSON = withText "Milestone event action" $ \t ->
case t of
"created" -> pure MilestoneCreatedAction
"closed" -> pure MilestoneClosedAction
"opened" -> pure MilestoneOpenedAction
"edited" -> pure MilestoneEditedAction
"deleted" -> pure MilestoneDeletedAction
_ -> pure (MilestoneActionOther t)
-- | Triggered when a milestone is created, closed, opened, edited, or deleted.
-- Events of this type are not visible in timelines. These events are only used to trigger hooks.
-- See <https://developer.github.com/v3/activity/events/types/#milestoneevent>.
data MilestoneEvent = MilestoneEvent
{ evMilestoneAction :: !MilestoneEventAction
, evMilestoenPayload :: !HookMilestone
, evMilestoneRepo :: !HookRepository
, evMilestoneOrg :: !HookOrganization
, evMilestoneSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender MilestoneEvent where senderOfEvent = evMilestoneSender
instance EventHasRepo MilestoneEvent where repoForEvent = evMilestoneRepo
instance NFData MilestoneEvent where rnf = genericRnf
data OrganizationEventAction
-- | Decodes from "member_added"
= OrgMemberAddedAction
-- | Decodes from "member_removed"
| OrgMemberRemovedAction
-- | Decodes from "member_invited"
| OrgMemberInvitedAction
-- | The result of decoding an unknown label event action type
| OrgActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData OrganizationEventAction where rnf = genericRnf
instance FromJSON OrganizationEventAction where
parseJSON = withText "Organization event action" $ \t ->
case t of
"member_added" -> pure OrgMemberAddedAction
"member_removed" -> pure OrgMemberRemovedAction
"member_invited" -> pure OrgMemberInvitedAction
_ -> pure (OrgActionOther t)
-- | Triggered when a user is added, removed, or invited to an Organization.
-- Events of this type are not visible in timelines. These events are only used to trigger organization hooks.
-- See <https://developer.github.com/v3/activity/events/types/#organizationevent>.
data OrganizationEvent = OrganizationEvent
{ evOrganizationAction :: !OrganizationEventAction
, evOrganizationInvitation :: !(Maybe HookOrganizationInvitation)
, evOrganizationMembership :: !(Maybe HookOrganizationMembership)
, evOrganizationOrg :: !HookOrganization
, evOrganizationSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender OrganizationEvent where senderOfEvent = evOrganizationSender
instance NFData OrganizationEvent where rnf = genericRnf
data OrgBlockEventAction
-- | Decodes from "blocked"
= OrgBlockBlockedAction
-- | Decodes from "unblocked"
| OrgBlockUnblockedAction
-- | The result of decoding an unknown org block event action type
| OrgBlockActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData OrgBlockEventAction where rnf = genericRnf
instance FromJSON OrgBlockEventAction where
parseJSON = withText "Organization event action" $ \t ->
case t of
"blocked" -> pure OrgBlockBlockedAction
"unblocked" -> pure OrgBlockUnblockedAction
_ -> pure (OrgBlockActionOther t)
-- | Triggered when an organization blocks or unblocks a user.
-- See <https://developer.github.com/v3/activity/events/types/#orgblockevent>.
data OrgBlockEvent = OrgBlockEvent
{ evOrgBlockAction :: !OrgBlockEventAction
, evOrgBlockUser :: !HookUser
, evOrgBlockOrg :: !HookOrganization
, evOrgBlockSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender OrgBlockEvent where senderOfEvent = evOrgBlockSender
instance NFData OrgBlockEvent where rnf = genericRnf
-- | Represents an attempted build of a GitHub Pages site, whether successful or not.
-- Triggered on push to a GitHub Pages enabled branch (gh-pages for project pages, master for user and organization pages).
-- Events of this type are not visible in timelines. These events are only used to trigger hooks.
-- See <https://developer.github.com/v3/activity/events/types/#pagebuildevent>.
data PageBuildEvent = PageBuildEvent
{ evPageBuildId :: !Int
, evPageBuildResult :: !HookPageBuildResult
, evPageBuildRepo :: !HookRepository
, evPageBuildSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender PageBuildEvent where senderOfEvent = evPageBuildSender
instance EventHasRepo PageBuildEvent where repoForEvent = evPageBuildRepo
instance NFData PageBuildEvent where rnf = genericRnf
data ProjectCardEventAction
-- | Decodes from "created"
= ProjectCardCreatedAction
-- | Decodes from "edited"
| ProjectCardEditedAction
-- | Decodes from "converted"
| ProjectCardConvertedAction
-- | Decodes from "moved"
| ProjectCardMovedAction
-- | Decodes from "deleted"
| ProjectCardDeletedAction
-- | The result of decoding an unknown project card event action type
| ProjectCardActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData ProjectCardEventAction where rnf = genericRnf
instance FromJSON ProjectCardEventAction where
parseJSON = withText "Project card event action" $ \t ->
case t of
"created" -> pure ProjectCardCreatedAction
"edited" -> pure ProjectCardEditedAction
"converted" -> pure ProjectCardConvertedAction
"moved" -> pure ProjectCardMovedAction
"deleted" -> pure ProjectCardDeletedAction
_ -> pure (ProjectCardActionOther t)
-- | Triggered when a project card is created, updated, moved, converted to an issue, or deleted.
-- See <https://developer.github.com/v3/activity/events/types/#projectcardevent>.
data ProjectCardEvent = ProjectCardEvent
{ evProjectCardAction :: !ProjectCardEventAction
, evProjectCardPayload :: !HookProjectCard
, evProjectCardRepo :: !HookRepository
, evProjectCardOrg :: !HookOrganization
, evProjectCardSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender ProjectCardEvent where senderOfEvent = evProjectCardSender
instance EventHasRepo ProjectCardEvent where repoForEvent = evProjectCardRepo
instance NFData ProjectCardEvent where rnf = genericRnf
data ProjectColumnEventAction
-- | Decodes from "created"
= ProjectColumnCreatedAction
-- | Decodes from "edited"
| ProjectColumnEditedAction
-- | Decodes from "moved"
| ProjectColumnMovedAction
-- | Decodes from "deleted"
| ProjectColumnDeletedAction
-- | The result of decoding an unknown project card event action type
| ProjectColumnActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData ProjectColumnEventAction where rnf = genericRnf
instance FromJSON ProjectColumnEventAction where
parseJSON = withText "Project column event action" $ \t ->
case t of
"created" -> pure ProjectColumnCreatedAction
"edited" -> pure ProjectColumnEditedAction
"moved" -> pure ProjectColumnMovedAction
"deleted" -> pure ProjectColumnDeletedAction
_ -> pure (ProjectColumnActionOther t)
-- | Triggered when a project column is created, updated, moved, or deleted.
-- See <https://developer.github.com/v3/activity/events/types/#projectcolumnevent>.
data ProjectColumnEvent = ProjectColumnEvent
{ evProjectColumnAction :: !ProjectColumnEventAction
, evProjectColumnPayload :: !HookProjectColumn
, evProjectColumnRepo :: !HookRepository
, evProjectColumnOrg :: !HookOrganization
, evProjectColumnSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender ProjectColumnEvent where senderOfEvent = evProjectColumnSender
instance EventHasRepo ProjectColumnEvent where repoForEvent = evProjectColumnRepo
instance NFData ProjectColumnEvent where rnf = genericRnf
data ProjectEventAction
-- | Decodes from "created"
= ProjectCreatedAction
-- | Decodes from "edited"
| ProjectEditedAction
-- | Decodes from "closed"
| ProjectClosedAction
-- | Decodes from "reopened"
| ProjectReopenedAction
-- | Decodes from "deleted"
| ProjectDeletedAction
-- | The result of decoding an unknown project event action type
| ProjectActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData ProjectEventAction where rnf = genericRnf
instance FromJSON ProjectEventAction where
parseJSON = withText "Project event action" $ \t ->
case t of
"created" -> pure ProjectCreatedAction
"edited" -> pure ProjectEditedAction
"closed" -> pure ProjectClosedAction
"reopened" -> pure ProjectReopenedAction
"deleted" -> pure ProjectDeletedAction
_ -> pure (ProjectActionOther t)
-- | Triggered when a project is created, updated, closed, reopened, or deleted.
-- See <https://developer.github.com/v3/activity/events/types/#projectevent>.
data ProjectEvent = ProjectEvent
{ evProjectEventAction :: !ProjectEventAction
, evProjectPayload :: !HookProject
, evProjectRepo :: !HookRepository
, evProjectOrganization :: !HookOrganization
, evProjectSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender ProjectEvent where senderOfEvent = evProjectSender
instance EventHasRepo ProjectEvent where repoForEvent = evProjectRepo
instance NFData ProjectEvent where rnf = genericRnf
-- | Triggered when a private repository is open sourced. Without a doubt: the best GitHub event.
-- See <https://developer.github.com/v3/activity/events/types/#publicevent>.
data PublicEvent = PublicEvent
{ evPublicEventRepo :: !HookRepository
, evPublicEventSender :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance EventHasSender PublicEvent where senderOfEvent = evPublicEventSender
instance EventHasRepo PublicEvent where repoForEvent = evPublicEventRepo
instance NFData PublicEvent where rnf = genericRnf
data PullRequestEventAction
-- | Decodes from "assigned"
= PullRequestAssignedAction
-- | Decodes from "unassigned"
| PullRequestUnassignedAction
-- | Decodes from "review_requsted"
| PullRequestReviewRequestedAction
-- | Decodes from "review_request_removed"
| PullRequestReviewRequestRemovedAction
-- | Decodes from "labeled"
| PullRequestLabeledAction
-- | Decodes from "unlabeled"
| PullRequestUnlabeledAction
-- | Decodes from "opened"
| PullRequestOpenedAction
-- | Decodes from "edited"
| PullRequestEditedAction
-- | Decodes from "closed"
| PullRequestClosedAction
-- | Decodes from "reopened"
| PullRequestReopenedAction
-- | The result of decoding an unknown pull request event action type
| PullRequestActionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData PullRequestEventAction where rnf = genericRnf
instance FromJSON PullRequestEventAction where
parseJSON = withText "Pull request event action" $ \t ->
case t of
"assigned" -> pure PullRequestAssignedAction
"unassigned" -> pure PullRequestUnassignedAction
"review_requsted" -> pure PullRequestReviewRequestedAction
"review_request_removed" -> pure PullRequestReviewRequestRemovedAction