1 |
use serde::{Deserialize, Serialize};
|
2 |
|
3 |
use crate::model::{
|
4 |
repository::{CommitMetadata, Repository, RepositoryFile, RepositoryView},
|
5 |
user::User,
|
6 |
};
|
7 |
|
8 |
#[derive(Clone, Serialize, Deserialize)]
|
9 |
pub struct RepositoryMessage {
|
10 |
pub target: Repository,
|
11 |
pub command: RepositoryMessageKind,
|
12 |
}
|
13 |
|
14 |
#[derive(Clone, Serialize, Deserialize)]
|
15 |
pub enum RepositoryMessageKind {
|
16 |
Request(RepositoryRequest),
|
17 |
Response(RepositoryResponse),
|
18 |
}
|
19 |
|
20 |
#[derive(Clone, Serialize, Deserialize)]
|
21 |
pub enum RepositoryRequest {
|
22 |
CreateRepository(CreateRepositoryRequest),
|
23 |
RepositoryFileInspect(RepositoryFileInspectRequest),
|
24 |
RepositoryInfo(RepositoryInfoRequest),
|
25 |
IssuesCount(RepositoryIssuesCountRequest),
|
26 |
IssueLabels(RepositoryIssueLabelsRequest),
|
27 |
Issues(RepositoryIssuesRequest),
|
28 |
}
|
29 |
|
30 |
#[derive(Clone, Serialize, Deserialize)]
|
31 |
pub enum RepositoryResponse {
|
32 |
CreateRepository(CreateRepositoryResponse),
|
33 |
RepositoryFileInspection(RepositoryFileInspectionResponse),
|
34 |
RepositoryInfo(RepositoryView),
|
35 |
IssuesCount(RepositoryIssuesCountResponse),
|
36 |
IssueLabels(RepositoryIssueLabelsResponse),
|
37 |
Issues(RepositoryIssuesResponse),
|
38 |
}
|
39 |
|
40 |
#[derive(Clone, Serialize, Deserialize)]
|
41 |
pub struct CreateRepositoryRequest {
|
42 |
pub name: String,
|
43 |
pub description: String,
|
44 |
pub default_branch: String,
|
45 |
pub owner: User,
|
46 |
}
|
47 |
|
48 |
#[derive(Clone, Serialize, Deserialize)]
|
49 |
pub enum CreateRepositoryResponse {
|
50 |
Created,
|
51 |
Failed,
|
52 |
}
|
53 |
|
54 |
#[derive(Clone, Serialize, Deserialize)]
|
55 |
pub struct RepositoryFileInspectRequest {
|
56 |
pub path: RepositoryFile,
|
57 |
}
|
58 |
|
59 |
#[derive(Clone, Serialize, Deserialize)]
|
60 |
pub enum RepositoryFileInspectionResponse {
|
61 |
File {
|
62 |
commit_metadata: CommitMetadata,
|
63 |
},
|
64 |
Folder {
|
65 |
commit_metadata: CommitMetadata,
|
66 |
members: Vec<RepositoryFile>,
|
67 |
},
|
68 |
Invalid {
|
69 |
path: RepositoryFile,
|
70 |
},
|
71 |
}
|
72 |
|
73 |
#[derive(Clone, Serialize, Deserialize)]
|
74 |
pub struct RepositoryIssuesCountRequest;
|
75 |
|
76 |
#[derive(Clone, Serialize, Deserialize)]
|
77 |
pub struct RepositoryIssuesCountResponse {
|
78 |
pub count: u64,
|
79 |
}
|
80 |
|
81 |
#[derive(Clone, Serialize, Deserialize)]
|
82 |
pub struct RepositoryIssueLabelsRequest;
|
83 |
|
84 |
#[derive(Clone, Serialize, Deserialize)]
|
85 |
pub struct RepositoryIssueLabelsResponse {
|
86 |
pub labels: Vec<IssueLabel>,
|
87 |
}
|
88 |
|
89 |
#[derive(Clone, Serialize, Deserialize)]
|
90 |
pub struct IssueLabel {
|
91 |
pub name: String,
|
92 |
pub color: String,
|
93 |
}
|
94 |
|
95 |
#[derive(Clone, Serialize, Deserialize)]
|
96 |
pub struct RepositoryIssuesRequest;
|
97 |
|
98 |
#[derive(Clone, Serialize, Deserialize)]
|
99 |
pub struct RepositoryIssuesResponse {
|
100 |
pub issues: Vec<RepositoryIssue>,
|
101 |
}
|
102 |
|
103 |
#[derive(Clone, Serialize, Deserialize)]
|
104 |
pub struct RepositoryIssue {
|
105 |
pub author: User,
|
106 |
pub id: u64,
|
107 |
pub title: String,
|
108 |
pub contents: String,
|
109 |
pub labels: Vec<IssueLabel>,
|
110 |
}
|
111 |
|
112 |
#[derive(Clone, Serialize, Deserialize)]
|
113 |
pub struct RepositoryInfoRequest;
|
114 |
|