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 pub status: i32,
21 pub avatar: String,
22 pub created_at: String,
23 pub preferred_theme: String,
24 pub anonymous: bool,
25 pub group: UserGroup,
26 pub tags: Vec<String>,
27}
28
29#[derive(Debug, Serialize, Deserialize, Clone)]
31pub struct UserGroup {
32 pub id: i32,
33 pub name: String,
34 pub allow_share: bool,
35 pub allow_remote_download: bool,
36 pub allow_archive_download: bool,
37 pub share_download: bool,
38 pub compress: bool,
39 pub webdav: bool,
40 pub source_batch: i32,
41 pub advance_delete: bool,
42 pub allow_web_dav_proxy: bool,
43}
44
45#[derive(Debug, Serialize, Deserialize, Clone)]
47pub struct Object {
48 pub id: String,
49 pub name: String,
50 pub path: String,
51 pub thumb: bool,
52 pub size: i64,
53 #[serde(rename = "type")]
54 pub object_type: String,
55 pub date: String,
56 pub create_date: String,
57 pub source_enabled: bool,
58}
59
60#[derive(Debug, Serialize, Deserialize, Clone)]
62pub struct Policy {
63 pub id: String,
64 pub name: String,
65 #[serde(rename = "type")]
66 pub policy_type: String,
67 pub max_size: i64,
68 pub file_type: Vec<String>,
69}
70
71#[derive(Debug, Serialize, Deserialize)]
73pub struct Property {
74 pub created_at: String,
75 pub updated_at: String,
76 pub policy: String,
77 pub size: i64,
78 pub child_folder_num: i32,
79 pub child_file_num: i32,
80 pub path: String,
81 pub query_date: String,
82}
83
84#[derive(Debug, Serialize, Deserialize)]
86pub struct DirectoryList {
87 pub parent: String,
88 pub objects: Vec<Object>,
89 pub policy: Policy,
90}
91
92#[derive(Debug, Serialize, Deserialize)]
94pub struct UploadSession {
95 pub session_id: String,
96 pub chunk_size: i64,
97 pub expires: i64,
98 pub upload_urls: Vec<String>,
99}
100
101#[derive(Debug, Serialize)]
103pub struct UploadFileRequest<'a> {
104 pub path: &'a str,
105 pub size: i64,
106 pub name: &'a str,
107 pub policy_id: &'a str,
108 pub last_modified: i64,
109 pub mime_type: &'a str,
110}
111
112#[derive(Debug, Deserialize)]
114pub struct DownloadUrl {
115 pub url: String,
116}
117
118#[derive(Debug, Deserialize)]
120pub struct FileSource {
121 pub url: String,
122 pub name: String,
123 pub parent: i64,
124}
125
126#[derive(Debug, Serialize, Deserialize)]
128pub struct StorageInfo {
129 pub used: i64,
130 pub free: i64,
131 pub total: i64,
132}
133
134#[derive(Debug, Deserialize)]
136pub struct Share {
137 pub key: String,
138}
139
140#[derive(Debug, Serialize)]
142pub struct ShareRequest {
143 pub id: String,
144 pub is_dir: bool,
145 pub password: String,
146 pub downloads: i32,
147 pub expire: i32,
148 pub preview: bool,
149}
150
151#[derive(Debug, Serialize, Deserialize)]
153pub struct SiteConfig {
154 pub title: String,
155 pub login_captcha: bool,
156 pub reg_captcha: bool,
157 pub forget_captcha: bool,
158 pub email_active: bool,
159 pub themes: String,
160 pub default_theme: String,
161 pub home_view_method: String,
162 pub share_view_method: String,
163 pub authn: bool,
164 pub user: Option<User>,
165 pub captcha_recaptcha_key: String,
166 pub captcha_type: String,
167 pub tcaptcha_captcha_app_id: String,
168 pub register_enabled: bool,
169 pub app_promotion: bool,
170 pub wopi_exts: Option<Value>,
171}
172
173#[derive(Debug, Serialize)]
175pub struct LoginRequest<'a> {
176 #[serde(rename = "userName")]
177 pub user_name: &'a str,
178 #[serde(rename = "Password")]
179 pub password: &'a str,
180 #[serde(rename = "captchaCode")]
181 pub captcha_code: &'a str,
182}
183
184#[derive(Debug, Serialize)]
186pub struct OtpLoginRequest {
187 pub code: String,
188}
189
190#[derive(Debug, Serialize)]
192pub struct CreateDirectoryRequest<'a> {
193 pub path: &'a str,
194}
195
196#[derive(Debug, Serialize)]
198pub struct CreateFileRequest<'a> {
199 pub path: &'a str,
200}
201
202#[derive(Debug, Serialize)]
204pub struct FileSourceRequest {
205 pub items: Vec<String>,
206}
207
208#[derive(Debug, Serialize)]
210pub struct RenameObjectRequest<'a> {
211 pub action: &'a str,
212 pub src: SourceItems<'a>,
213 pub new_name: &'a str,
214}
215
216#[derive(Debug, Serialize)]
218pub struct SourceItems<'a> {
219 pub dirs: Vec<&'a str>,
220 pub items: Vec<&'a str>,
221}
222
223#[derive(Debug, Serialize)]
225pub struct MoveObjectRequest<'a> {
226 pub action: &'a str,
227 pub src_dir: &'a str,
228 pub src: SourceItems<'a>,
229 pub dst: &'a str,
230}
231
232#[derive(Debug, Serialize)]
234pub struct CopyObjectRequest<'a> {
235 pub src_dir: &'a str,
236 pub src: SourceItems<'a>,
237 pub dst: &'a str,
238}
239
240#[derive(Debug, Serialize)]
242pub struct DeleteObjectRequest<'a> {
243 pub items: Vec<&'a str>,
244 pub dirs: Vec<&'a str>,
245 pub force: bool,
246 pub unlink: bool,
247}
248
249pub struct ObjectPropertyRequest<'a> {
251 pub id: &'a str,
252 pub is_folder: Option<bool>,
253 pub trace_root: Option<bool>,
254}
255
256#[derive(Debug, Deserialize)]
258pub struct Aria2Task {
259 pub id: String,
260 pub url: String,
261 pub status: String,
262 pub progress: f64,
263 pub created_at: String,
264}
265
266#[derive(Debug, Serialize)]
268pub struct Aria2CreateRequest<'a> {
269 pub dst: &'a str,
270 pub url: Vec<&'a str>,
271}
272
273#[derive(Debug, Deserialize)]
275pub struct WebdavAccount {
276 pub id: i32,
277 pub name: String,
278 pub server: String,
279 pub created_at: String,
280}