1use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6#[derive(Debug, Serialize, Deserialize)]
7pub struct ApiResponse<T> {
8 pub code: i32,
9 pub msg: String,
10 pub data: Option<T>,
11}
12
13#[derive(Debug, Serialize, Deserialize, Clone)]
14pub struct User {
15 pub id: String,
16 pub email: String,
17 pub nickname: String,
18 #[serde(default)]
19 pub status: Option<String>,
20 #[serde(default)]
21 pub avatar: Option<String>,
22 pub created_at: String,
23 #[serde(default)]
24 pub group: Option<UserGroup>,
25}
26
27#[derive(Debug, Serialize, Deserialize, Clone)]
28pub struct UserGroup {
29 pub id: String,
30 pub name: String,
31 #[serde(default)]
32 pub permission: Option<String>,
33 #[serde(default)]
34 pub direct_link_batch_size: Option<u64>,
35 #[serde(default)]
36 pub trash_retention: Option<u64>,
37}
38
39#[derive(Debug, Serialize, Deserialize, Clone)]
40pub struct Token {
41 pub access_token: String,
42 pub refresh_token: String,
43 pub access_expires: String,
44 pub refresh_expires: String,
45}
46
47#[derive(Debug, Serialize, Deserialize)]
48pub struct LoginData {
49 pub user: User,
50 pub token: Token,
51}
52
53#[derive(Debug, Serialize, Deserialize)]
54pub struct FileStat {
55 pub size: u64,
56 pub created_at: String,
57 pub updated_at: String,
58 pub mime_type: String,
59}
60
61#[derive(Debug, Serialize, Deserialize, Clone)]
62pub struct ShareLink {
63 pub id: String,
64 pub name: String,
65 pub visited: i64,
66 pub downloaded: i64,
67 pub price: i64,
68 pub unlocked: bool,
69 pub source_type: ShareSourceType,
70 pub owner: NewUser,
71 pub created_at: String,
72 pub expired: bool,
73 pub url: String,
74 pub permission_setting: PermissionSetting,
75 #[serde(rename = "is_private")]
76 pub is_private: Option<bool>,
77 pub password: Option<String>,
78 pub source_uri: Option<String>,
79 pub share_view: Option<bool>,
80 pub show_readme: Option<bool>,
81 pub password_protected: Option<bool>,
82 pub expires: Option<String>,
83 pub expired_at: Option<String>,
84 pub download_count: u64,
85}
86
87#[derive(Debug, Serialize, Deserialize, Clone)]
88pub struct StoragePolicy {
89 pub id: String,
90 pub name: String,
91 #[serde(rename = "type")]
92 pub type_: String,
93 pub max_size: u64,
94 #[serde(default)]
95 pub allowed_suffix: Option<Vec<String>>,
96 #[serde(default)]
97 pub denied_suffix: Option<Vec<String>>,
98 #[serde(default)]
99 pub allowed_name_regexp: Option<String>,
100 #[serde(default)]
101 pub denied_name_regexp: Option<String>,
102 #[serde(default)]
103 pub relay: Option<bool>,
104 #[serde(default)]
105 pub weight: Option<u64>,
106 #[serde(default)]
107 pub children: Option<Vec<StoragePolicy>>,
108 #[serde(default)]
109 pub chunk_concurrency: Option<u32>,
110}
111
112#[derive(Debug, Serialize, Deserialize)]
113pub struct Node {
114 pub id: u64,
115 pub name: String,
116 pub created_at: String,
117}
118
119#[derive(Debug, Serialize, Deserialize, Clone)]
120pub struct Task {
121 pub id: String,
122 pub name: String,
123 pub status: String,
124 pub created_at: String,
125 pub updated_at: String,
126}
127
128#[derive(Debug, Serialize)]
129pub struct LoginRequest<'a> {
130 pub email: &'a str,
131 pub password: &'a str,
132}
133
134#[derive(Debug, Serialize)]
135pub struct TwoFactorLoginRequest<'a> {
136 pub email: &'a str,
137 pub password: &'a str,
138 pub code: &'a str,
139 pub ticket: Option<&'a str>,
140}
141
142#[derive(Debug, Serialize)]
143pub struct RefreshTokenRequest<'a> {
144 pub refresh_token: &'a str,
145}
146
147#[derive(Debug, Serialize)]
148pub struct RegisterRequest<'a> {
149 pub username: &'a str,
150 pub password: &'a str,
151 pub email: Option<&'a str>,
152}
153
154#[derive(Debug, Serialize)]
155pub struct UpdateProfileRequest<'a> {
156 pub nickname: Option<&'a str>,
157 pub email: Option<&'a str>,
158 pub avatar: Option<&'a str>,
159}
160
161#[derive(Debug, Serialize)]
162pub struct ChangePasswordRequest<'a> {
163 pub old_password: &'a str,
164 pub new_password: &'a str,
165}
166
167#[derive(Debug, Deserialize)]
168pub struct Quota {
169 pub used: u64,
170 pub total: u64,
171 #[serde(default)]
172 pub storage_pack_total: Option<u64>,
173}
174
175#[derive(Debug, Serialize, Deserialize)]
176pub struct UserSettings {
177 pub theme: Option<String>,
178 pub language: Option<String>,
179 pub timezone: Option<String>,
180}
181
182#[derive(Debug, Serialize)]
183pub struct UploadRequest<'a> {
184 pub path: &'a str,
185 pub name: Option<&'a str>,
186 pub overwrite: Option<bool>,
187}
188
189#[derive(Debug, Serialize, Default)]
190pub struct ListFilesRequest<'a> {
191 pub path: &'a str,
192 pub page: Option<u32>,
193 pub page_size: Option<u32>,
194 pub order_by: Option<&'a str>,
195 pub order_direction: Option<&'a str>,
196 pub next_page_token: Option<&'a str>,
197}
198
199#[derive(Debug, Serialize)]
200pub struct MoveFileRequest<'a> {
201 pub from: &'a str,
202 pub to: &'a str,
203}
204
205#[derive(Debug, Serialize)]
206pub struct CopyFileRequest<'a> {
207 pub from: &'a str,
208 pub to: &'a str,
209}
210
211#[derive(Debug, Serialize)]
212pub struct RenameFileRequest<'a> {
213 pub name: &'a str,
214}
215
216#[derive(Debug, Serialize)]
217pub struct CreateShareLinkRequest {
218 pub permissions: PermissionSetting,
219 pub uri: String,
220 pub is_private: Option<bool>,
221 pub share_view: Option<bool>,
222 pub expire: Option<u32>,
223 pub price: Option<i32>,
224 pub password: Option<String>,
225 pub show_readme: Option<bool>,
226}
227
228#[derive(Debug, Serialize)]
229pub struct EditShareLinkRequest {
230 pub permissions: PermissionSetting,
231 pub uri: String,
232 pub share_view: Option<bool>,
233 pub expire: Option<u32>,
234 pub price: Option<i32>,
235 pub show_readme: Option<bool>,
236}
237
238#[derive(Debug, Serialize)]
239pub struct AbuseReportRequest<'a> {
240 pub reason: &'a str,
241}
242
243#[derive(Debug, Serialize)]
244pub struct CreateRemoteDownloadRequest<'a> {
245 pub url: &'a str,
246 pub path: Option<&'a str>,
247 pub node_id: Option<u64>,
248}
249
250#[derive(Debug, Serialize, Default)]
251pub struct ListTasksRequest<'a> {
252 pub page: Option<u32>,
253 pub per_page: Option<u32>,
254 pub status: Option<&'a str>,
255 pub type_: Option<&'a str>,
256}
257
258#[derive(Debug, Serialize)]
259pub struct CreateArchiveRequest<'a> {
260 pub files: Vec<&'a str>,
261 pub name: &'a str,
262 pub path: Option<&'a str>,
263}
264
265#[derive(Debug, Serialize)]
266pub struct ExtractArchiveRequest<'a> {
267 pub archive_uri: &'a str,
268 pub path: Option<&'a str>,
269}
270
271#[derive(Debug, Deserialize, Clone)]
272pub struct TaskProgress {
273 pub progress: f64,
274 pub message: String,
275 pub total: Option<u64>,
276 pub current: Option<u64>,
277}
278
279#[derive(Debug, Deserialize, Clone)]
280pub struct DetailedTask {
281 pub id: String,
282 pub name: String,
283 pub status: String,
284 pub type_: String,
285 pub created_at: String,
286 pub updated_at: String,
287 pub progress: Option<TaskProgress>,
288}
289
290#[derive(Debug, Serialize, Deserialize, Clone)]
291pub struct NewUser {
292 pub id: String,
293 pub email: Option<String>,
294 pub nickname: Option<String>,
295 pub created_at: String,
296 pub anonymous: Option<bool>,
297 pub group: NewGroup,
298 pub status: Option<UserStatus>,
299 pub avatar: Option<AvatarType>,
300 pub preferred_theme: Option<String>,
301 pub credit: Option<i64>,
302 pub language: String,
303 pub disable_view_sync: Option<String>,
304 pub share_links_in_profile: Option<ShareLinkVisibility>,
305}
306
307#[derive(Debug, Serialize, Deserialize, Clone)]
308pub enum UserStatus {
309 #[serde(rename = "active")]
310 Active,
311 #[serde(rename = "inactive")]
312 Inactive,
313 #[serde(rename = "manual_banned")]
314 ManualBanned,
315 #[serde(rename = "sys_banned")]
316 SysBanned,
317}
318
319#[derive(Debug, Serialize, Deserialize, Clone)]
320pub enum AvatarType {
321 #[serde(rename = "file")]
322 File,
323 #[serde(rename = "gravatar")]
324 Gravatar,
325}
326
327#[derive(Debug, Serialize, Deserialize, Clone)]
328pub enum ShareLinkVisibility {
329 #[serde(rename = "")]
330 Empty,
331 #[serde(rename = "all_share")]
332 AllShare,
333 #[serde(rename = "hide_share")]
334 HideShare,
335}
336
337#[derive(Debug, Serialize, Deserialize, Clone)]
338pub struct NewGroup {
339 pub id: String,
340 pub name: String,
341 pub permission: String,
342 pub direct_link_batch_size: i64,
343 pub trash_retention: i64,
344}
345
346#[derive(Debug, Serialize, Deserialize, Clone)]
347pub struct File {
348 #[serde(rename = "type")]
349 pub r#type: FileType,
350 pub id: String,
351 pub name: String,
352 #[serde(default)]
353 pub permission: Option<String>,
354 pub created_at: String,
355 pub updated_at: String,
356 pub size: i64,
357 #[serde(default)]
358 pub metadata: Option<Value>,
359 pub path: String,
360 #[serde(default)]
361 pub capability: Option<String>,
362 pub owned: bool,
363 #[serde(default)]
364 pub primary_entity: Option<String>
365}
366
367#[derive(Debug, Serialize, Deserialize)]
368pub struct CreditChangeRecord {
369 pub id: String,
370 pub amount: i64,
371 pub reason: String,
372 pub created_at: String,
373}
374
375#[derive(Debug, Serialize, Deserialize)]
376pub struct PaymentRecord {
377 pub id: String,
378 pub amount: f64,
379 pub method: String,
380 pub status: String,
381 pub created_at: String,
382 pub transaction_id: Option<String>,
383}
384
385#[derive(Debug, Serialize, Deserialize)]
386pub struct TwoFactorSetup {
387 pub secret: String,
388 pub qr_code: String,
389 pub recovery_codes: Vec<String>,
390}
391
392#[derive(Debug, Serialize, Deserialize)]
393pub struct TwoFactorVerify {
394 pub code: String,
395}
396
397#[derive(Debug, Serialize, Clone, PartialEq)]
398pub enum FileType {
399 File = 0,
400 Folder = 1,
401}
402
403impl<'de> Deserialize<'de> for FileType {
404 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
405 where
406 D: serde::Deserializer<'de>,
407 {
408 let value = i32::deserialize(deserializer)?;
409 match value {
410 0 => Ok(FileType::File),
411 1 => Ok(FileType::Folder),
412 _ => Err(serde::de::Error::custom(format!("Invalid FileType value: {}", value))),
413 }
414 }
415}
416
417#[derive(Debug, Serialize, Deserialize, Clone)]
418pub struct ExtendedInfo {
419 pub storage_policy: Option<NewStoragePolicy>,
420 pub storage_policy_inherited: bool,
421 pub storage_used: i64,
422 pub shares: Option<Vec<NewShare>>,
423 pub entities: Option<Vec<NewEntity>>,
424 pub permissions: Option<PermissionSetting>,
425 pub direct_links: Option<Vec<DirectLink>>,
426}
427
428#[derive(Debug, Serialize, Deserialize, Clone)]
429pub struct NewStoragePolicy {
430 pub id: String,
431 pub name: String,
432 #[serde(rename = "type")]
433 pub policy_type: StoragePolicyType,
434 pub allowed_suffix: Option<Vec<String>>,
435 pub denied_suffix: Option<Vec<String>>,
436 pub allowed_name_regexp: Option<String>,
437 pub denied_name_regexp: Option<String>,
438 pub max_size: f64,
439 pub relay: Option<bool>,
440 pub weight: Option<f64>,
441 pub children: Option<Vec<NewStoragePolicy>>,
442 pub chunk_concurrency: Option<i32>,
443}
444
445#[derive(Debug, Serialize, Deserialize, Clone)]
446pub enum StoragePolicyType {
447 #[serde(rename = "local")]
448 Local,
449 #[serde(rename = "qiniu")]
450 Qiniu,
451 #[serde(rename = "upyun")]
452 Upyun,
453 #[serde(rename = "oss")]
454 Oss,
455 #[serde(rename = "cos")]
456 Cos,
457 #[serde(rename = "s3")]
458 S3,
459 #[serde(rename = "onedrive")]
460 Onedrive,
461 #[serde(rename = "remote")]
462 Remote,
463 #[serde(rename = "obs")]
464 Obs,
465 #[serde(rename = "load_balance")]
466 LoadBalance,
467 #[serde(rename = "ks3")]
468 KS3,
469}
470
471#[derive(Debug, Serialize, Deserialize, Clone)]
472pub struct NewShare {
473 pub id: String,
474 pub name: String,
475 pub visited: i64,
476 pub downloaded: i64,
477 pub price: i64,
478 pub unlocked: bool,
479 pub source_type: ShareSourceType,
480 pub owner: NewUser,
481 pub created_at: String,
482 pub expired: bool,
483 pub url: String,
484 pub permission_setting: PermissionSetting,
485 pub is_private: Option<bool>,
486 pub password: Option<String>,
487 pub source_uri: String,
488 pub share_view: Option<bool>,
489 pub show_readme: Option<bool>,
490 pub password_protected: Option<bool>,
491}
492
493#[derive(Debug, Serialize, Deserialize, Clone)]
494pub enum ShareSourceType {
495 #[serde(rename = "0")]
496 File = 0,
497 #[serde(rename = "1")]
498 Folder = 1,
499}
500
501#[derive(Debug, Serialize, Deserialize, Clone)]
502pub struct NewEntity {
503 pub id: String,
504 pub size: i64,
505 pub r#type: EntityType,
506 pub created_at: String,
507 pub storage_policy: Option<NewStoragePolicy>,
508 pub created_by: NewUser,
509}
510
511#[derive(Debug, Serialize, Deserialize, Clone)]
512pub enum EntityType {
513 #[serde(rename = "0")]
514 Primary = 0,
515 #[serde(rename = "1")]
516 Secondary = 1,
517 #[serde(rename = "2")]
518 Temporary = 2,
519}
520
521#[derive(Debug, Serialize, Deserialize, Clone)]
522pub struct DirectLink {
523 pub id: String,
524 pub url: String,
525 pub downloaded: f64,
526 pub created_at: String,
527}
528
529#[derive(Debug, Serialize, Deserialize, Clone)]
530pub struct PermissionSetting {
531 #[serde(rename = "user_explicit")]
532 pub user_explicit: Value,
533 #[serde(rename = "group_explicit")]
534 pub group_explicit: Value,
535 #[serde(rename = "same_group")]
536 pub same_group: String,
537 #[serde(rename = "other")]
538 pub other: String,
539 #[serde(rename = "anonymous")]
540 pub anonymous: String,
541 #[serde(rename = "everyone")]
542 pub everyone: String,
543}
544
545#[derive(Debug, Serialize, Deserialize, Clone)]
546pub struct FolderSummary {
547 pub size: i64,
548 pub files: i64,
549 pub folders: i64,
550 pub completed: bool,
551 pub calculated_at: String,
552}
553
554#[derive(Debug, Serialize, Deserialize, Clone)]
555pub struct ListResponse {
556 pub files: Vec<File>,
557 pub parent: File,
558 pub pagination: PaginationResults,
559 pub props: NavigatorProps,
560 pub context_hint: String,
561 pub mixed_type: bool,
562 pub storage_policy: Option<StoragePolicy>,
563 pub view: Option<ExplorerView>,
564}
565
566#[derive(Debug, Serialize, Deserialize, Clone)]
567pub struct PaginationResults {
568 pub page: i32,
569 pub page_size: i32,
570 pub total_items: Option<i64>,
571 pub next_token: Option<String>,
572 pub is_cursor: bool,
573}
574
575#[derive(Debug, Serialize, Deserialize, Clone)]
576pub struct NavigatorProps {
577 pub capability: String,
578 pub max_page_size: i32,
579 pub order_by_options: Vec<String>,
580 pub order_direction_options: Vec<String>,
581}
582
583#[derive(Debug, Serialize, Deserialize, Clone)]
584pub struct ExplorerView {
585 pub page_size: Option<i32>,
586 pub order: Option<String>,
587 pub order_direction: Option<OrderDirection>,
588 pub view: Option<ExplorerViewMode>,
589 pub thumbnail: Option<bool>,
590 pub gallery_width: Option<i32>,
591 pub columns: Option<Vec<ListViewColumn>>,
592}
593
594#[derive(Debug, Serialize, Deserialize, Clone)]
595pub enum OrderDirection {
596 #[serde(rename = "asc")]
597 Asc,
598 #[serde(rename = "desc")]
599 Desc,
600}
601
602#[derive(Debug, Serialize, Deserialize, Clone)]
603pub enum ExplorerViewMode {
604 #[serde(rename = "list")]
605 List,
606 #[serde(rename = "grid")]
607 Grid,
608 #[serde(rename = "gallery")]
609 Gallery,
610}
611
612#[derive(Debug, Serialize, Deserialize, Clone)]
613pub struct ListViewColumn {
614 pub r#type: i32,
615 pub width: Option<i32>,
616 pub props: Option<ColumnProps>,
617}
618
619#[derive(Debug, Serialize, Deserialize, Clone)]
620pub struct ColumnProps {
621 pub metadata_key: Option<String>,
622}
623
624#[derive(Debug, Serialize, Deserialize, Clone)]
625pub struct TaskResponse {
626 pub created_at: String,
627 pub updated_at: String,
628 pub id: String,
629 pub status: TaskStatus,
630 pub r#type: TaskType,
631 pub summary: Option<TaskSummary>,
632 pub duration: Option<i64>,
633 pub resume_time: Option<i64>,
634 pub error: Option<String>,
635 pub error_history: Option<Vec<String>>,
636 pub retry_count: Option<i32>,
637 pub node: NewNode,
638}
639
640#[derive(Debug, Serialize, Deserialize, Clone)]
641pub enum TaskStatus {
642 #[serde(rename = "queued")]
643 Queued,
644 #[serde(rename = "processing")]
645 Processing,
646 #[serde(rename = "suspending")]
647 Suspending,
648 #[serde(rename = "error")]
649 Error,
650 #[serde(rename = "canceled")]
651 Canceled,
652 #[serde(rename = "completed")]
653 Completed,
654}
655
656#[derive(Debug, Serialize, Deserialize, Clone)]
657pub enum TaskType {
658 #[serde(rename = "media_meta")]
659 MediaMeta,
660 #[serde(rename = "entity_recycle_routine")]
661 EntityRecycleRoutine,
662 #[serde(rename = "explicit_entity_recycle")]
663 ExplicitEntityRecycle,
664 #[serde(rename = "upload_sentinel_check")]
665 UploadSentinelCheck,
666 #[serde(rename = "create_archive")]
667 CreateArchive,
668 #[serde(rename = "extract_archive")]
669 ExtractArchive,
670 #[serde(rename = "relocate")]
671 Relocate,
672 #[serde(rename = "remote_download")]
673 RemoteDownload,
674 #[serde(rename = "import")]
675 Import,
676}
677
678#[derive(Debug, Serialize, Deserialize, Clone)]
679pub struct TaskSummary {
680 pub phase: String,
681 pub props: Value,
682}
683
684#[derive(Debug, Serialize, Deserialize, Clone)]
685pub struct NewNode {
686 pub id: String,
687 pub name: String,
688 pub r#type: NodeType,
689 pub capabilities: String,
690}
691
692#[derive(Debug, Serialize, Deserialize, Clone)]
693pub enum NodeType {
694 #[serde(rename = "master")]
695 Master,
696 #[serde(rename = "slave")]
697 Slave,
698}
699
700#[derive(Debug, Serialize, Deserialize, Clone)]
701pub struct TaskListResponse {
702 pub pagination: TaskPagination,
703 pub tasks: Vec<TaskResponse>,
704}
705
706#[derive(Debug, Serialize, Deserialize, Clone)]
707pub struct TaskPagination {
708 pub page_size: i32,
709 pub next_token: String,
710 pub is_cursor: bool,
711}
712
713#[derive(Debug, Serialize, Deserialize, Clone)]
714pub struct Progress {
715 pub total: i64,
716 pub current: i64,
717 pub identifier: Option<String>,
718}
719
720#[derive(Debug, Serialize, Deserialize, Clone)]
721pub struct Activity {
722 pub id: String,
723 pub content: LogEntry,
724 pub created_at: String,
725 pub user: Option<NewUser>,
726 pub version_id: Option<String>,
727}
728
729#[derive(Debug, Serialize, Deserialize, Clone)]
730pub struct LogEntry {
731 pub r#type: String,
732 pub props: Value,
733}
734
735#[derive(Debug, Serialize, Deserialize, Clone)]
736pub struct FileActivitiesResponse {
737 pub activities: Vec<Activity>,
738 pub pagination: ActivitiesPagination,
739}
740
741#[derive(Debug, Serialize, Deserialize, Clone)]
742pub struct ActivitiesPagination {
743 pub page: i32,
744 pub page_size: i32,
745 pub next_token: String,
746 pub is_cursor: bool,
747}
748
749#[derive(Debug, Deserialize)]
750pub struct CaptchaResponse {
751 pub image: String,
752 pub ticket: String,
753}
754
755#[derive(Debug, Deserialize)]
756pub struct SiteConfig {
757 pub instance_id: Option<String>,
758 pub title: Option<String>,
759 pub login_captcha: Option<bool>,
760 pub reg_captcha: Option<bool>,
761 pub forget_captcha: Option<bool>,
762 pub abuse_report_captcha: Option<bool>,
763 pub themes: Option<String>,
764 pub default_theme: Option<String>,
765 pub authn: Option<bool>,
766 pub user: Option<NewUser>,
767 pub captcha_re_captcha_key: Option<String>,
768 pub captcha_cap_instance_url: String,
769 pub captcha_cap_site_key: String,
770 pub site_notice: Option<String>,
771 pub captcha_type: Option<String>,
772 pub turnstile_site_id: Option<String>,
773 pub register_enabled: Option<bool>,
774 pub qq_enabled: Option<bool>,
775 pub sso_enabled: Option<bool>,
776 pub sso_display_name: Option<String>,
777 pub sso_icon: Option<String>,
778 pub oidc_enabled: Option<bool>,
779 pub oidc_display_name: Option<String>,
780 pub oidc_icon: Option<String>,
781 pub logo: Option<String>,
782 pub logo_light: Option<String>,
783 pub tos_url: Option<String>,
784 pub privacy_policy_url: Option<String>,
785 pub icons: Option<String>,
786 pub emoji_preset: Option<String>,
787 pub point_enabled: Option<bool>,
788 pub share_point_gain_rate: Option<f64>,
789 pub map_provider: Option<String>,
790 pub google_map_tile_type: Option<String>,
791 pub file_viewers: Option<Vec<FileViewer>>,
792 pub max_batch_size: Option<f64>,
793 pub app_promotion: Option<bool>,
794 pub app_feedback: Option<String>,
795 pub app_forum: Option<String>,
796 pub payment: Option<PaymentSetting>,
797 pub anonymous_purchase: Option<bool>,
798 pub point_price: Option<f64>,
799 pub shop_nav_enabled: Option<bool>,
800 pub storage_products: Option<Vec<StorageProduct>>,
801 pub group_skus: Option<Vec<GroupSKU>>,
802 pub thumbnail_width: Option<f64>,
803 pub thumbnail_height: Option<f64>,
804 pub custom_props: Option<Vec<CustomProps>>,
805 pub custom_nav_items: Option<Vec<CustomNavItem>>,
806 pub custom_html: Option<CustomHTML>,
807 pub mapbox_ak: Option<String>,
808 pub thumb_exts: Option<Vec<String>>,
809}
810
811#[derive(Debug, Serialize, Deserialize)]
812pub struct FileViewer {
813 pub extensions: Vec<String>,
814 pub handler: String,
815 pub name: String,
816 pub priority: i32,
817}
818
819#[derive(Debug, Serialize, Deserialize)]
820pub struct PaymentSetting {
821 pub providers: Vec<PaymentProvider>,
822}
823
824#[derive(Debug, Serialize, Deserialize)]
825pub struct PaymentProvider {
826 pub id: String,
827 pub name: String,
828 pub enabled: bool,
829}
830
831#[derive(Debug, Serialize, Deserialize)]
832pub struct StorageProduct {
833 pub id: String,
834 pub name: String,
835 pub price: f64,
836 pub storage: i64,
837}
838
839#[derive(Debug, Serialize, Deserialize)]
840pub struct GroupSKU {
841 pub id: String,
842 pub name: String,
843 pub price: f64,
844 pub group_id: String,
845}
846
847#[derive(Debug, Serialize, Deserialize)]
848pub struct CustomProps {
849 pub key: String,
850 pub name: String,
851 pub r#type: String,
852 pub options: Option<Vec<String>>,
853}
854
855#[derive(Debug, Serialize, Deserialize)]
856pub struct CustomNavItem {
857 pub icon: String,
858 pub name: String,
859 pub url: String,
860}
861
862#[derive(Debug, Serialize, Deserialize)]
863pub struct CustomHTML {
864 pub head: Option<String>,
865 pub body: Option<String>,
866}
867
868#[derive(Debug, Deserialize)]
869pub struct LoginPreparation {
870 pub webauthn_enabled: bool,
871 pub sso_enabled: bool,
872 pub password_enabled: bool,
873 pub qq_enabled: bool,
874}
875
876#[derive(Debug, Serialize)]
877pub struct OpenIdPrepareRequest<'a> {
878 pub hint: Option<&'a str>,
879 pub linking: Option<bool>,
880 pub provider: i32,
881}
882
883#[derive(Debug, Serialize)]
884pub struct OpenIdFinishRequest<'a> {
885 pub code: &'a str,
886 pub session_id: &'a str,
887 pub provider_id: i32,
888}
889
890#[derive(Debug, Deserialize)]
891pub struct PasskeySignInPreparation {
892 pub session_id: String,
893 pub options: serde_json::Value,
894}
895
896#[derive(Debug, Serialize)]
897pub struct PasskeySignInRequest<'a> {
898 pub response: &'a str,
899 pub session_id: &'a str,
900}
901
902#[derive(Debug, Deserialize)]
903pub struct LoginResponse {
904 pub user: NewUser,
905 pub token: Token,
906}
907
908#[derive(Debug, Serialize)]
909pub struct SearchUserRequest<'a> {
910 pub query: &'a str,
911 pub page: Option<u32>,
912 pub page_size: Option<u32>,
913}
914
915#[derive(Debug, Serialize)]
916pub struct UpdateUserSettingRequest<'a> {
917 pub key: &'a str,
918 pub value: &'a str,
919}
920
921#[derive(Debug, Serialize)]
922pub struct SetFilePermissionRequest<'a> {
923 pub uri: &'a str,
924 #[serde(skip_serializing_if = "Option::is_none")]
925 pub user_explicit: Option<serde_json::Value>,
926 #[serde(skip_serializing_if = "Option::is_none")]
927 pub group_explicit: Option<serde_json::Value>,
928 #[serde(skip_serializing_if = "Option::is_none")]
929 pub same_group: Option<&'a str>,
930 #[serde(skip_serializing_if = "Option::is_none")]
931 pub other: Option<&'a str>,
932 #[serde(skip_serializing_if = "Option::is_none")]
933 pub anonymous: Option<&'a str>,
934 #[serde(skip_serializing_if = "Option::is_none")]
935 pub everyone: Option<&'a str>,
936}
937
938#[derive(Debug, Serialize)]
939pub struct CreateUploadSessionRequest<'a> {
940 pub uri: &'a str,
942 pub size: u64,
944 pub policy_id: &'a str,
946 #[serde(skip_serializing_if = "Option::is_none")]
948 pub last_modified: Option<u64>,
949 #[serde(skip_serializing_if = "Option::is_none")]
951 pub mime_type: Option<&'a str>,
952 #[serde(skip_serializing_if = "Option::is_none")]
954 pub metadata: Option<std::collections::HashMap<String, String>>,
955 #[serde(skip_serializing_if = "Option::is_none")]
957 pub entity_type: Option<&'a str>,
958}
959
960#[derive(Debug, Deserialize)]
961pub struct UploadSessionResponse {
962 pub session_id: String,
963 #[serde(default)]
964 pub upload_id: Option<String>,
965 pub chunk_size: u64,
966 pub expires: u64,
967 #[serde(default)]
968 pub upload_urls: Option<Vec<String>>,
969 #[serde(default)]
970 pub credential: Option<String>,
971 #[serde(default)]
972 pub complete_url: Option<String>,
973 pub storage_policy: StoragePolicy,
974 #[serde(default)]
975 pub mime_type: Option<String>,
976 #[serde(default)]
977 pub upload_policy: Option<String>,
978}
979
980impl UploadSessionResponse {
981 pub fn total_chunks(&self, file_size: u64) -> u32 {
983 if self.chunk_size == 0 {
984 return 1;
985 }
986 file_size.div_ceil(self.chunk_size) as u32
987 }
988}
989
990#[derive(Debug, Serialize)]
991pub struct DeleteUploadSessionRequest<'a> {
992 pub id: &'a str,
994 pub uri: &'a str,
996}
997
998#[derive(Debug, Serialize)]
999pub struct MoveCopyFileRequest<'a> {
1000 pub from: Vec<&'a str>,
1001 pub to: &'a str,
1002 #[serde(skip_serializing_if = "Option::is_none")]
1003 pub copy: Option<bool>,
1004}
1005
1006#[derive(Debug, Serialize)]
1007pub struct UpdateFileContentRequest<'a> {
1008 pub uri: &'a str,
1009 pub content: &'a str,
1010}
1011
1012#[derive(Debug, Serialize)]
1013pub struct CreateViewerSessionRequest<'a> {
1014 pub uri: &'a str,
1015}
1016
1017#[derive(Debug, Deserialize)]
1018pub struct ViewerSessionResponse {
1019 pub session_id: String,
1020}
1021
1022#[derive(Debug, Serialize)]
1023pub struct CreateFileRequest<'a> {
1024 pub path: &'a str,
1025 pub name: &'a str,
1026 #[serde(skip_serializing_if = "Option::is_none")]
1027 pub content: Option<&'a str>,
1028 #[serde(skip_serializing_if = "Option::is_none")]
1029 pub overwrite: Option<bool>,
1030}
1031
1032#[derive(Debug, Serialize)]
1033pub struct RenameMultipleRequest<'a> {
1034 pub uris: Vec<&'a str>,
1035 pub names: Vec<&'a str>,
1036}
1037
1038#[derive(Debug, Serialize)]
1039pub struct CreateDownloadUrlRequest<'a> {
1040 pub uris: Vec<&'a str>,
1041 #[serde(skip_serializing_if = "Option::is_none")]
1042 pub download: Option<bool>,
1043 #[serde(skip_serializing_if = "Option::is_none")]
1044 pub redirect: Option<bool>,
1045 #[serde(skip_serializing_if = "Option::is_none")]
1046 pub entity: Option<&'a str>,
1047 #[serde(skip_serializing_if = "Option::is_none")]
1048 pub use_primary_site_url: Option<bool>,
1049 #[serde(skip_serializing_if = "Option::is_none")]
1050 pub skip_error: Option<bool>,
1051 #[serde(skip_serializing_if = "Option::is_none")]
1052 pub archive: Option<bool>,
1053 #[serde(skip_serializing_if = "Option::is_none")]
1054 pub no_cache: Option<bool>,
1055}
1056
1057#[derive(Debug, Deserialize)]
1058pub struct DownloadUrlResponse {
1059 pub urls: Vec<DownloadUrlItem>,
1060 pub expires: String,
1061}
1062
1063#[derive(Debug, Deserialize)]
1064pub struct DownloadUrlItem {
1065 pub url: String,
1066 #[serde(default)]
1067 pub stream_saver_display_name: Option<String>,
1068}
1069
1070#[derive(Debug, Serialize)]
1071pub struct RestoreFileRequest<'a> {
1072 pub uris: Vec<&'a str>,
1073}
1074
1075#[derive(Debug, Serialize)]
1076pub struct UpdateMetadataRequest {
1077 #[serde(skip_serializing_if = "Option::is_none")]
1078 pub metadata: Option<serde_json::Value>,
1079 #[serde(skip_serializing_if = "Option::is_none")]
1080 pub clear_metadata: Option<bool>,
1081}
1082
1083#[derive(Debug, Serialize)]
1084pub struct MountStoragePolicyRequest {
1085 pub policy_id: u64,
1086 #[serde(skip_serializing_if = "Option::is_none")]
1087 pub inherit_to_children: Option<bool>,
1088}
1089
1090#[derive(Debug, Serialize)]
1091pub struct UpdateViewRequest {
1092 #[serde(skip_serializing_if = "Option::is_none")]
1093 pub page_size: Option<i32>,
1094 #[serde(skip_serializing_if = "Option::is_none")]
1095 pub order: Option<String>,
1096 #[serde(skip_serializing_if = "Option::is_none")]
1097 pub order_direction: Option<String>,
1098 #[serde(skip_serializing_if = "Option::is_none")]
1099 pub view: Option<String>,
1100 #[serde(skip_serializing_if = "Option::is_none")]
1101 pub thumbnail: Option<bool>,
1102 #[serde(skip_serializing_if = "Option::is_none")]
1103 pub gallery_width: Option<i32>,
1104}
1105
1106#[derive(Debug, Serialize)]
1107pub struct GetFileInfoRequest<'a> {
1108 pub uri: &'a str,
1109 #[serde(skip_serializing_if = "Option::is_none")]
1110 pub include_extended_info: Option<bool>,
1111}
1112
1113#[derive(Debug, Serialize)]
1114pub struct GetArchiveListRequest<'a> {
1115 pub uri: &'a str,
1116}
1117
1118#[derive(Debug, Deserialize)]
1119pub struct ArchiveListResponse {
1120 pub files: Vec<ArchiveFileItem>,
1121}
1122
1123#[derive(Debug, Deserialize)]
1124pub struct ArchiveFileItem {
1125 pub name: String,
1126 pub size: u64,
1127 pub r#type: String,
1128 pub path: String,
1129}
1130
1131#[derive(Debug, Serialize)]
1132pub struct CreateDownloadRequest<'a> {
1133 pub url: &'a str,
1134 pub path: Option<&'a str>,
1135 pub node_id: Option<u64>,
1136}
1137
1138#[derive(Debug, Serialize)]
1139pub struct SelectDownloadFilesRequest<'a> {
1140 pub selected_files: Vec<&'a str>,
1141}
1142
1143#[derive(Debug, Serialize)]
1144pub struct RelocateRequest<'a> {
1145 pub files: Vec<&'a str>,
1146 pub target_policy_id: &'a str,
1147 pub path: Option<&'a str>,
1148}
1149
1150#[derive(Debug, Serialize)]
1151pub struct ImportRequest<'a> {
1152 pub source_url: &'a str,
1153 pub target_path: &'a str,
1154 pub node_id: Option<u64>,
1155}