1 |
use serde::{Deserialize, Serialize};
|
2 |
|
3 |
use crate::model::repository::RepositoryVisibility;
|
4 |
use crate::model::{
|
5 |
repository::{Commit, Repository, RepositoryTreeEntry, RepositoryView},
|
6 |
user::User,
|
7 |
};
|
8 |
|
9 |
use super::UnvalidatedUserAuthenticated;
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
#[derive(Clone, Serialize, Deserialize)]
|
16 |
pub struct RepositoryMessage {
|
17 |
pub target: Repository,
|
18 |
pub command: RepositoryMessageKind,
|
19 |
}
|
20 |
|
21 |
#[derive(Clone, Serialize, Deserialize)]
|
22 |
pub enum RepositoryMessageKind {
|
23 |
Request(RepositoryRequest),
|
24 |
Response(RepositoryResponse),
|
25 |
}
|
26 |
|
27 |
#[derive(Clone, Serialize, Deserialize)]
|
28 |
pub enum RepositoryRequest {
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
CreateRepository(UnvalidatedUserAuthenticated<CreateRepositoryRequest>),
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
RepositoryFileInspect(UnvalidatedUserAuthenticated<RepositoryFileInspectRequest>),
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
RepositoryInfo(UnvalidatedUserAuthenticated<RepositoryInfoRequest>),
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
IssuesCount(UnvalidatedUserAuthenticated<RepositoryIssuesCountRequest>),
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
IssueLabels(UnvalidatedUserAuthenticated<RepositoryIssueLabelsRequest>),
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
Issues(UnvalidatedUserAuthenticated<RepositoryIssuesRequest>),
|
98 |
}
|
99 |
|
100 |
#[derive(Clone, Serialize, Deserialize)]
|
101 |
pub enum RepositoryResponse {
|
102 |
CreateRepository(CreateRepositoryResponse),
|
103 |
RepositoryFileInspection(RepositoryFileInspectionResponse),
|
104 |
RepositoryInfo(RepositoryView),
|
105 |
IssuesCount(RepositoryIssuesCountResponse),
|
106 |
IssueLabels(RepositoryIssueLabelsResponse),
|
107 |
Issues(RepositoryIssuesResponse),
|
108 |
}
|
109 |
|
110 |
|
111 |
#[derive(Clone, Serialize, Deserialize)]
|
112 |
pub struct CreateRepositoryRequest {
|
113 |
pub name: String,
|
114 |
pub description: Option<String>,
|
115 |
pub visibility: RepositoryVisibility,
|
116 |
pub default_branch: String,
|
117 |
pub owner: User,
|
118 |
}
|
119 |
|
120 |
#[derive(Clone, Serialize, Deserialize)]
|
121 |
pub enum CreateRepositoryResponse {
|
122 |
Created,
|
123 |
Failed,
|
124 |
}
|
125 |
|
126 |
|
127 |
#[derive(Clone, Serialize, Deserialize)]
|
128 |
pub struct RepositoryFileInspectRequest {
|
129 |
pub path: RepositoryTreeEntry,
|
130 |
}
|
131 |
|
132 |
#[derive(Clone, Serialize, Deserialize)]
|
133 |
pub enum RepositoryFileInspectionResponse {
|
134 |
File {
|
135 |
commit_metadata: Commit,
|
136 |
},
|
137 |
Folder {
|
138 |
commit_metadata: Commit,
|
139 |
members: Vec<RepositoryTreeEntry>,
|
140 |
},
|
141 |
Invalid {
|
142 |
path: RepositoryTreeEntry,
|
143 |
},
|
144 |
}
|
145 |
|
146 |
|
147 |
#[derive(Clone, Serialize, Deserialize)]
|
148 |
pub struct RepositoryIssuesCountRequest;
|
149 |
|
150 |
#[derive(Clone, Serialize, Deserialize)]
|
151 |
pub struct RepositoryIssuesCountResponse {
|
152 |
pub count: u64,
|
153 |
}
|
154 |
|
155 |
|
156 |
#[derive(Clone, Serialize, Deserialize)]
|
157 |
pub struct RepositoryIssueLabelsRequest;
|
158 |
|
159 |
#[derive(Clone, Serialize, Deserialize)]
|
160 |
pub struct RepositoryIssueLabelsResponse {
|
161 |
pub labels: Vec<IssueLabel>,
|
162 |
}
|
163 |
|
164 |
#[derive(Clone, Serialize, Deserialize)]
|
165 |
pub struct IssueLabel {
|
166 |
pub name: String,
|
167 |
pub color: String,
|
168 |
}
|
169 |
|
170 |
|
171 |
#[derive(Clone, Serialize, Deserialize)]
|
172 |
pub struct RepositoryIssuesRequest;
|
173 |
|
174 |
#[derive(Clone, Serialize, Deserialize)]
|
175 |
pub struct RepositoryIssuesResponse {
|
176 |
pub issues: Vec<RepositoryIssue>,
|
177 |
}
|
178 |
|
179 |
#[derive(Clone, Serialize, Deserialize)]
|
180 |
pub struct RepositoryIssue {
|
181 |
pub author: User,
|
182 |
pub id: u64,
|
183 |
pub title: String,
|
184 |
pub contents: String,
|
185 |
pub labels: Vec<IssueLabel>,
|
186 |
}
|
187 |
|
188 |
#[derive(Clone, Serialize, Deserialize)]
|
189 |
pub struct RepositoryInfoRequest {
|
190 |
pub repository: Repository,
|
191 |
|
192 |
pub extra_metadata: bool,
|
193 |
|
194 |
pub rev: Option<String>,
|
195 |
|
196 |
pub path: Option<String>,
|
197 |
}
|
198 |
|