cloudreve_api/api/v4/models/
request.rs

1//! Request types for Cloudreve API v4
2
3use serde::Serialize;
4
5/// Upload file request
6#[derive(Debug, Serialize)]
7pub struct UploadRequest<'a> {
8    pub path: &'a str,
9    pub name: Option<&'a str>,
10    pub overwrite: Option<bool>,
11}
12
13/// List files request
14#[derive(Debug, Serialize, Default)]
15pub struct ListFilesRequest<'a> {
16    pub path: &'a str,
17    pub page: Option<u32>,
18    pub page_size: Option<u32>,
19    pub order_by: Option<&'a str>,
20    pub order_direction: Option<&'a str>,
21    pub next_page_token: Option<&'a str>,
22}
23
24/// Move file request
25#[derive(Debug, Serialize)]
26pub struct MoveFileRequest<'a> {
27    pub from: &'a str,
28    pub to: &'a str,
29}
30
31/// Copy file request
32#[derive(Debug, Serialize)]
33pub struct CopyFileRequest<'a> {
34    pub from: &'a str,
35    pub to: &'a str,
36}
37
38/// Rename file request
39#[derive(Debug, Serialize)]
40pub struct RenameFileRequest<'a> {
41    pub name: &'a str,
42}
43
44/// Set file permission request
45#[derive(Debug, Serialize)]
46pub struct SetFilePermissionRequest<'a> {
47    /// File path (will be converted to URI format internally)
48    ///
49    /// Can be:
50    /// - Absolute path: "/folder/file.txt"
51    /// - Relative path: "folder/file.txt"
52    /// - Already formatted URI: "cloudreve://my/folder/file.txt"
53    pub uri: &'a str,
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub user_explicit: Option<serde_json::Value>,
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub group_explicit: Option<serde_json::Value>,
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub same_group: Option<&'a str>,
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub other: Option<&'a str>,
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub anonymous: Option<&'a str>,
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub everyone: Option<&'a str>,
66}
67
68/// Create upload session request
69#[derive(Debug, Serialize)]
70pub struct CreateUploadSessionRequest<'a> {
71    /// Target file path (will be converted to URI format internally)
72    ///
73    /// Can be:
74    /// - Absolute path: "/folder/file.txt"
75    /// - Relative path: "folder/file.txt"
76    /// - Already formatted URI: "cloudreve://my/folder/file.txt"
77    pub uri: &'a str,
78    /// Size of the file in bytes
79    pub size: u64,
80    /// ID of the storage policy to use
81    pub policy_id: &'a str,
82    /// Optional Unix milliseconds timestamp of when the file is last modified
83    #[serde(skip_serializing_if = "Option::is_none")]
84    pub last_modified: Option<u64>,
85    /// Optional mime type of the file
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub mime_type: Option<&'a str>,
88    /// Optional key-value of file metadata
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub metadata: Option<std::collections::HashMap<String, String>>,
91    /// Optional blob type. "version" overwrites existing files.
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub entity_type: Option<&'a str>,
94}
95
96/// Delete upload session request
97#[derive(Debug, Serialize)]
98pub struct DeleteUploadSessionRequest<'a> {
99    /// ID of the upload session
100    pub id: &'a str,
101    /// Target file path (will be converted to URI format internally)
102    ///
103    /// Can be:
104    /// - Absolute path: "/folder/file.txt"
105    /// - Relative path: "folder/file.txt"
106    /// - Already formatted URI: "cloudreve://my/folder/file.txt"
107    pub uri: &'a str,
108}
109
110/// Move/copy file request
111#[derive(Debug, Serialize)]
112pub struct MoveCopyFileRequest<'a> {
113    pub from: Vec<&'a str>,
114    pub to: &'a str,
115    #[serde(skip_serializing_if = "Option::is_none")]
116    pub copy: Option<bool>,
117}
118
119/// Update file content request
120#[derive(Debug, Serialize)]
121pub struct UpdateFileContentRequest<'a> {
122    /// File path (will be converted to URI format internally)
123    ///
124    /// Can be:
125    /// - Absolute path: "/folder/file.txt"
126    /// - Relative path: "folder/file.txt"
127    /// - Already formatted URI: "cloudreve://my/folder/file.txt"
128    pub uri: &'a str,
129    pub content: &'a str,
130}
131
132/// Create viewer session request
133#[derive(Debug, Serialize)]
134pub struct CreateViewerSessionRequest<'a> {
135    /// File path (will be converted to URI format internally)
136    ///
137    /// Can be:
138    /// - Absolute path: "/folder/file.txt"
139    /// - Relative path: "folder/file.txt"
140    /// - Already formatted URI: "cloudreve://my/folder/file.txt"
141    pub uri: &'a str,
142}
143
144/// Create file request
145#[derive(Debug, Serialize)]
146pub struct CreateFileRequest<'a> {
147    pub path: &'a str,
148    pub name: &'a str,
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub content: Option<&'a str>,
151    #[serde(skip_serializing_if = "Option::is_none")]
152    pub overwrite: Option<bool>,
153}
154
155/// Rename multiple request
156#[derive(Debug, Serialize)]
157pub struct RenameMultipleRequest<'a> {
158    pub uris: Vec<&'a str>,
159    pub names: Vec<&'a str>,
160}
161
162/// Create download URL request
163#[derive(Debug, Serialize)]
164pub struct CreateDownloadUrlRequest<'a> {
165    /// List of file paths (will be converted to URI format internally)
166    ///
167    /// Each path can be:
168    /// - Absolute path: "/folder/file.txt"
169    /// - Relative path: "folder/file.txt"
170    /// - Already formatted URI: "cloudreve://my/folder/file.txt"
171    pub uris: Vec<&'a str>,
172    #[serde(skip_serializing_if = "Option::is_none")]
173    pub download: Option<bool>,
174    #[serde(skip_serializing_if = "Option::is_none")]
175    pub redirect: Option<bool>,
176    #[serde(skip_serializing_if = "Option::is_none")]
177    pub entity: Option<&'a str>,
178    #[serde(skip_serializing_if = "Option::is_none")]
179    pub use_primary_site_url: Option<bool>,
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub skip_error: Option<bool>,
182    #[serde(skip_serializing_if = "Option::is_none")]
183    pub archive: Option<bool>,
184    #[serde(skip_serializing_if = "Option::is_none")]
185    pub no_cache: Option<bool>,
186}
187
188/// Restore file request
189#[derive(Debug, Serialize)]
190pub struct RestoreFileRequest<'a> {
191    /// List of file paths to restore (will be converted to URI format internally)
192    ///
193    /// Each path can be:
194    /// - Absolute path: "/folder/file.txt"
195    /// - Relative path: "folder/file.txt"
196    /// - Already formatted URI: "cloudreve://my/folder/file.txt"
197    pub uris: Vec<&'a str>,
198}
199
200/// Update metadata request
201#[derive(Debug, Serialize)]
202pub struct UpdateMetadataRequest {
203    #[serde(skip_serializing_if = "Option::is_none")]
204    pub metadata: Option<serde_json::Value>,
205    #[serde(skip_serializing_if = "Option::is_none")]
206    pub clear_metadata: Option<bool>,
207}
208
209/// Mount storage policy request
210#[derive(Debug, Serialize)]
211pub struct MountStoragePolicyRequest {
212    pub policy_id: u64,
213    #[serde(skip_serializing_if = "Option::is_none")]
214    pub inherit_to_children: Option<bool>,
215}
216
217/// Update view request
218#[derive(Debug, Serialize)]
219pub struct UpdateViewRequest {
220    #[serde(skip_serializing_if = "Option::is_none")]
221    pub page_size: Option<i32>,
222    #[serde(skip_serializing_if = "Option::is_none")]
223    pub order: Option<String>,
224    #[serde(skip_serializing_if = "Option::is_none")]
225    pub order_direction: Option<String>,
226    #[serde(skip_serializing_if = "Option::is_none")]
227    pub view: Option<String>,
228    #[serde(skip_serializing_if = "Option::is_none")]
229    pub thumbnail: Option<bool>,
230    #[serde(skip_serializing_if = "Option::is_none")]
231    pub gallery_width: Option<i32>,
232}
233
234/// Get file info request
235#[derive(Debug, Serialize)]
236pub struct GetFileInfoRequest<'a> {
237    /// File path (will be converted to URI format internally)
238    ///
239    /// Can be:
240    /// - Absolute path: "/folder/file.txt"
241    /// - Relative path: "folder/file.txt"
242    /// - Already formatted URI: "cloudreve://my/folder/file.txt"
243    pub uri: &'a str,
244    #[serde(skip_serializing_if = "Option::is_none")]
245    pub include_extended_info: Option<bool>,
246}
247
248/// Get archive list request
249#[derive(Debug, Serialize)]
250pub struct GetArchiveListRequest<'a> {
251    /// File path (will be converted to URI format internally)
252    ///
253    /// Can be:
254    /// - Absolute path: "/folder/file.txt"
255    /// - Relative path: "folder/file.txt"
256    /// - Already formatted URI: "cloudreve://my/folder/file.txt"
257    pub uri: &'a str,
258}
259
260/// Create remote download request
261#[derive(Debug, Serialize)]
262pub struct CreateRemoteDownloadRequest<'a> {
263    pub url: &'a str,
264    pub path: Option<&'a str>,
265    pub node_id: Option<u64>,
266}
267
268/// Relocate request
269#[derive(Debug, Serialize)]
270pub struct RelocateRequest<'a> {
271    pub files: Vec<&'a str>,
272    pub target_policy_id: &'a str,
273    pub path: Option<&'a str>,
274}
275
276/// Import request
277#[derive(Debug, Serialize)]
278pub struct ImportRequest<'a> {
279    pub source_url: &'a str,
280    pub target_path: &'a str,
281    pub node_id: Option<u64>,
282}
283
284/// Select download files request
285#[derive(Debug, Serialize)]
286pub struct SelectDownloadFilesRequest<'a> {
287    pub selected_files: Vec<&'a str>,
288}
289
290/// Create download request (alias for remote download)
291#[derive(Debug, Serialize)]
292pub struct CreateDownloadRequest<'a> {
293    pub url: &'a str,
294    pub path: Option<&'a str>,
295    pub node_id: Option<u64>,
296}