1use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6#[derive(Debug, Serialize, Deserialize)]
8pub struct ApiResponse<T> {
9 pub code: i32,
10 pub msg: String,
11 pub data: Option<T>,
12}
13
14#[derive(Debug, Serialize, Deserialize, Clone)]
16pub struct User {
17 pub id: String,
18 pub user_name: String,
19 pub nickname: String,
20 #[serde(default)]
21 pub status: i32,
22 #[serde(default)]
23 pub avatar: String,
24 pub created_at: String,
25 #[serde(default)]
26 pub preferred_theme: String,
27 #[serde(default)]
28 pub anonymous: bool,
29 pub group: UserGroup,
30 #[serde(default)]
31 pub tags: Vec<String>,
32}
33
34#[derive(Debug, Serialize, Deserialize, Clone)]
36pub struct UserGroup {
37 #[serde(default)]
38 pub id: i32,
39 #[serde(default)]
40 pub name: String,
41 #[serde(default)]
42 pub allow_share: bool,
43 #[serde(default)]
44 pub allow_remote_download: bool,
45 #[serde(default)]
46 pub allow_archive_download: bool,
47 #[serde(default)]
48 pub share_download: bool,
49 #[serde(default)]
50 pub compress: bool,
51 #[serde(default)]
52 pub webdav: bool,
53 #[serde(default)]
54 pub source_batch: i32,
55 #[serde(default)]
56 pub advance_delete: bool,
57 #[serde(default)]
58 pub allow_web_dav_proxy: bool,
59}
60
61#[derive(Debug, Serialize, Deserialize, Clone)]
63pub struct Object {
64 pub id: String,
65 pub name: String,
66 pub path: String,
67 pub thumb: bool,
68 pub size: i64,
69 #[serde(rename = "type")]
70 pub object_type: String,
71 pub date: String,
72 pub create_date: String,
73 pub source_enabled: bool,
74}
75
76#[derive(Debug, Serialize, Deserialize, Clone, Default)]
78pub struct Policy {
79 #[serde(default)]
80 pub id: String,
81 #[serde(default)]
82 pub name: String,
83 #[serde(rename = "type")]
84 #[serde(default)]
85 pub policy_type: String,
86 #[serde(default)]
87 pub max_size: i64,
88 #[serde(default)]
89 pub file_type: Option<Vec<String>>,
90}
91
92#[derive(Debug, Serialize, Deserialize)]
94pub struct Property {
95 pub created_at: String,
96 pub updated_at: String,
97 pub policy: String,
98 pub size: i64,
99 pub child_folder_num: i32,
100 pub child_file_num: i32,
101 pub path: String,
102 pub query_date: String,
103}
104
105#[derive(Debug, Serialize, Deserialize)]
107pub struct DirectoryList {
108 #[serde(default)]
109 pub parent: String,
110 #[serde(default)]
111 pub objects: Vec<Object>,
112 #[serde(default)]
113 pub policy: Policy,
114}
115
116#[derive(Debug, Serialize, Deserialize)]
118pub struct UploadSession {
119 pub session_id: String,
120 pub chunk_size: i64,
121 pub expires: i64,
122 pub upload_urls: Vec<String>,
123}
124
125#[derive(Debug, Serialize)]
127pub struct UploadFileRequest<'a> {
128 pub path: &'a str,
129 pub size: i64,
130 pub name: &'a str,
131 pub policy_id: &'a str,
132 pub last_modified: i64,
133 pub mime_type: &'a str,
134}
135
136#[derive(Debug, Deserialize)]
138pub struct DownloadUrl {
139 pub url: String,
140}
141
142#[derive(Debug, Deserialize)]
144pub struct FileSource {
145 pub url: String,
146 pub name: String,
147 pub parent: i64,
148}
149
150#[derive(Debug, Serialize, Deserialize)]
152pub struct StorageInfo {
153 pub used: i64,
154 pub free: i64,
155 pub total: i64,
156}
157
158#[derive(Debug, Deserialize)]
160pub struct Share {
161 pub key: String,
162}
163
164#[derive(Debug, Serialize)]
166pub struct ShareRequest {
167 pub id: String,
168 pub is_dir: bool,
169 pub password: String,
170 pub downloads: i32,
171 pub expire: i32,
172 pub preview: bool,
173}
174
175#[derive(Debug, Serialize, Deserialize)]
177pub struct SiteConfig {
178 pub title: String,
179 pub login_captcha: bool,
180 pub reg_captcha: bool,
181 pub forget_captcha: bool,
182 pub email_active: bool,
183 pub themes: String,
184 pub default_theme: String,
185 pub home_view_method: String,
186 pub share_view_method: String,
187 pub authn: bool,
188 pub user: Option<User>,
189 pub captcha_recaptcha_key: String,
190 pub captcha_type: String,
191 pub tcaptcha_captcha_app_id: String,
192 pub register_enabled: bool,
193 pub app_promotion: bool,
194 pub wopi_exts: Option<Value>,
195}
196
197#[derive(Debug, Serialize)]
199pub struct LoginRequest<'a> {
200 #[serde(rename = "userName")]
201 pub user_name: &'a str,
202 #[serde(rename = "Password")]
203 pub password: &'a str,
204 #[serde(rename = "captchaCode")]
205 pub captcha_code: &'a str,
206}
207
208#[derive(Debug, Serialize)]
210pub struct OtpLoginRequest {
211 pub code: String,
212}
213
214#[derive(Debug, Serialize)]
216pub struct CreateDirectoryRequest<'a> {
217 pub path: &'a str,
218}
219
220#[derive(Debug, Serialize)]
222pub struct CreateFileRequest<'a> {
223 pub path: &'a str,
224}
225
226#[derive(Debug, Serialize)]
228pub struct FileSourceRequest {
229 pub items: Vec<String>,
230}
231
232#[derive(Debug, Serialize)]
234pub struct RenameObjectRequest<'a> {
235 pub action: &'a str,
236 pub src: SourceItems<'a>,
237 pub new_name: &'a str,
238}
239
240#[derive(Debug, Serialize)]
242pub struct SourceItems<'a> {
243 pub dirs: Vec<&'a str>,
244 pub items: Vec<&'a str>,
245}
246
247#[derive(Debug, Serialize)]
249pub struct MoveObjectRequest<'a> {
250 pub action: &'a str,
251 pub src_dir: &'a str,
252 pub src: SourceItems<'a>,
253 pub dst: &'a str,
254}
255
256#[derive(Debug, Serialize)]
258pub struct CopyObjectRequest<'a> {
259 pub src_dir: &'a str,
260 pub src: SourceItems<'a>,
261 pub dst: &'a str,
262}
263
264#[derive(Debug, Serialize)]
266pub struct DeleteObjectRequest<'a> {
267 pub items: Vec<&'a str>,
268 pub dirs: Vec<&'a str>,
269 pub force: bool,
270 pub unlink: bool,
271}
272
273pub struct ObjectPropertyRequest<'a> {
275 pub id: &'a str,
276 pub is_folder: Option<bool>,
277 pub trace_root: Option<bool>,
278}
279
280#[derive(Debug, Deserialize)]
282pub struct Aria2Task {
283 pub id: String,
284 pub url: String,
285 pub status: String,
286 pub progress: f64,
287 pub created_at: String,
288}
289
290#[derive(Debug, Serialize)]
292pub struct Aria2CreateRequest<'a> {
293 pub dst: &'a str,
294 pub url: Vec<&'a str>,
295}
296
297#[derive(Debug, Deserialize)]
299pub struct WebdavAccount {
300 pub id: i32,
301 pub name: String,
302 pub server: String,
303 pub created_at: String,
304}