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
use crate::model::{prelude::*, repositories::nested::*, user::SimpleUser};

/// <https://docs.github.com/en/rest/repos/repos#get-a-repository=>
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Repository {
    pub network_count: i64,
    pub subscribers_count: i64,
    #[serde(flatten)]
    pub common: Repo,
}

as_ref_and_deref!(Repository, Repo, common);

/// <https://docs.github.com/en/rest/projects/projects#get-a-project=>
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Project {
    pub id: usize,
    pub node_id: String,
    pub number: usize,
    pub name: String,
    pub body: Option<String>,
    pub state: ProjectState,
    pub url: String,
    pub html_url: String,
    pub owner_url: String,
    pub creator: Option<SimpleUser>,
    pub columns_url: String,
    pub created_at: String,
    pub updated_at: String,
}

/// <https://docs.github.com/en/rest/projects/cards#get-a-project-card=>
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ProjectCard {
    pub id: usize,
    pub node_id: String,
    pub note: Option<String>,
    pub url: String,
    pub column_url: String,
    pub project_url: String,
    pub creator: Option<SimpleUser>,
    pub created_at: String,
    pub updated_at: String,
}

/// <https://docs.github.com/en/rest/projects/columns#get-a-project-column=>
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ProjectColumn {
    pub id: usize,
    pub node_id: String,
    pub url: String,
    pub project_url: String,
    pub cards_url: String,
    pub name: String,
    pub created_at: String,
    pub updated_at: String,
}

/// <https://docs.github.com/en/rest/deploy-keys#get-a-deploy-key=>
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DeployKey {
    pub id: usize,
    pub key: String,
    pub url: String,
    pub title: String,
    pub verified: bool,
    pub created_at: String,
    pub read_only: bool,
}

/// <https://docs.github.com/en/rest/code-scanning#get-a-code-scanning-alert=>
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CodeScanningAlert {
    pub number: usize,
    pub created_at: String,
    pub updated_at: String,
    pub url: String,
    pub html_url: String,
    pub instances_url: String,
    pub state: CodeScanningAlertState,
    pub fixed_at: Option<String>,
    pub dismissed_by: Option<SimpleUser>,
    pub dismissed_at: Option<String>,
    pub rule: CodeScanningAlertRule,
    pub tool: Tool,
    pub most_recent_instance: MostRecentInstance,
}

pub mod nested {
    use crate::model::{prelude::*, user::SimpleUser};

    #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
    pub struct Repo {
        pub archive_url: String,
        pub assignees_url: String,
        pub blobs_url: String,
        pub branches_url: String,
        pub collaborators_url: String,
        pub comments_url: String,
        pub commits_url: String,
        pub compare_url: String,
        pub contents_url: String,
        pub contributors_url: String,
        pub deployments_url: String,
        pub description: Option<String>,
        pub downloads_url: String,
        pub events_url: String,
        pub fork: bool,
        pub forks_url: String,
        pub full_name: String,
        pub git_commits_url: String,
        pub git_refs_url: String,
        pub git_tags_url: String,
        pub hooks_url: String,
        pub html_url: String,
        pub id: i64,
        pub node_id: String,
        pub issue_comment_url: String,
        pub issue_events_url: String,
        pub issues_url: String,
        pub keys_url: String,
        pub labels_url: String,
        pub languages_url: String,
        pub merges_url: String,
        pub milestones_url: String,
        pub name: String,
        pub notifications_url: String,
        pub owner: SimpleUser,
        pub private: bool,
        pub pulls_url: String,
        pub releases_url: String,
        pub stargazers_url: String,
        pub tags_url: String,
        pub teams_url: String,
        pub trees_url: String,
        pub url: String,
        pub clone_url: String,
        pub default_branch: String,
        pub forks: i64,
        pub forks_count: i64,
        pub git_url: String,
        pub has_downloads: bool,
        pub has_issues: bool,
        pub has_projects: bool,
        pub has_wiki: bool,
        pub has_pages: bool,
        pub homepage: Option<String>,
        pub language: Option<String>,
        pub archived: bool,
        pub disabled: bool,
        pub mirror_url: Option<String>,
        pub open_issues: i64,
        pub open_issues_count: i64,
        pub license: Option<SimpleLicense>,
        pub pushed_at: String,
        pub size: i64,
        pub ssh_url: String,
        pub stargazers_count: i64,
        pub svn_url: String,
        pub watchers: i64,
        pub watchers_count: i64,
        pub created_at: String,
        pub updated_at: String,
    }

    #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
    pub struct SimpleLicense {
        pub key: String,
        pub name: String,
        pub url: Option<String>,
        pub spdx_id: Option<String>,
        pub node_id: String,
    }

    #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
    pub struct Tool {
        pub name: String,
        pub version: Option<String>,
        pub guid: Option<String>,
    }

    #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
    pub struct MostRecentInstance {
        #[serde(rename = "ref")]
        pub ref_field: String,
        pub analysis_key: String,
        pub environment: String,
        pub category: String,
        pub state: CodeScanningAlertState,
        pub commit_sha: String,
        pub message: Message,
        pub html_url: String,
    }

    #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
    pub struct Message {
        pub text: String,
    }

    #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
    pub struct CodeScanningAlertRule {
        pub id: String,
        pub severity: String,
        pub description: String,
        pub full_description: String,
        pub tags: Vec<String>,
        pub help: String,
    }

    #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
    #[serde(rename_all = "lowercase")]
    pub enum ProjectState {
        Open,
        Closed,
    }

    #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
    #[serde(rename_all = "lowercase")]
    pub enum CodeScanningAlertState {
        Open,
        Closed,
        Dismissed,
        Fixed,
    }
}