cloudreve_api/api/v4/models/
task.rs1use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Serialize, Deserialize, Clone)]
7pub struct Task {
8 pub id: String,
9 pub name: String,
10 pub status: String,
11 pub created_at: String,
12 pub updated_at: String,
13}
14
15#[derive(Debug, Serialize, Deserialize, Clone)]
17pub struct TaskResponse {
18 pub created_at: String,
19 pub updated_at: String,
20 pub id: String,
21 pub status: TaskStatus,
22 pub r#type: TaskType,
23 pub summary: Option<TaskSummary>,
24 pub duration: Option<i64>,
25 pub resume_time: Option<i64>,
26 pub error: Option<String>,
27 pub error_history: Option<Vec<String>>,
28 pub retry_count: Option<i32>,
29 pub node: NewNode,
30}
31
32#[derive(Debug, Serialize, Deserialize, Clone)]
34pub enum TaskStatus {
35 #[serde(rename = "queued")]
36 Queued,
37 #[serde(rename = "processing")]
38 Processing,
39 #[serde(rename = "suspending")]
40 Suspending,
41 #[serde(rename = "error")]
42 Error,
43 #[serde(rename = "canceled")]
44 Canceled,
45 #[serde(rename = "completed")]
46 Completed,
47}
48
49#[derive(Debug, Serialize, Deserialize, Clone)]
51pub enum TaskType {
52 #[serde(rename = "media_meta")]
53 MediaMeta,
54 #[serde(rename = "entity_recycle_routine")]
55 EntityRecycleRoutine,
56 #[serde(rename = "explicit_entity_recycle")]
57 ExplicitEntityRecycle,
58 #[serde(rename = "upload_sentinel_check")]
59 UploadSentinelCheck,
60 #[serde(rename = "create_archive")]
61 CreateArchive,
62 #[serde(rename = "extract_archive")]
63 ExtractArchive,
64 #[serde(rename = "relocate")]
65 Relocate,
66 #[serde(rename = "remote_download")]
67 RemoteDownload,
68 #[serde(rename = "import")]
69 Import,
70}
71
72#[derive(Debug, Serialize, Deserialize, Clone)]
74pub struct TaskSummary {
75 pub phase: String,
76 pub props: serde_json::Value,
77}
78
79#[derive(Debug, Serialize, Deserialize, Clone)]
81pub struct NewNode {
82 pub id: String,
83 pub name: String,
84 pub r#type: NodeType,
85 pub capabilities: String,
86}
87
88#[derive(Debug, Serialize, Deserialize, Clone)]
90pub enum NodeType {
91 #[serde(rename = "master")]
92 Master,
93 #[serde(rename = "slave")]
94 Slave,
95}
96
97#[derive(Debug, Serialize, Deserialize, Clone)]
99pub struct TaskListResponse {
100 pub pagination: TaskPagination,
101 pub tasks: Vec<TaskResponse>,
102}
103
104#[derive(Debug, Serialize, Deserialize, Clone)]
106pub struct TaskPagination {
107 pub page_size: i32,
108 pub next_token: String,
109 pub is_cursor: bool,
110}
111
112#[derive(Debug, Serialize, Deserialize, Clone)]
114pub struct TaskProgress {
115 pub progress: f64,
116 pub message: String,
117 pub total: Option<u64>,
118 pub current: Option<u64>,
119}
120
121#[derive(Debug, Deserialize, Clone)]
123pub struct DetailedTask {
124 pub id: String,
125 pub name: String,
126 pub status: String,
127 pub type_: String,
128 pub created_at: String,
129 pub updated_at: String,
130 pub progress: Option<TaskProgress>,
131}
132
133#[derive(Debug, Serialize, Deserialize, Clone)]
135pub struct Progress {
136 pub total: i64,
137 pub current: i64,
138 pub identifier: Option<String>,
139}
140
141#[derive(Debug, Serialize, Deserialize, Clone)]
143pub struct Activity {
144 pub id: String,
145 pub content: LogEntry,
146 pub created_at: String,
147 pub user: Option<super::auth::NewUser>,
148 pub version_id: Option<String>,
149}
150
151#[derive(Debug, Serialize, Deserialize, Clone)]
153pub struct LogEntry {
154 pub r#type: String,
155 pub props: serde_json::Value,
156}
157
158#[derive(Debug, Serialize, Deserialize, Clone)]
160pub struct FileActivitiesResponse {
161 pub activities: Vec<Activity>,
162 pub pagination: ActivitiesPagination,
163}
164
165#[derive(Debug, Serialize, Deserialize, Clone)]
167pub struct ActivitiesPagination {
168 pub page: i32,
169 pub page_size: i32,
170 pub next_token: String,
171 pub is_cursor: bool,
172}
173
174#[derive(Debug, Serialize, Default)]
176pub struct ListTasksRequest<'a> {
177 pub page: Option<u32>,
178 pub per_page: Option<u32>,
179 pub status: Option<&'a str>,
180 pub type_: Option<&'a str>,
181}
182
183#[derive(Debug, Serialize)]
185pub struct CreateArchiveRequest<'a> {
186 pub files: Vec<&'a str>,
187 pub name: &'a str,
188 pub path: Option<&'a str>,
189}
190
191#[derive(Debug, Serialize)]
193pub struct ExtractArchiveRequest<'a> {
194 pub archive_uri: &'a str,
195 pub path: Option<&'a str>,
196}