-
-
Notifications
You must be signed in to change notification settings - Fork 271
/
models.rs
960 lines (913 loc) · 31.9 KB
/
models.rs
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
//! Serde mappings from GitHub's JSON to structs.
use std::collections::HashMap;
use std::fmt;
use std::ops::{Deref, DerefMut};
use chrono::{DateTime, Utc};
use serde::{de, Deserialize, Deserializer, Serialize};
use url::Url;
pub mod actions;
pub mod activity;
pub mod apps;
pub mod checks;
pub mod commits;
pub mod events;
pub mod gists;
pub mod hooks;
pub mod issues;
pub mod orgs;
pub mod pulls;
pub mod reactions;
pub mod repos;
pub mod teams;
pub mod timelines;
pub mod webhook_events;
pub mod workflows;
mod date_serde;
pub use apps::App;
type BaseIdType = u64;
macro_rules! id_type {
// This macro takes an argument of designator `ident` and
// creates a function named `$func_name`.
// The `ident` designator is used for variable/function names.
($($name:ident),+) => {$(
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize)]
pub struct $name(pub BaseIdType);
impl fmt::Display for $name {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl Deref for $name {
type Target = BaseIdType;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for $name {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl $name {
pub fn into_inner(self) -> BaseIdType {
self.0
}
}
impl From<BaseIdType> for $name {
fn from(value: BaseIdType) -> Self {
Self(value)
}
}
impl AsRef<BaseIdType> for $name {
fn as_ref(&self) -> &BaseIdType {
&self.0
}
}
impl<'de> Deserialize<'de> for $name {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>
{
struct IdVisitor;
impl<'de> de::Visitor<'de> for IdVisitor {
type Value = $name;
fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
where E: de::Error {
Ok($name(value))
}
fn visit_str<E>(self, id: &str) -> Result<Self::Value, E>
where E: de::Error {
id.parse::<u64>().map($name).map_err(de::Error::custom)
}
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "expected {} as number or string", stringify!($name)) // TODO: $name
}
}
deserializer.deserialize_any(IdVisitor)
}
}
)+};
}
id_type!(
ActorId, // A Bot, EnterpriseUserAccount, Mannequin, Organization or User
AppId,
ArtifactId,
AssetId,
BranchProtectionRuleId,
CardId,
CheckSuiteId,
CheckRunId,
CommentId,
InstallationId,
IssueEventId,
IssueId,
JobId,
HookId,
LabelId,
MilestoneId,
NotificationId,
OrgId,
ProjectId,
ProjectColumnId,
PullRequestId,
PushId,
ReactionId,
ReleaseId,
RepositoryId,
ReviewId,
RunId,
RunnerId,
RunnerGroupId,
RunnerLabelId,
StatusId,
TeamId,
TimelineEventId,
ThreadId,
UploaderId,
UserId,
UserOrOrgId,
WorkflowId,
TeamInvitationId
);
macro_rules! convert_into {
($($from:ident -> $to:ident),+) => {$(
impl From<$from> for $to {
fn from(v: $from) -> $to {
$to(v.0)
}
}
)+};
}
convert_into!(OrgId -> ActorId,
UserId -> ActorId,
OrgId -> UserOrOrgId,
UserId -> UserOrOrgId,
PullRequestId -> IssueId);
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Contents {
#[serde(rename = "type")]
pub contents_type: String,
pub encoding: String,
pub size: u64,
pub name: String,
pub path: String,
pub content: String,
pub sha: String,
pub url: Url,
pub git_url: Url,
pub html_url: Url,
pub download_url: Url,
}
/// Issue events are triggered by activity in issues and pull requests.
/// https://docs.github.com/en/webhooks-and-events/events/issue-event-types
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum Event {
/// The issue or pull request was added to a project board.
AddedToProject,
/// The issue or pull request was assigned to a user.
Assigned,
/// Auto merge was disabled for a pull request.
AutoMergeDisabled,
/// Auto merge was enabled for a pull request.
AutoMergeEnabled,
/// GitHub unsuccessfully attempted to automatically change the base branch of the pull request.
AutomaticBaseChangeFailed,
/// GitHub successfully attempted to automatically change the base branch of the pull request.
AutomaticBaseChangeSucceeded,
/// The base reference branch of the pull request changed.
BaseRefChanged,
/// Not documented in the Github issue events documentation.
BaseRefForcePushed,
/// The issue or pull request was closed. When the commit_id is present, it identifies the commit that closed the issue using "closes / fixes" syntax.
Closed,
/// A comment was added to the issue or pull request.
Commented,
/// A comment that was removed from the issue or pull request.
/// This isn't documented as part of the issues-event-types API but returned by the API.
CommentDeleted,
/// A commit was added to the pull request's HEAD branch.
Committed,
/// The issue or pull request was linked to another issue or pull request.
Connected,
/// The pull request was converted to draft mode.
ConvertToDraft,
/// The issue was created by converting a note in a project board to an issue.
ConvertedNoteToIssue,
/// The issue was closed and converted to a discussion.
ConvertedToDiscussion,
/// The issue or pull request was referenced from another issue or pull request.
#[serde(rename = "cross-referenced")]
CrossReferenced,
/// The issue or pull request was removed from a milestone.
Demilestoned,
/// The pull request was deployed.
Deployed,
/// The pull request deployment environment was changed.
DeploymentEnvironmentChanged,
/// The issue or pull request was unlinked from another issue or pull request.
Disconnected,
/// The pull request's HEAD branch was deleted.
HeadRefDeleted,
/// The pull request's HEAD branch was force pushed.
HeadRefForcePushed,
/// The pull request's HEAD branch was restored to the last known commit.
HeadRefRestored,
/// A label was added to the issue or pull request.
Labeled,
/// A comment on a line of source in a pull request. Not documented in the issue and events documentation.
#[serde(rename = "line-commented")]
LineCommented,
/// The issue or pull request was locked.
Locked,
/// The actor was @mentioned in an issue or pull request body.
Mentioned,
/// A user with write permissions marked an issue as a duplicate of another issue, or a pull request as a duplicate of another pull request.
MarkedAsDuplicate,
/// The pull request was merged. The commit_id attribute is the SHA1 of the HEAD commit that was merged. The commit_repository is always the same as the main repository.
Merged,
/// The issue or pull request was added to a milestone.
Milestoned,
/// The issue or pull request was moved between columns in a project board.
MovedColumnsInProject,
/// The issue was pinned.
Pinned,
/// A draft pull request was marked as ready for review.
ReadyForReview,
/// The issue was referenced from a commit message. The commit_id attribute is the commit SHA1 of where that happened and the commit_repository is where that commit was pushed.
Referenced,
/// The issue or pull request was removed from a project board.
RemovedFromProject,
/// The issue or pull request title was changed.
Renamed,
/// The issue or pull request was reopened.
Reopened,
/// The pull request review was dismissed.
ReviewDismissed,
/// A pull request review was requested.
ReviewRequested,
/// A pull request review request was removed.
ReviewRequestRemoved,
/// The pull request was reviewed.
Reviewed,
/// Someone subscribed to receive notifications for an issue or pull request.
Subscribed,
/// The issue was transferred to another repository.
Transferred,
/// A user was unassigned from the issue.
Unassigned,
/// A label was removed from the issue.
Unlabeled,
/// The issue was unlocked.
Unlocked,
/// An issue that a user had previously marked as a duplicate of another issue is no longer considered a duplicate, or a pull request that a user had previously marked as a duplicate of another pull request is no longer considered a duplicate.
UnmarkedAsDuplicate,
/// The issue was unpinned.
Unpinned,
/// Someone unsubscribed from receiving notifications for an issue or pull request.
Unsubscribed,
/// An organization owner blocked a user from the organization.
UserBlocked,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum IssueState {
Open,
Closed,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct IssueEvent {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<IssueEventId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub node_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
pub actor: Author,
#[serde(skip_serializing_if = "Option::is_none")]
pub assignee: Option<Author>,
#[serde(skip_serializing_if = "Option::is_none")]
pub assignees: Option<Vec<Author>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub assigner: Option<Author>,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels: Option<Vec<Label>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub milestone: Option<Milestone>,
#[serde(skip_serializing_if = "Option::is_none")]
pub project_card: Option<ProjectCard>,
#[serde(skip_serializing_if = "Option::is_none")]
pub event: Option<Event>,
#[serde(skip_serializing_if = "Option::is_none")]
pub commit_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub commit_url: Option<String>,
pub created_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ProjectCard {
pub id: CardId,
pub url: Url,
pub project_id: ProjectId,
pub project_url: Url,
#[serde(skip_serializing_if = "Option::is_none")]
pub column_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub previous_column_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub column_url: Option<Url>,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Project {
pub owner_url: Url,
pub url: Url,
pub html_url: Url,
pub columns_url: Url,
pub id: ProjectId,
pub node_id: String,
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub body: Option<String>,
pub number: u32,
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
pub creator: Author,
pub created_at: DateTime<Utc>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ProjectCardContentType {
Issue,
PullRequest,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ProjectColumn {
pub url: Url,
pub project_url: Url,
pub cards_url: Url,
pub id: ProjectColumnId,
pub node_id: String,
pub name: String,
pub created_at: DateTime<Utc>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct IssuePullRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub html_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub diff_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub patch_url: Option<String>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Author {
pub login: String,
pub id: UserId,
pub node_id: String,
pub avatar_url: Url,
pub gravatar_id: String,
pub url: Url,
pub html_url: Url,
pub followers_url: Url,
pub following_url: Url,
pub gists_url: Url,
pub starred_url: Url,
pub subscriptions_url: Url,
pub organizations_url: Url,
pub repos_url: Url,
pub events_url: Url,
pub received_events_url: Url,
pub r#type: String,
pub site_admin: bool,
pub patch_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[non_exhaustive]
pub enum AuthorAssociation {
Collaborator,
Contributor,
FirstTimer,
FirstTimeContributor,
Mannequin,
Member,
None,
Owner,
#[serde(untagged)]
Other(String),
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Collaborator {
#[serde(flatten)]
pub author: Author,
pub permissions: Permissions,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Contributor {
#[serde(flatten)]
pub author: Author,
pub contributions: u32,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct StarGazer {
pub starred_at: Option<DateTime<Utc>>,
pub user: Option<Author>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Label {
pub id: LabelId,
pub node_id: String,
pub url: Url,
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
pub color: String,
pub default: bool,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Milestone {
pub url: Url,
pub html_url: Url,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels_url: Option<Url>,
pub id: MilestoneId,
pub node_id: String,
pub number: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
pub title: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub creator: Option<Author>,
#[serde(skip_serializing_if = "Option::is_none")]
pub open_issues: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub closed_issues: Option<i64>,
pub created_at: DateTime<Utc>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub closed_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub due_on: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Repository {
pub id: RepositoryId,
#[serde(skip_serializing_if = "Option::is_none")]
pub node_id: Option<String>,
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub full_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub owner: Option<Author>,
#[serde(skip_serializing_if = "Option::is_none")]
pub private: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub html_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub fork: Option<bool>,
pub url: Url,
#[serde(skip_serializing_if = "Option::is_none")]
pub archive_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub assignees_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub blobs_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub branches_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub collaborators_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub comments_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub commits_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub compare_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub contents_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub contributors_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub deployments_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub downloads_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub events_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub forks_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub git_commits_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub git_refs_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub git_tags_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub git_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub issue_comment_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub issue_events_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub issues_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub keys_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub labels_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub languages_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub merges_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub milestones_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub notifications_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub pulls_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub releases_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ssh_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub stargazers_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub statuses_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub subscribers_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub subscription_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tags_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub teams_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub trees_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub clone_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub mirror_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub hooks_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub svn_url: Option<Url>,
#[serde(skip_serializing_if = "Option::is_none")]
pub homepage: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<::serde_json::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub forks_count: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub stargazers_count: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub watchers_count: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub default_branch: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub open_issues_count: Option<u32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_template: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub topics: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub has_issues: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub has_projects: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub has_wiki: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub has_pages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub has_downloads: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub archived: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub disabled: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub visibility: Option<String>,
#[serde(
skip_serializing_if = "Option::is_none",
default,
deserialize_with = "date_serde::deserialize_opt"
)]
pub pushed_at: Option<DateTime<Utc>>,
#[serde(
skip_serializing_if = "Option::is_none",
default,
deserialize_with = "date_serde::deserialize_opt"
)]
pub created_at: Option<DateTime<Utc>>,
#[serde(
skip_serializing_if = "Option::is_none",
default,
deserialize_with = "date_serde::deserialize_opt"
)]
pub updated_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub permissions: Option<Permissions>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_rebase_merge: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub template_repository: Option<Box<Repository>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_squash_merge: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_merge_commit: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_update_branch: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_forking: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub subscribers_count: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub network_count: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub license: Option<License>,
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_auto_merge: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub delete_branch_on_merge: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parent: Option<Box<Repository>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<Box<Repository>>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
pub struct RepositoryFile {
pub name: Option<String>,
pub key: Option<String>,
pub url: Option<Url>,
pub html_url: Option<Url>,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct RepositoryMetrics {
pub health_percentage: u64,
pub description: Option<String>,
pub documentation: Option<String>,
pub files: HashMap<String, Option<RepositoryFile>>,
pub updated_at: Option<DateTime<Utc>>,
pub content_reports_enabled: Option<bool>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct License {
pub key: String,
pub name: String,
pub node_id: String,
pub spdx_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<Url>,
pub html_url: Option<Url>,
pub description: Option<String>,
pub implementation: Option<String>,
pub permissions: Option<Vec<String>>,
pub conditions: Option<Vec<String>>,
pub limitations: Option<Vec<String>>,
pub body: Option<String>,
pub featured: Option<bool>,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Code {
pub name: String,
pub path: String,
pub sha: String,
pub url: Url,
pub git_url: Url,
pub html_url: Url,
pub repository: Repository,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Permissions {
#[serde(default)]
pub admin: bool,
pub push: bool,
pub pull: bool,
#[serde(default)]
pub triage: bool,
#[serde(default)]
pub maintain: bool,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CheckRuns {
pub total_count: i32,
pub check_runs: Vec<CheckRun>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CheckRun {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<CheckRunId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub head_sha: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub node_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub external_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub html_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub details_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<CheckStatus>,
#[serde(skip_serializing_if = "Option::is_none")]
pub conclusion: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub started_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub completed_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum CheckStatus {
Queued,
Completed,
InProgress,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct CombinedStatus {
pub state: StatusState,
pub sha: String,
pub total_count: i64,
pub statuses: Vec<Status>,
#[serde(skip_serializing)]
pub repository: Option<Repository>,
#[serde(skip_serializing)]
pub commit_url: Option<Url>,
#[serde(skip_serializing)]
pub url: Option<Url>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Status {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<StatusId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub node_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<DateTime<Utc>>,
pub state: StatusState,
#[serde(skip_serializing_if = "Option::is_none")]
pub creator: Option<Author>,
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option<String>,
}
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum StatusState {
Failure,
Pending,
Success,
Error,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct InstallationRepositories {
pub total_count: i64,
pub repositories: Vec<Repository>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub struct Installation {
pub id: InstallationId,
pub account: Author,
#[serde(skip_serializing_if = "Option::is_none")]
pub access_tokens_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub repositories_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub html_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub app_id: Option<AppId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_id: Option<UserOrOrgId>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_type: Option<String>,
pub permissions: InstallationPermissions,
/// List of events in the installation.
///
/// Note that for Webhook events, the list of events in the
/// list is guaranteed to match variants from
/// [WebhookEventType](webhook_events::WebhookEventType)
pub events: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub single_file_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub repository_selection: Option<String>,
#[serde(
skip_serializing_if = "Option::is_none",
default,
deserialize_with = "date_serde::deserialize_opt"
)]
pub created_at: Option<DateTime<Utc>>,
#[serde(
skip_serializing_if = "Option::is_none",
default,
deserialize_with = "date_serde::deserialize_opt"
)]
pub updated_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub struct InstallationPermissions {
#[serde(skip_serializing_if = "Option::is_none")]
pub actions: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub checks: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub contents: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub issues: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub single_file: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub statuses: Option<String>,
}
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub struct InstallationToken {
pub token: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub expires_at: Option<String>,
pub permissions: InstallationPermissions,
#[serde(skip_serializing_if = "Option::is_none")]
pub repositories: Option<Vec<Repository>>,
}
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub struct PublicKey {
pub key_id: String,
pub key: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RateLimit {
pub resources: Resources,
pub rate: Rate,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Resources {
pub core: Rate,
pub search: Rate,
pub graphql: Option<Rate>,
pub integration_manifest: Option<Rate>,
pub scim: Option<Rate>,
pub source_import: Option<Rate>,
pub code_scanning_upload: Option<Rate>,
pub actions_runner_registration: Option<Rate>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Rate {
pub limit: usize,
pub used: usize,
pub remaining: usize,
pub reset: usize,
}