-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathPayload.hs
More file actions
1698 lines (1529 loc) · 61.9 KB
/
Payload.hs
File metadata and controls
1698 lines (1529 loc) · 61.9 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.Payload
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 payload contents.
-}
module GitHub.Data.Webhooks.Payload
( -- * Construction Types
URL(..)
, getUrl
, OwnerType(..)
-- * Webhook Types
, HookIssue(..)
, HookRepository(..)
, HookRepositorySimple(..)
, HookRepositoryLabel(..)
, HookUser(..)
, HookSimpleUser(..)
, HookOrganization(..)
, HookOrganizationInvitation(..)
, HookOrganizationMembership(..)
, HookTeam(..)
, HookMarketplaceAccount(..)
, HookMarketplaceBillingCycle(..)
, HookMarketplacePlan(..)
, HookMarketplacePlanPriceModel(..)
, HookMarketplacePurchase(..)
, HookMilestone(..)
, HookMembership(..)
, HookProject(..)
, HookProjectCard(..)
, HookProjectColumn(..)
, HookIssueLabels(..)
, HookCommit(..)
, HookCheckSuiteStatus(..)
, HookCheckSuiteConclusion(..)
, HookCheckSuite(..)
, HookCheckSuiteCommit(..)
, HookCheckSuiteApp(..)
, HookCheckSuiteAppPermissions(..)
, HookCheckRunStatus(..)
, HookCheckRunConclusion(..)
, HookCheckRun(..)
, HookCheckRunOutput(..)
, HookCheckRunRequestedAction(..)
, HookChecksInstallation(..)
, HookChecksPullRequest(..)
, HookChecksPullRequestRepository(..)
, HookChecksPullRequestTarget(..)
, HookRelease(..)
, HookPullRequest(..)
, PullRequestTarget(..)
, HookPullRequestReview(..)
, HookInstallation(..)
, HookDeployment(..)
, HookDeploymentStatus(..)
, HookWikiPage(..)
, HookPageBuildResult(..)
, HookIssueComment(..)
, HookCommitComment(..)
, HookPullRequestReviewComment(..)
) where
import Data.Aeson (FromJSON(..), withObject, withText, (.!=), (.:), (.:?))
import Control.DeepSeq (NFData (..))
import Control.DeepSeq.Generics (genericRnf)
import Control.Applicative ((<|>), (<*>), pure)
import Data.Data (Data, Typeable)
import Data.Functor ((<$>))
import Data.Time (UTCTime)
import Data.Time.LocalTime (zonedTimeToUTC)
import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
import Data.Text (Text)
import qualified Data.Text as T
import Data.Vector (Vector)
import GHC.Generics (Generic)
-- Types lifted from the @github@ package.
-- | Represents the owner of a repository, pull request or similar.
--
-- A bot is a "special type of user which takes actions on behalf of GitHub Apps".
-- See also https://developer.github.com/v4/object/bot/
data OwnerType = OwnerUser | OwnerOrganization | OwnerBot
deriving (Eq, Ord, Enum, Bounded, Show, Read, Generic, Typeable, Data)
instance NFData OwnerType
instance FromJSON OwnerType where
parseJSON = withText "Owner type" $ \t ->
case T.toLower t of
"user" -> pure OwnerUser
"organization" -> pure OwnerOrganization
"bot" -> pure OwnerBot
_ -> fail $ "Unknown owner type: " ++ T.unpack t
-- | Represents an internet address that would be suitable to query
-- for more information. The GitHub API only returns valid 'URL's.
newtype URL = URL Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData URL where rnf = genericRnf
instance FromJSON URL where
parseJSON = withText "URL" (pure . URL)
-- | Demote GitHub URL to Text.
getUrl :: URL -> Text
getUrl (URL url) = url
-- Hooks
type IssueState = Text
-- | Represents the "issue" field in the 'IssueCommentEvent'
-- and 'IssueEvent' payload.
data HookIssue = HookIssue
{ whIssueUrl :: !URL
, whIssueLabelsUrl :: !URL
, whIssueCommentsUrl :: !URL
, whIssueEventsUrl :: !URL
, whIssueHtmlUrl :: !URL
, whIssueId :: !Int
, whIssueNodeId :: !Text
, whIssueNumber :: !Int
, whIssueTitle :: !Text
, whIssueUser :: !HookUser
, whIssueLabels :: !(Vector HookIssueLabels)
, whIssueState :: IssueState
, whIssueIsLocked :: !Bool
, whIssueAssignee :: !(Maybe HookUser)
, whIssueMilestone :: !(Maybe HookMilestone)
, whIssueCommentCount :: !Int
, whIssueCreatedAt :: !UTCTime
, whIssueUpdatedAt :: !UTCTime
, whIssueClosedAt :: !(Maybe UTCTime)
, whIssueBody :: !Text
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookIssue where rnf = genericRnf
-- | Represents the "repository" field in all types of payload.
data HookRepository = HookRepository
{ whRepoId :: !Int
, whRepoNodeId :: !Text
, whRepoName :: !Text
, whRepoFullName :: !Text
, whRepoOwner :: !(Either HookSimpleUser HookUser)
, whRepoIsPrivate :: !Bool
, whRepoHtmlUrl :: !URL
, whRepoDescription :: !Text
, whRepoIsAFork :: !Bool
, whRepoUrl :: !URL
, whRepoForksUrl :: !URL
, whRepoKeysUrl :: !URL
, whRepoCollaboratorsUrl :: !URL
, whRepoTeamsUrl :: !URL
, whRepoHooksUrl :: !URL
, whRepoIssueEventsUrl :: !URL
, whRepoEventsUrl :: !URL
, whRepoAssigneesUrl :: !URL
, whRepoBranchesUrl :: !URL
, whRepoTagsUrl :: !URL
, whRepoBlobsUrl :: !URL
, whRepoGitTagsUrl :: !URL
, whRepoGitRefsUrl :: !URL
, whRepoTreesUrl :: !URL
, whRepoStatusesUrl :: !URL
, whRepoLanguagesUrl :: !URL
, whRepoStargazersUrl :: !URL
, whRepoContributorsUrl :: !URL
, whRepoSubscribersUrl :: !URL
, whRepoSubscriptionUrl :: !URL
, whRepoCommitsUrl :: !URL
, whRepoGitCommitsUrl :: !URL
, whRepoCommentsUrl :: !URL
, whRepoIssueCommentsUrl :: !URL
, whRepoContentsUrl :: !URL
, whRepoCompareUrl :: !URL
, whRepoMergesUrl :: !URL
, whRepoArchiveUrl :: !URL
, whRepoDownloadsUrl :: !URL
, whRepoIssuesUrl :: !URL
, whRepoPullsUrl :: !URL
, whRepoMilestonesUrl :: !URL
, whRepoNotificationsUrl :: !URL
, whRepoLabelsUrl :: !URL
, whRepoReleasesUrl :: !URL
, whRepoCreatedAt :: !UTCTime
, whRepoUpdatedAt :: !UTCTime
, whRepoPushedAt :: !UTCTime
, whRepoGitUrl :: !URL
, whRepoSshUrl :: !URL
, whRepoCloneUrl :: !URL
, whRepoSvnUrl :: !URL
, whRepoHomepage :: !(Maybe URL)
, whRepoSize :: !Int
, whRepoStargazersCount :: !Int
, whRepoWatchersCount :: !Int
, whRepoLanguage :: !(Maybe Text)
, whRepoHasIssues :: !Bool
, whRepoHasDownloads :: !Bool
, whRepoHasWiki :: !Bool
, whRepoHasPages :: !Bool
, whRepoForkCount :: !Int
, whRepoMirrorUrl :: !(Maybe URL)
, whRepoOpenIssuesCount :: !Int
, whRepoDefaultBranchName :: !Text
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookRepository where rnf = genericRnf
-- | Represents the "repositories_added" and "repositories_removed"
-- field in the 'InstallationRepositoriesEvent' payload.
data HookRepositorySimple = HookRepositorySimple
{ whSimplRepoId :: !Int
, whSimplRepoNodeId :: !Text
, whSimplRepoName :: !Text
, whSimplRepoFullName :: !Text
, whSimplRepoIsPrivate :: !Bool
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookRepositorySimple where rnf = genericRnf
-- | Represents the "label" field in the 'LabelEvent' payload.
data HookRepositoryLabel = HookRepositoryLabel
{ whRepoLabelNodeId :: !(Maybe Text)
, whRepoLabelUrl :: !URL
, whRepoLabelName :: !Text
, whRepoLabelColor :: !Text
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookRepositoryLabel where rnf = genericRnf
-- | Represents the "user" field in all types of payload.
data HookUser = HookUser
{ whUserLogin :: !Text
, whUserId :: !Int
, whUserNodeId :: !Text
, whUserAvatarUrl :: !URL
, whUserGravatarId :: !URL
, whUserUrl :: !URL
, whUserHtmlUrl :: !URL
, whUserFollowersUrl :: !URL
, whUserFollowingUrl :: !URL
, whUserGistsUrl :: !URL
, whUserStarredUrl :: !URL
, whUserSubscriptionsUrl :: !URL
, whUserOrganizationsUrl :: !URL
, whUserReposUrl :: !URL
, whUserEventsUrl :: !URL
, whUserReceivedEventsUrl :: !URL
, whUserType :: !OwnerType
, whUserIsAdminOfSite :: !Bool
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookUser where rnf = genericRnf
-- FIXME: Not sure where this is.
data HookSimpleUser = HookSimpleUser
{ whSimplUserName :: !Text
, whSimplUserEmail :: !Text
, whSimplUserLogin :: !(Maybe Text)
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookSimpleUser where rnf = genericRnf
-- | Represents the "organization" field in all types of payload.
data HookOrganization = HookOrganization
{ whOrgLogin :: !Text
, whOrgId :: !Int
, whOrgNodeId :: !Text
, whOrgUrl :: !URL
, whOrgReposUrl :: !URL
, whOrgEventsUrl :: !URL
, whOrgHooksUrl :: !(Maybe URL)
, whOrgIssuesUrl :: !(Maybe URL)
, whOrgMembersUrl :: !URL
, whOrgPublicMembersUrl :: !URL
, whOrgAvatarUrl :: !URL
, whOrgDescription :: !Text
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookOrganization where rnf = genericRnf
-- | Represents the "invitation" field in the 'OrganizationEvent' payload.
data HookOrganizationInvitation = HookOrganizationInvitation
{ whOrgInvitationId :: !Int
, whOrgInvitationNodeId :: !Text
, whOrgInvitationLogin :: !Text
, whOrgInvitationEmail :: !(Maybe Text)
, whOrgInvitationRole :: !Text
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookOrganizationInvitation where rnf = genericRnf
-- | Represents the "membership" field in the 'OrganizationEvent' payload.
data HookOrganizationMembership = HookOrganizationMembership
{ whOrgMembershipUrl :: !URL
, whOrgMembershipState :: !Text
, whOrgMembershipRole :: !Text
, whOrgMembershipOrgUrl :: !URL
, whOrgMembershipUser :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookOrganizationMembership where rnf = genericRnf
-- | Represents the "team" field in the 'TeamEvent' and
-- 'TeamAddEvent' payload.
data HookTeam = HookTeam
{ whTeamName :: !Text
, whTeamId :: !Int
, whTeamNodeId :: !Text
, whTeamSlug :: !Text
, whTeamPermission :: !Text
, whTeamUrl :: !URL
, whTeamMembersUrl :: !URL
, whTeamRepositoriesUrl :: !URL
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookTeam where rnf = genericRnf
-- | Represents the "billing_cycle" field in the
-- 'HookMarketplacePurchase' payload.
data HookMarketplaceBillingCycle
-- | Decodes from "yearly"
= HookMarketplaceBillingCycleYearly
-- | Decodes from "monthly".
| HookMarketplaceBillingCycleMonthly
-- | The result of decoding an unknown marketplace purchase billing cycle type
| HookMarketplaceBillingCycleOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData HookMarketplaceBillingCycle where rnf = genericRnf
instance FromJSON HookMarketplaceBillingCycle where
parseJSON = withText "Hook marketplace billing cycle" $ \t ->
case t of
"yearly" -> pure HookMarketplaceBillingCycleYearly
"monthly" -> pure HookMarketplaceBillingCycleMonthly
_ -> pure (HookMarketplaceBillingCycleOther t)
-- | Represents the "marketplace_purchase" field in the 'MarketplacePurchaseEvent' payload.
data HookMarketplacePurchase = HookMarketplacePurchase
{ whMarketplacePurchaseAccount :: !HookMarketplaceAccount
, whMarketplacePurchaseBillingCycle :: !(Maybe HookMarketplaceBillingCycle)
, whMarketplacePurchaseUnitCount :: !Int
, whMarketplacePurchaseOnFreeTrial :: !Bool
, whMarketplacePurchaseFreeTrialEndsOn :: !(Maybe UTCTime)
, whMarketplacePurchaseNextBillingDate :: !(Maybe UTCTime)
, whMarketplacePurchasePlan :: !HookMarketplacePlan
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookMarketplacePurchase where rnf = genericRnf
-- | Represents the "account" field in the 'HookMarketplacePurchase' payload.
data HookMarketplaceAccount = HookMarketplaceAccount
{ whMarketplaceAccountType :: !OwnerType
, whMarketplaceAccountId :: !Int
, whMarketplaceAccountNodeId :: !Text
, whMarketplaceAccountLogin :: !Text
, whMarketplaceAccountOrganizationBillingEmail :: !(Maybe Text)
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookMarketplaceAccount where rnf = genericRnf
-- | Represents the "plan" field in the 'HookMarketplacePurchase' payload.
data HookMarketplacePlan = HookMarketplacePlan
{ whMarketplacePlanId :: !Int
, whMarketplacePlanName :: !Text
, whMarketplacePlanDescription :: !Text
, whMarketplacePlanMonthlyPriceInCents :: !Int
, whMarketplacePlanYearlyPriceInCents :: !Int
, whMarketplacePlanPriceModel :: !HookMarketplacePlanPriceModel
, whMarketplacePlanHasFreeTrial :: !Bool
, whMarketplacePlanUnitName :: !(Maybe Text)
, whMarketplacePlanBullet :: !(Vector Text)
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookMarketplacePlan where rnf = genericRnf
-- | Represents the "price_model" field in the
-- 'HookMarketplacePlan' payload.
data HookMarketplacePlanPriceModel
-- | Decodes from "flat-rate"
= HookMarketplacePlanPriceModelFlatRate
-- | Decodes from "per-unit".
| HookMarketplacePlanPriceModelPerUnit
-- | Decodes from "free".
| HookMarketplacePlanPriceModelFree
-- | The result of decoding an unknown marketplace plan price model
| HookMarketplacePlanPriceModelOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData HookMarketplacePlanPriceModel where rnf = genericRnf
instance FromJSON HookMarketplacePlanPriceModel where
parseJSON = withText "Hook marketplace plan price model" $ \t ->
case t of
"flat-rate" -> pure HookMarketplacePlanPriceModelFlatRate
"per-unit" -> pure HookMarketplacePlanPriceModelPerUnit
"free" -> pure HookMarketplacePlanPriceModelFree
_ -> pure (HookMarketplacePlanPriceModelOther t)
type MilestoneState = Text
-- | Represents the "milestone" field in the 'MilestoneEvent' payload.
data HookMilestone = HookMilestone
{ whMilestoneUrl :: !URL
, whMilestoneHtmlUrl :: !URL
, whMilestoneLabelsUrl :: !URL
, whMilestoneId :: !Int
, whMilestoneNodeId :: !Text
, whMilestoneNumber :: !Int
, whMilestoneTitle :: !Text
, whMilestoneDescription :: !(Maybe Text)
, whMilestoneCreator :: !HookUser
, whMilestoneOpenIssues :: !Int
, whMilestoneClosedIssues :: !Int
, whMilestoneState :: !MilestoneState
, whMilestoneCreatedAt :: !UTCTime
, whMilestoneUpdatedAt :: !UTCTime
, whMilestoneDueOn :: !(Maybe UTCTime)
, whMilestoneClosedAt :: !(Maybe UTCTime)
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookMilestone where rnf = genericRnf
type MembershipState = Text
type MembershipRole = Text
-- FIXME: Not sure where this is.
data HookMembership = HookMembership
{ whMembershipUrl :: !URL
, whMembershipState :: !MembershipState
, whMembershipRole :: !MembershipRole
, whMembershipOrgUrl :: !URL
, whMembershipUser :: !HookUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookMembership where rnf = genericRnf
type ProjectState = Text
-- | Represents the "project" field in the 'ProjectEvent' payload.
data HookProject = HookProject
{ whProjectOwnerUrl :: !URL
, whProjectUrl :: !URL
, whProjectColumnsUrl :: !URL
, whProjectId :: !Int
, whProjectNodeId :: !Text
, whProjectName :: !Text
, whProjectBody :: !Text
, whProjectNumber :: !Int
, whProjectState :: !ProjectState
, whProjectCreator :: !HookUser
, whProjectCreatedAt :: !UTCTime
, whProjectUpdatedAt :: !UTCTime
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookProject where rnf = genericRnf
-- | Represents the "project_card" field in the 'ProjectCardEvent' payload.
data HookProjectCard = HookProjectCard
{ whProjectCardUrl :: !URL
, whProjectCardColumnUrl :: !URL
, whProjectCardColumnId :: !Int
, whProjectCardId :: !Int
, whProjectCardNodeId :: !Text
, whProjectCardNote :: !(Maybe Text)
, whProjectCardCreator :: !HookUser
, whProjectCardCreatedAt :: !UTCTime
, whProjectCardUpdatedAt :: !UTCTime
, whProjectCardContentUrl :: !URL
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookProjectCard where rnf = genericRnf
-- | Represents the "project_column" field in the 'ProjectColumnEvent' payload.
data HookProjectColumn = HookProjectColumn
{ whProjectColumnUrl :: !URL
, whProjectColumnProjUrl :: !URL
, whProjectColumnCardsUrl :: !URL
, whProjectColumnId :: !Int
, whProjectColumnNodeId :: !Text
, whProjectColumnName :: !Text
, whProjectColumnCreatedAt :: !UTCTime
, whProjectColumnUpdatedAt :: !UTCTime
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookProjectColumn where rnf = genericRnf
-- | Represents the "issue.labels" field in the
-- 'IssueCommentEvent' and 'IssueEvent' payloads.
data HookIssueLabels = HookIssueLabels
{ whIssueLabelId :: !(Maybe Int) -- ^ Not always sent.
, whIssueLabelNodeId :: !(Maybe Text)
, whIssueLabelUrl :: !URL
, whIssueLabelName :: !Text
, whIssueLabelColor :: !Text
, whIssueLabelIsDefault :: !Bool -- ^ Defaults to false when not present.
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookIssueLabels where rnf = genericRnf
-- | Represents the "status" field in the
-- 'HookCheckSuite' payload.
data HookCheckSuiteStatus
-- | Decodes from "requested"
= HookCheckSuiteStatusRequested
-- | Decodes from "queued".
| HookCheckSuiteStatusQueued
-- | Decodes from "in_progress"
| HookCheckSuiteStatusInProgress
-- | Decodes from "completed"
| HookCheckSuiteStatusCompleted
-- | The result of decoding an unknown check suite status type
| HookCheckSuiteStatusOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData HookCheckSuiteStatus where rnf = genericRnf
instance FromJSON HookCheckSuiteStatus where
parseJSON = withText "Hook check suite status" $ \t ->
case t of
"requested" -> pure HookCheckSuiteStatusRequested
"queued" -> pure HookCheckSuiteStatusQueued
"in_progress" -> pure HookCheckSuiteStatusInProgress
"completed" -> pure HookCheckSuiteStatusCompleted
_ -> pure (HookCheckSuiteStatusOther t)
-- | Represents the "conclusion" field in the
-- 'HookCheckSuite' payload.
data HookCheckSuiteConclusion
-- | Decodes from "success"
= HookCheckSuiteConclusionSuccess
-- | Decodes from "failure"
| HookCheckSuiteConclusionFailure
-- | Decodes from "neutral"
| HookCheckSuiteConclusionNeutral
-- | Decodes from "cancelled"
| HookCheckSuiteConclusionCancelled
-- | Decodes from "timed_out"
| HookCheckSuiteConclusionTimedOut
-- | Decodes from "action_required"
| HookCheckSuiteConclusionActionRequired
-- | Decodes from "stale"
| HookCheckSuiteConclusionStale
-- | The result of decoding an unknown check suite conclusion type
| HookCheckSuiteConclusionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData HookCheckSuiteConclusion where rnf = genericRnf
instance FromJSON HookCheckSuiteConclusion where
parseJSON = withText "Hook check suite status" $ \t ->
case t of
"success" -> pure HookCheckSuiteConclusionSuccess
"failure" -> pure HookCheckSuiteConclusionFailure
"neutral" -> pure HookCheckSuiteConclusionNeutral
"cancelled" -> pure HookCheckSuiteConclusionCancelled
"timed_out" -> pure HookCheckSuiteConclusionTimedOut
"action_required" -> pure HookCheckSuiteConclusionActionRequired
"stale" -> pure HookCheckSuiteConclusionStale
_ -> pure (HookCheckSuiteConclusionOther t)
-- FIXME: Missing nested "app", there are examples, but no documentation.
-- | Represents the "check_suite" field in the
-- 'CheckSuiteEvent' payload.
data HookCheckSuite = HookCheckSuite
{ whCheckSuiteId :: !Int
, whCheckSuiteNodeId :: !Text
, whCheckSuiteHeadBranch :: !(Maybe Text) -- ^ The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty pull_requests array and a null value for head_branch.
, whCheckSuiteHeadSha :: !Text
, whCheckSuiteStatus :: !HookCheckSuiteStatus
, whCheckSuiteConclusion :: !(Maybe HookCheckSuiteConclusion)
, whCheckSuiteUrl :: !URL
, whCheckSuiteBeforeSha :: !(Maybe Text)
, whCheckSuiteAfterSha :: !(Maybe Text)
, whCheckSuitePullRequests :: !(Vector HookChecksPullRequest)
, whCheckSuiteCreatedAt :: !UTCTime
, whCheckSuiteUpdatedAt :: !UTCTime
, whCheckSuiteLatestCheckRunsCount :: !(Maybe Int) -- not included in the check run nested payload
, whCheckSuiteCheckRunsUrl :: !(Maybe URL) -- not included in the check run nested payload
, whCheckSuiteHeadCommit :: !(Maybe HookCheckSuiteCommit) -- not included in the check run nested payload
, whCheckSuiteApp :: !(Maybe HookCheckSuiteApp) -- not included in the check run nested payload
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookCheckSuite where rnf = genericRnf
-- | Represents the "head_commit" field in the
-- 'CheckSuiteEvent' payload.
data HookCheckSuiteCommit = HookCheckSuiteCommit
{ whCheckSuiteCommitSha :: !Text -- ^ Sometimes called the commit 'id'.
, whCheckSuiteCommitAuthor :: !HookSimpleUser
, whCheckSuiteCommitCommitter :: !HookSimpleUser
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookCheckSuiteCommit where rnf = genericRnf
-- | Represents the "app" field in the
-- 'CheckSuiteEvent' payload.
data HookCheckSuiteApp = HookCheckSuiteApp
{ whCheckSuiteAppId :: !Int
, whCheckSuiteAppNodeId :: !Text
, whCheckSuiteAppSlug :: !(Maybe Text)
, whCheckSuiteAppOwner :: !HookUser
, whCheckSuiteAppName :: !Text
, whCheckSuiteAppDescription :: !Text
, whCheckSuiteAppExternalUrl :: !URL
, whCheckSuiteAppHtmlUrl :: !URL
, whCheckSuiteAppClientId :: !(Maybe Text)
, whCheckSuiteAppCreatedAt :: !UTCTime
, whCheckSuiteAppUpdatedAt :: !UTCTime
, whCheckSuiteAppPermissions :: !(Maybe HookCheckSuiteAppPermissions)
, whCheckSuiteAppEvents :: !(Maybe (Vector Text))
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookCheckSuiteApp where rnf = genericRnf
data HookCheckSuiteAppPermissions = HookCheckSuiteAppPermissions
{ whCheckSuiteAppPermissionsActions :: !(Maybe Text)
, whCheckSuiteAppPermissionsAdministration :: !(Maybe Text)
, whCheckSuiteAppPermissionsChecks :: !(Maybe Text)
, whCheckSuiteAppPermissionsContentReferences :: !(Maybe Text)
, whCheckSuiteAppPermissionsContents :: !(Maybe Text)
, whCheckSuiteAppPermissionsDeployments :: !(Maybe Text)
, whCheckSuiteAppPermissionsDiscussions :: !(Maybe Text)
, whCheckSuiteAppPermissionsEmails :: !(Maybe Text)
, whCheckSuiteAppPermissionsEnvironments :: !(Maybe Text)
, whCheckSuiteAppPermissionsIssues :: !(Maybe Text)
, whCheckSuiteAppPermissionsKeys :: !(Maybe Text)
, whCheckSuiteAppPermissionsMembers :: !(Maybe Text)
, whCheckSuiteAppPermissionsMetadata :: !(Maybe Text)
, whCheckSuiteAppPermissionsOrganizationAdministration :: !(Maybe Text)
, whCheckSuiteAppPermissionsOrganizationHooks :: !(Maybe Text)
, whCheckSuiteAppPermissionsOrganisationPackages :: !(Maybe Text)
, whCheckSuiteAppPermissionsOrganizationPlan :: !(Maybe Text)
, whCheckSuiteAppPermissionsOrganizationProjects :: !(Maybe Text)
, whCheckSuiteAppPermissionsOrganizationSecrets :: !(Maybe Text)
, whCheckSuiteAppPermissionsOrganizationSelfHostedRunners :: !(Maybe Text)
, whCheckSuiteAppPermissionsOrganizationUserBlocking :: !(Maybe Text)
, whCheckSuiteAppPermissionsPackages :: !(Maybe Text)
, whCheckSuiteAppPermissionsPages :: !(Maybe Text)
, whCheckSuiteAppPermissionsPullRequests :: !(Maybe Text)
, whCheckSuiteAppPermissionsRepositoryHooks :: !(Maybe Text)
, whCheckSuiteAppPermissionsRepositoryProjects :: !(Maybe Text)
, whCheckSuiteAppPermissionsSecretScanningAlerts :: !(Maybe Text)
, whCheckSuiteAppPermissionsSecrets :: !(Maybe Text)
, whCheckSuiteAppPermissionsSecurityEvents :: !(Maybe Text)
, whCheckSuiteAppPermissionsSecurityScanningAlert :: !(Maybe Text)
, whCheckSuiteAppPermissionsSingleFile :: !(Maybe Text)
, whCheckSuiteAppPermissionsStatuses :: !(Maybe Text)
, whCheckSuiteAppPermissionsTeamDiscussion :: !(Maybe Text)
, whCheckSuiteAppPermissionsVulnerabilityAlerts :: !(Maybe Text)
, whCheckSuiteAppPermissionsWorkflows :: !(Maybe Text)
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookCheckSuiteAppPermissions where rnf = genericRnf
-- | Represents the "status" field in the
-- 'HookCheckRun' payload.
data HookCheckRunStatus
-- | Decodes from "queued"
= HookCheckRunStatusQueued
-- | Decodes from "in_progress"
| HookCheckRunStatusInProgress
-- | Decodes from "completed"
| HookCheckRunStatusCompleted
-- | The result of decoding an unknown check run status type
| HookCheckRunStatusOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData HookCheckRunStatus where rnf = genericRnf
instance FromJSON HookCheckRunStatus where
parseJSON = withText "Hook check suite status" $ \t ->
case t of
"queued" -> pure HookCheckRunStatusQueued
"in_progress" -> pure HookCheckRunStatusInProgress
"completed" -> pure HookCheckRunStatusCompleted
_ -> pure (HookCheckRunStatusOther t)
-- | Represents the "conclusion" field in the
-- 'HookCheckRun' payload.
data HookCheckRunConclusion
-- | Decodes from "success"
= HookCheckRunConclusionSuccess
-- | Decodes from "failure"
| HookCheckRunConclusionFailure
-- | Decodes from "neutral"
| HookCheckRunConclusionNeutral
-- | Decodes from "cancelled"
| HookCheckRunConclusionCancelled
-- | Decodes from "timed_out"
| HookCheckRunConclusionTimedOut
-- | Decodes from "action_required"
| HookCheckRunConclusionActionRequired
-- | Decodes from "stale"
| HookCheckRunConclusionStale
-- | The result of decoding an unknown check run conclusion type
| HookCheckRunConclusionOther !Text
deriving (Eq, Ord, Show, Generic, Typeable, Data)
instance NFData HookCheckRunConclusion where rnf = genericRnf
instance FromJSON HookCheckRunConclusion where
parseJSON = withText "Hook check suite status" $ \t ->
case t of
"success" -> pure HookCheckRunConclusionSuccess
"failure" -> pure HookCheckRunConclusionFailure
"neutral" -> pure HookCheckRunConclusionNeutral
"cancelled" -> pure HookCheckRunConclusionCancelled
"timed_out" -> pure HookCheckRunConclusionTimedOut
"action_required" -> pure HookCheckRunConclusionActionRequired
"stale" -> pure HookCheckRunConclusionStale
_ -> pure (HookCheckRunConclusionOther t)
-- | Represents the "check_run" field in the
-- 'CheckRunEvent' payload.
data HookCheckRun = HookCheckRun
{ whCheckRunId :: !Int
, whCheckRunNodeId :: !Text
, whCheckRunHeadSha :: !Text
, whCheckRunExternalId :: !Text
, whCheckRunUrl :: !URL
, whCheckRunHtmlUrl :: !URL
, whCheckRunDetailsUrl :: !URL
, whCheckRunStatus :: !HookCheckRunStatus
, whCheckRunConclusion :: !(Maybe HookCheckRunConclusion)
, whCheckRunStartedAt :: !UTCTime
, whCheckRunCompletedAt :: !(Maybe UTCTime)
, whCheckRunOutput :: !HookCheckRunOutput
, whCheckRunName :: !Text
, whCheckRunCheckSuite :: !HookCheckSuite
, whCheckRunPullRequests :: !(Vector HookChecksPullRequest)
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookCheckRun where rnf = genericRnf
-- | Represents the "output" field in the
-- 'HookCheckRun' payload.
data HookCheckRunOutput = HookCheckRunOutput
{ whCheckRunOutputTitle :: !(Maybe Text)
, whCheckRunOutputSummary :: !(Maybe Text)
, whCheckRunOutputText :: !(Maybe Text)
, whCheckRunOutputAnnotationsCount :: !Int
, whCheckRunOutputAnnotationsUrl :: !URL
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookCheckRunOutput where rnf = genericRnf
-- | Represents the "requested_action" field in the
-- 'CheckRunEvent' payload.
newtype HookCheckRunRequestedAction = HookCheckRunRequestedAction
{ whCheckRunRequestedActionIdentifier :: Text
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookCheckRunRequestedAction where rnf = genericRnf
-- | Represents the "installation" field in the checks payloads.
data HookChecksInstallation = HookChecksInstallation
{ whChecksInstallationId :: Int
, whChecksInstallationNodeId :: Text
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookChecksInstallation where rnf = genericRnf
-- | Represents the "pull_requests" field in the checks payloads.
data HookChecksPullRequest = HookChecksPullRequest
{ whChecksPullRequestUrl :: !URL
, whChecksPullRequestId :: !Int
, whChecksPullRequestNumber :: !Int
, whChecksPullRequestHead :: !HookChecksPullRequestTarget
, whChecksPullRequestBase :: !HookChecksPullRequestTarget
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookChecksPullRequest where rnf = genericRnf
-- | Represents the "repo" field in the checks pull_request payloads.
data HookChecksPullRequestRepository = HookChecksPullRequestRepository
{ whChecksPullRequestRepositoryId :: !Int
, whChecksPullRequestRepositoryUrl :: !URL
, whChecksPullRequestRepositoryName :: !Text
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookChecksPullRequestRepository where rnf = genericRnf
-- | Represents the repo targets in
-- the checks pull requests repository payloads.
data HookChecksPullRequestTarget = HookChecksPullRequestTarget
{ whChecksPullRequestTargetSha :: !Text
, whChecksPullRequestTargetRef :: !Text -- ex "somebranch"
, whChecksPullRequestTargetRepo :: !HookChecksPullRequestRepository
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookChecksPullRequestTarget where rnf = genericRnf
--- FIXME: Missing nested metadata that provides commit description
--- FIXME: Missing property "parent" (no examples provided)
data HookCommit = HookCommit
{ whCommitSha :: !Text -- ^ Sometimes called the commit 'id'.
, whCommitUrl :: !URL
, whCommitHtmlUrl :: !(Maybe URL) -- ^ Not always sent.
, whCommitCommentsUrl :: !(Maybe URL) -- ^ Not always sent.
, whCommitAuthor :: !(Either HookSimpleUser HookUser)
, whCommitCommitter :: !(Either HookSimpleUser HookUser)
, whCommitDistinct :: !(Maybe Bool) -- ^ Whether this commit is distinct from any that have been pushed before. Not always sent.
, whCommitMessage :: !(Maybe Text) -- ^ Not always sent
, whCommitTimestamp :: !(Maybe UTCTime) -- ^ Not always sent.
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookCommit where rnf = genericRnf
-- FIXME: Missing property "assets" (no examples provided)
data HookRelease = HookRelease
{ whReleaseUrl :: !URL
, whReleaseAssetsUrl :: !URL
, whReleaseUploadUrl :: !URL
, whReleaseHtmlUrl :: !URL
, whReleaseId :: !Int
, whReleaseNodeId :: !Text
, whReleaseTagName :: !Text
, whReleaseTargetCommitish :: !Text
, whReleaseName :: !(Maybe Text)
, whReleaseIsDraft :: !Bool
, whReleaseAuthor :: !HookUser
, whReleaseIsPreRelease :: !Bool
, whReleaseCreatedAt :: !UTCTime
, whReleasePublishedAt :: !(Maybe UTCTime)
, whReleaseTarballUrl :: !URL
, whReleaseZipballUrl :: !URL
, whReleaseBody :: !(Maybe Text)
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookRelease where rnf = genericRnf
data HookPullRequest = HookPullRequest
{ whPullReqUrl :: !URL
, whPullReqId :: !Int
, whPullReqNodeId :: !Text
, whPullReqHtmlUrl :: !URL
, whPullReqDiffUrl :: !URL
, whPullReqPatchUrl :: !URL
, whPullReqIssueUrl :: !URL
, whPullReqNumber :: !Int
, whPullReqState :: !Text -- FIXME: Smart constructor?
, whPullReqIsLocked :: !Bool
, whPullReqTitle :: !Text
, whPullReqUser :: !HookUser
, whPullReqBody :: !Text
, whPullReqCreatedAt :: !UTCTime
, whPullReqUpdatedAt :: !UTCTime
, whPullReqClosedAt :: !(Maybe UTCTime)
, whPullReqMergedAt :: !(Maybe UTCTime)
, whPullReqMergeCommitSha :: !(Maybe Text)
, whPullReqAssignee :: !(Maybe HookUser)
, whPullReqMilestone :: !(Maybe HookMilestone)
, whPullReqCommitsUrl :: !URL
, whPullReqRevCommentsUrl :: !URL
, whPullReqRevCommentUrl :: !URL
, whPullReqCommentsUrl :: !URL
, whPullReqStatusesUrl :: !URL
, whPullReqBase :: !PullRequestTarget
, whPullReqHead :: !PullRequestTarget
, whPullReqIsDraft :: !(Maybe Bool)
-- , whPullReqIsMerged :: !Bool
-- , whPullReqIsMergeable :: !Bool
, whPullReqMergeableState :: !(Maybe Text) -- ^ Not sent with all events.
-- , whPullReqMergedBy :: !(Maybe HookUser)
, whPullReqCommentCount :: !(Maybe Int) -- ^ Not sent with all events.
, whPullReqRevCommentCount :: !(Maybe Int) -- ^ Not sent with all events.
, whPullReqCommitCount :: !(Maybe Int) -- ^ Not sent with all events.
, whPullReqAdditionsCount :: !(Maybe Int) -- ^ Not sent with all events.
, whPullReqDeletionsCount :: !(Maybe Int) -- ^ Not sent with all events.
, whPullReqFileChangeCount :: !(Maybe Int) -- ^ Not sent with all events.
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookPullRequest where rnf = genericRnf
data PullRequestTarget = PullRequestTarget
{ whPullReqTargetSha :: !Text
, whPullReqTargetUser :: !HookUser
, whPullReqTargetRepo :: !(Maybe HookRepository) -- maybe null, see #47
, whPullReqTargetLabel :: !Text -- ex "user:branch"
, whPullReqTargetRef :: !Text -- ex "somebranch"
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData PullRequestTarget where rnf = genericRnf
-- | Represents the "pull_request" field in the 'PullRequestReviewEvent' payload.
data HookPullRequestReview = HookPullRequestReview
{ whPullReqReviewId :: !Int
, whPullReqReviewNodeId :: !Text
, whPullReqReviewUser :: !HookUser
, whPullReqReviewBody :: !Text
, whPullReqReviewSubmittedAt :: !UTCTime
, whPullReqReviewState :: !Text
, whPullReqReviewHtmlUrl :: !URL
, whPullReqReviewPullUrl :: !URL
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookPullRequestReview where rnf = genericRnf
-- | Represents the "installation" field in the 'InstallationEvent' payload.
data HookInstallation = HookInstallation
{ whInstallationId :: !Int
, whInstallationAccount :: !HookUser
, whInstallationRepoSel :: !Text
, whInstallationTokenUrl :: !URL
, whInstallationRepoUrl :: !URL
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookInstallation where rnf = genericRnf
-- | Represents the "deployment" field in the
-- 'DeploymentEvent' and 'DeploymentStatusEvent' payload.
data HookDeployment = HookDeployment
{ whDeploymentUrl :: !URL
, whDeploymentId :: !Int
, whDeploymentNodeId :: !Text
, whDeploymentSha :: !Text
, whDeploymentRef :: !Text
, whDeploymentTask :: !Text
-- , whDeploymentPayload
, whDeploymentEnv :: !Text
, whDeploymentDescription :: !(Maybe Text)
, whDeploymentCreator :: !HookUser
, whDeploymentCreatedAt :: !UTCTime
, whDeploymentUpdatedAt :: !UTCTime
, whDeploymentStatusesUrl :: !URL
, whDeploymentRepoUrl :: !URL
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookDeployment where rnf = genericRnf
-- | Represents the "deployment_status" field in the
-- 'DeploymentStatusEvent' payload.
data HookDeploymentStatus = HookDeploymentStatus
{ whDeploymentStatusUrl :: !URL
, whDeploymentStatusId :: !Int
, whDeploymentStatusNodeId :: !Text
, whDeploymentStatusState :: !Text
, whDeploymentStatusCreator :: !HookUser
, whDeploymentStatusDesc :: !(Maybe Text)
, whDeploymentStatusTargetUrl :: !(Maybe URL)
, whDeploymentStatusCreatedAt :: !UTCTime
, whDeploymentStatusUpdatedAt :: !UTCTime
, whDeploymentStatusDeplUrl :: !URL
, whDeploymentStatusRepoUrl :: !URL
}
deriving (Eq, Show, Typeable, Data, Generic)
instance NFData HookDeploymentStatus where rnf = genericRnf