github_types/
repo.rs

1// Copyright (c) 2019 Jason White
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19// SOFTWARE.
20
21use serde::Deserialize;
22
23use crate::{DateTime, Oid, User};
24
25/// Short info about a repository.
26#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
27pub struct ShortRepo {
28    pub id: u64,
29    pub name: String,
30    pub full_name: String,
31    pub private: bool,
32}
33
34/// A repository.
35#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
36pub struct Repository {
37    pub id: u64,
38    pub owner: User,
39    pub name: String,
40    pub full_name: String,
41    pub description: Option<String>,
42    pub private: bool,
43    pub fork: bool,
44    pub url: String,
45    pub html_url: String,
46    pub archive_url: String,
47    pub assignees_url: String,
48    pub blobs_url: String,
49    pub branches_url: String,
50    pub clone_url: String,
51    pub collaborators_url: String,
52    pub comments_url: String,
53    pub commits_url: String,
54    pub compare_url: String,
55    pub contents_url: String,
56    pub contributors_url: String,
57    pub deployments_url: String,
58    pub downloads_url: String,
59    pub events_url: String,
60    pub forks_url: String,
61    pub git_commits_url: String,
62    pub git_refs_url: String,
63    pub git_tags_url: String,
64    pub git_url: String,
65    pub hooks_url: String,
66    pub issue_comment_url: String,
67    pub issue_events_url: String,
68    pub issues_url: String,
69    pub keys_url: String,
70    pub labels_url: String,
71    pub languages_url: String,
72    pub merges_url: String,
73    pub milestones_url: String,
74    pub mirror_url: Option<String>,
75    pub notifications_url: String,
76    pub pulls_url: String,
77    pub releases_url: String,
78    pub ssh_url: String,
79    pub stargazers_url: String,
80    pub statuses_url: String,
81    pub subscribers_url: String,
82    pub subscription_url: String,
83    pub svn_url: String,
84    pub tags_url: String,
85    pub teams_url: String,
86    pub trees_url: String,
87    pub homepage: Option<String>,
88    pub language: Option<String>,
89    pub forks_count: u64,
90    pub stargazers_count: u64,
91    pub watchers_count: u64,
92    pub size: u64,
93    pub default_branch: String,
94    pub open_issues_count: u64,
95    pub has_issues: bool,
96    pub has_wiki: bool,
97    pub has_pages: bool,
98    pub has_downloads: bool,
99    pub archived: bool,
100    pub pushed_at: DateTime,
101    pub created_at: DateTime,
102    pub updated_at: DateTime,
103}
104
105#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
106pub struct Comment {
107    pub id: u64,
108    pub url: String,
109    pub html_url: String,
110    pub body: String,
111    pub user: User,
112    pub created_at: DateTime,
113    pub updated_at: DateTime,
114}
115
116#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
117pub struct PullRequest {
118    pub id: u64,
119    pub url: String,
120    pub html_url: String,
121    pub diff_url: String,
122    pub patch_url: String,
123    pub issue_url: String,
124    pub commits_url: String,
125    pub review_comments_url: String,
126    pub review_comment_url: String,
127    pub comments_url: String,
128    pub statuses_url: String,
129    pub number: u64,
130    pub state: String,
131    pub title: String,
132    pub body: Option<String>,
133    pub created_at: DateTime,
134    pub updated_at: DateTime,
135    pub closed_at: Option<DateTime>,
136    pub merged_at: Option<DateTime>,
137    pub head: ShortCommit,
138    pub base: ShortCommit,
139    pub user: User,
140    pub assignee: Option<User>,
141    pub assignees: Vec<User>,
142    pub merge_commit_sha: Option<String>,
143    pub merged: bool,
144    pub mergeable: Option<bool>,
145    pub merged_by: Option<User>,
146    pub comments: Option<u64>,
147    pub commits: Option<u64>,
148    pub additions: Option<u64>,
149    pub deletions: Option<u64>,
150    pub changed_files: Option<u64>,
151    pub labels: Vec<Label>,
152}
153
154#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
155pub struct ShortCommit {
156    pub label: String,
157    #[serde(rename = "ref")]
158    pub commit_ref: String,
159    pub sha: Oid,
160    pub user: User,
161}
162
163#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
164pub struct Label {
165    pub url: String,
166    pub name: String,
167    pub color: String,
168}
169
170#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
171pub struct Issue {
172    pub id: u64,
173    pub url: String,
174    pub labels_url: String,
175    pub comments_url: String,
176    pub events_url: String,
177    pub html_url: String,
178    pub number: u64,
179    pub state: String,
180    pub title: String,
181    pub body: Option<String>,
182    pub user: User,
183    pub labels: Vec<Label>,
184    pub assignee: Option<User>,
185    pub locked: bool,
186    pub comments: u64,
187    pub pull_request: Option<PullRef>,
188    pub closed_at: Option<DateTime>,
189    pub created_at: DateTime,
190    pub updated_at: DateTime,
191    pub assignees: Vec<User>,
192}
193
194/// A reference to a pull request.
195#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
196pub struct PullRef {
197    pub url: String,
198    pub html_url: String,
199    pub diff_url: String,
200    pub patch_url: String,
201}
202
203#[derive(
204    Deserialize, Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash,
205)]
206#[serde(rename_all = "snake_case")]
207pub enum ReviewState {
208    Commented,
209}
210
211#[derive(Deserialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
212pub struct Review {
213    pub id: u64,
214    pub user: User,
215    pub body: Option<String>,
216    pub commit_id: Oid,
217    pub submitted_at: DateTime,
218    pub state: ReviewState,
219    pub html_url: String,
220    pub pull_request_url: String,
221    pub author_association: String,
222}