JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Major post-refactor cleanup

Amber - ⁨2⁩ years ago

parent: tbd commit: ⁨f90d7fb

⁨src/messages/repository.rs⁩ - ⁨4298⁩ bytes
Raw
1 use serde::{Deserialize, Serialize};
2
3 use crate::model::repository::RepositoryVisibility;
4 use crate::model::{
5 repository::{Commit, Repository, RepositoryTreeEntry},
6 user::User,
7 };
8
9 /// A request to create a repository.
10 ///
11 /// # Authentication
12 /// - Instance Authentication
13 /// - Used to validate User token `issued_for`
14 /// - User Authentication
15 /// - Used to source owning user
16 /// - Used to authorize user token against user's instance
17 /// # Authorization
18 /// - Instance Authorization
19 /// - Used to authorize action using User token requiring a correct `issued_for` and valid issuance from user's instance
20 /// - User Authorization
21 /// - Potential User permissions checks
22 #[derive(Clone, Serialize, Deserialize)]
23 pub struct CreateRepositoryRequest {
24 pub name: String,
25 pub description: Option<String>,
26 pub visibility: RepositoryVisibility,
27 pub default_branch: String,
28 pub owner: User,
29 }
30
31 #[derive(Clone, Serialize, Deserialize)]
32 pub enum CreateRepositoryResponse {
33 Created,
34 Failed,
35 }
36
37 /// A request to inspect the tree of a repository.
38 ///
39 /// # Authentication
40 /// - Instance Authentication
41 /// - Validate request against the `issued_for` public key
42 /// - Validate User token against the user's instance's public key
43 /// # Authorization
44 /// - User Authorization
45 /// - Potential User permissions checks
46 #[derive(Clone, Serialize, Deserialize)]
47 pub struct RepositoryFileInspectRequest {
48 pub path: RepositoryTreeEntry,
49 }
50
51 #[derive(Clone, Serialize, Deserialize)]
52 pub enum RepositoryFileInspectionResponse {
53 File {
54 commit_metadata: Commit,
55 },
56 Folder {
57 commit_metadata: Commit,
58 members: Vec<RepositoryTreeEntry>,
59 },
60 Invalid {
61 path: RepositoryTreeEntry,
62 },
63 }
64
65 /// A request to get a repository's information.
66 ///
67 /// # Authentication
68 /// - Instance Authentication
69 /// - Validate request against the `issued_for` public key
70 /// - Validate User token against the user's instance's public key
71 /// # Authorization
72 /// - User Authorization
73 /// - Potential User permissions checks
74 #[derive(Clone, Serialize, Deserialize)]
75 pub struct RepositoryIssuesCountRequest;
76
77 #[derive(Clone, Serialize, Deserialize)]
78 pub struct RepositoryIssuesCountResponse {
79 pub count: u64,
80 }
81
82 /// A request to get a repository's issues count.
83 ///
84 /// # Authentication
85 /// - Instance Authentication
86 /// - Validate request against the `issued_for` public key
87 /// - Validate User token against the user's instance's public key
88 /// # Authorization
89 /// - User Authorization
90 /// - Potential User permissions checks
91 #[derive(Clone, Serialize, Deserialize)]
92 pub struct RepositoryIssueLabelsRequest;
93
94 #[derive(Clone, Serialize, Deserialize)]
95 pub struct RepositoryIssueLabelsResponse {
96 pub labels: Vec<IssueLabel>,
97 }
98
99 #[derive(Clone, Serialize, Deserialize)]
100 pub struct IssueLabel {
101 pub name: String,
102 pub color: String,
103 }
104
105 /// A request to get a repository's issue labels.
106 ///
107 /// # Authentication
108 /// - Instance Authentication
109 /// - Validate request against the `issued_for` public key
110 /// - Validate User token against the user's instance's public key
111 /// # Authorization
112 /// - User Authorization
113 /// - Potential User permissions checks
114 #[derive(Clone, Serialize, Deserialize)]
115 pub struct RepositoryIssuesRequest;
116
117 #[derive(Clone, Serialize, Deserialize)]
118 pub struct RepositoryIssuesResponse {
119 pub issues: Vec<RepositoryIssue>,
120 }
121
122 /// A request to get a repository's issues.
123 ///
124 /// # Authentication
125 /// - Instance Authentication
126 /// - Validate request against the `issued_for` public key
127 /// - Validate User token against the user's instance's public key
128 /// # Authorization
129 /// - User Authorization
130 /// - Potential User permissions checks
131 #[derive(Clone, Serialize, Deserialize)]
132 pub struct RepositoryIssue {
133 pub author: User,
134 pub id: u64,
135 pub title: String,
136 pub contents: String,
137 pub labels: Vec<IssueLabel>,
138 }
139
140 #[derive(Clone, Serialize, Deserialize)]
141 pub struct RepositoryInfoRequest {
142 pub repository: Repository,
143 /// Whether to fetch extra metadata like the last commit made to file or size
144 pub extra_metadata: bool,
145 /// Rev (branch) being requested
146 pub rev: Option<String>,
147 /// Tree path being requested
148 pub path: Option<String>,
149 }
150