1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum AllowedActionsError {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum Delete6Error {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum FindById7Error {
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum FindNext10TasksError {
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum GetError {
48 UnknownValue(serde_json::Value),
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum GetActionResultsError {
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum SaveError {
62 UnknownValue(serde_json::Value),
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum ValidateCronExpressionError {
69 UnknownValue(serde_json::Value),
70}
71
72pub async fn allowed_actions(
73 configuration: &configuration::Configuration,
74) -> Result<Vec<models::ActionMetadata>, Error<AllowedActionsError>> {
75 let uri_str = format!(
76 "{}/api/reminder-task/allowed-actions",
77 configuration.base_path
78 );
79 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
80
81 if let Some(ref user_agent) = configuration.user_agent {
82 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
83 }
84 if let Some(ref token) = configuration.bearer_access_token {
85 req_builder = req_builder.bearer_auth(token.to_owned());
86 };
87
88 let req = req_builder.build()?;
89 let resp = configuration.client.execute(req).await?;
90
91 let status = resp.status();
92 let content_type = resp
93 .headers()
94 .get("content-type")
95 .and_then(|v| v.to_str().ok())
96 .unwrap_or("application/octet-stream");
97 let content_type = super::ContentType::from(content_type);
98
99 if !status.is_client_error() && !status.is_server_error() {
100 let content = resp.text().await?;
101 match content_type {
102 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
103 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ActionMetadata>`"))),
104 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::ActionMetadata>`")))),
105 }
106 } else {
107 let content = resp.text().await?;
108 let entity: Option<AllowedActionsError> = serde_json::from_str(&content).ok();
109 Err(Error::ResponseError(ResponseContent {
110 status,
111 content,
112 entity,
113 }))
114 }
115}
116
117pub async fn delete6(
118 configuration: &configuration::Configuration,
119 id: &str,
120) -> Result<(), Error<Delete6Error>> {
121 let p_query_id = id;
123
124 let uri_str = format!("{}/api/reminder-task", configuration.base_path);
125 let mut req_builder = configuration
126 .client
127 .request(reqwest::Method::DELETE, &uri_str);
128
129 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
130 if let Some(ref user_agent) = configuration.user_agent {
131 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
132 }
133 if let Some(ref token) = configuration.bearer_access_token {
134 req_builder = req_builder.bearer_auth(token.to_owned());
135 };
136
137 let req = req_builder.build()?;
138 let resp = configuration.client.execute(req).await?;
139
140 let status = resp.status();
141
142 if !status.is_client_error() && !status.is_server_error() {
143 Ok(())
144 } else {
145 let content = resp.text().await?;
146 let entity: Option<Delete6Error> = serde_json::from_str(&content).ok();
147 Err(Error::ResponseError(ResponseContent {
148 status,
149 content,
150 entity,
151 }))
152 }
153}
154
155pub async fn find_by_id7(
156 configuration: &configuration::Configuration,
157 id: &str,
158) -> Result<models::ReminderTask, Error<FindById7Error>> {
159 let p_query_id = id;
161
162 let uri_str = format!("{}/api/reminder-task/find-by-id", configuration.base_path);
163 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
164
165 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
166 if let Some(ref user_agent) = configuration.user_agent {
167 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
168 }
169 if let Some(ref token) = configuration.bearer_access_token {
170 req_builder = req_builder.bearer_auth(token.to_owned());
171 };
172
173 let req = req_builder.build()?;
174 let resp = configuration.client.execute(req).await?;
175
176 let status = resp.status();
177 let content_type = resp
178 .headers()
179 .get("content-type")
180 .and_then(|v| v.to_str().ok())
181 .unwrap_or("application/octet-stream");
182 let content_type = super::ContentType::from(content_type);
183
184 if !status.is_client_error() && !status.is_server_error() {
185 let content = resp.text().await?;
186 match content_type {
187 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
188 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReminderTask`"))),
189 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ReminderTask`")))),
190 }
191 } else {
192 let content = resp.text().await?;
193 let entity: Option<FindById7Error> = serde_json::from_str(&content).ok();
194 Err(Error::ResponseError(ResponseContent {
195 status,
196 content,
197 entity,
198 }))
199 }
200}
201
202pub async fn find_next10_tasks(
203 configuration: &configuration::Configuration,
204) -> Result<Vec<models::ReminderTask>, Error<FindNext10TasksError>> {
205 let uri_str = format!(
206 "{}/api/reminder-task/find-next-ten-tasks",
207 configuration.base_path
208 );
209 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
210
211 if let Some(ref user_agent) = configuration.user_agent {
212 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
213 }
214 if let Some(ref token) = configuration.bearer_access_token {
215 req_builder = req_builder.bearer_auth(token.to_owned());
216 };
217
218 let req = req_builder.build()?;
219 let resp = configuration.client.execute(req).await?;
220
221 let status = resp.status();
222 let content_type = resp
223 .headers()
224 .get("content-type")
225 .and_then(|v| v.to_str().ok())
226 .unwrap_or("application/octet-stream");
227 let content_type = super::ContentType::from(content_type);
228
229 if !status.is_client_error() && !status.is_server_error() {
230 let content = resp.text().await?;
231 match content_type {
232 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
233 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ReminderTask>`"))),
234 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::ReminderTask>`")))),
235 }
236 } else {
237 let content = resp.text().await?;
238 let entity: Option<FindNext10TasksError> = serde_json::from_str(&content).ok();
239 Err(Error::ResponseError(ResponseContent {
240 status,
241 content,
242 entity,
243 }))
244 }
245}
246
247pub async fn get(
248 configuration: &configuration::Configuration,
249) -> Result<Vec<models::ReminderTask>, Error<GetError>> {
250 let uri_str = format!("{}/api/reminder-task/find-all", configuration.base_path);
251 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
252
253 if let Some(ref user_agent) = configuration.user_agent {
254 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
255 }
256 if let Some(ref token) = configuration.bearer_access_token {
257 req_builder = req_builder.bearer_auth(token.to_owned());
258 };
259
260 let req = req_builder.build()?;
261 let resp = configuration.client.execute(req).await?;
262
263 let status = resp.status();
264 let content_type = resp
265 .headers()
266 .get("content-type")
267 .and_then(|v| v.to_str().ok())
268 .unwrap_or("application/octet-stream");
269 let content_type = super::ContentType::from(content_type);
270
271 if !status.is_client_error() && !status.is_server_error() {
272 let content = resp.text().await?;
273 match content_type {
274 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
275 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ReminderTask>`"))),
276 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::ReminderTask>`")))),
277 }
278 } else {
279 let content = resp.text().await?;
280 let entity: Option<GetError> = serde_json::from_str(&content).ok();
281 Err(Error::ResponseError(ResponseContent {
282 status,
283 content,
284 entity,
285 }))
286 }
287}
288
289pub async fn get_action_results(
290 configuration: &configuration::Configuration,
291 key: &str,
292 arg1: models::Pageable,
293) -> Result<models::PagedModelActionResult, Error<GetActionResultsError>> {
294 let p_query_key = key;
296 let p_query_arg1 = arg1;
297
298 let uri_str = format!(
299 "{}/api/reminder-task/action-results",
300 configuration.base_path
301 );
302 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
303
304 req_builder = req_builder.query(&[("key", &p_query_key.to_string())]);
305 req_builder = req_builder.query(&[("arg1", &p_query_arg1.to_string())]);
306 if let Some(ref user_agent) = configuration.user_agent {
307 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
308 }
309 if let Some(ref token) = configuration.bearer_access_token {
310 req_builder = req_builder.bearer_auth(token.to_owned());
311 };
312
313 let req = req_builder.build()?;
314 let resp = configuration.client.execute(req).await?;
315
316 let status = resp.status();
317 let content_type = resp
318 .headers()
319 .get("content-type")
320 .and_then(|v| v.to_str().ok())
321 .unwrap_or("application/octet-stream");
322 let content_type = super::ContentType::from(content_type);
323
324 if !status.is_client_error() && !status.is_server_error() {
325 let content = resp.text().await?;
326 match content_type {
327 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
328 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagedModelActionResult`"))),
329 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PagedModelActionResult`")))),
330 }
331 } else {
332 let content = resp.text().await?;
333 let entity: Option<GetActionResultsError> = serde_json::from_str(&content).ok();
334 Err(Error::ResponseError(ResponseContent {
335 status,
336 content,
337 entity,
338 }))
339 }
340}
341
342pub async fn save(
343 configuration: &configuration::Configuration,
344 reminder_task: models::ReminderTask,
345) -> Result<(), Error<SaveError>> {
346 let p_body_reminder_task = reminder_task;
348
349 let uri_str = format!("{}/api/reminder-task/save", configuration.base_path);
350 let mut req_builder = configuration
351 .client
352 .request(reqwest::Method::POST, &uri_str);
353
354 if let Some(ref user_agent) = configuration.user_agent {
355 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
356 }
357 if let Some(ref token) = configuration.bearer_access_token {
358 req_builder = req_builder.bearer_auth(token.to_owned());
359 };
360 req_builder = req_builder.json(&p_body_reminder_task);
361
362 let req = req_builder.build()?;
363 let resp = configuration.client.execute(req).await?;
364
365 let status = resp.status();
366
367 if !status.is_client_error() && !status.is_server_error() {
368 Ok(())
369 } else {
370 let content = resp.text().await?;
371 let entity: Option<SaveError> = serde_json::from_str(&content).ok();
372 Err(Error::ResponseError(ResponseContent {
373 status,
374 content,
375 entity,
376 }))
377 }
378}
379
380pub async fn validate_cron_expression(
381 configuration: &configuration::Configuration,
382 cron_expression: &str,
383) -> Result<models::ValidateCronExpression200Response, Error<ValidateCronExpressionError>> {
384 let p_query_cron_expression = cron_expression;
386
387 let uri_str = format!(
388 "{}/api/reminder-task/validate-cron-expression",
389 configuration.base_path
390 );
391 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
392
393 req_builder = req_builder.query(&[("cronExpression", &p_query_cron_expression.to_string())]);
394 if let Some(ref user_agent) = configuration.user_agent {
395 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
396 }
397 if let Some(ref token) = configuration.bearer_access_token {
398 req_builder = req_builder.bearer_auth(token.to_owned());
399 };
400
401 let req = req_builder.build()?;
402 let resp = configuration.client.execute(req).await?;
403
404 let status = resp.status();
405 let content_type = resp
406 .headers()
407 .get("content-type")
408 .and_then(|v| v.to_str().ok())
409 .unwrap_or("application/octet-stream");
410 let content_type = super::ContentType::from(content_type);
411
412 if !status.is_client_error() && !status.is_server_error() {
413 let content = resp.text().await?;
414 match content_type {
415 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
416 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ValidateCronExpression200Response`"))),
417 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ValidateCronExpression200Response`")))),
418 }
419 } else {
420 let content = resp.text().await?;
421 let entity: Option<ValidateCronExpressionError> = serde_json::from_str(&content).ok();
422 Err(Error::ResponseError(ResponseContent {
423 status,
424 content,
425 entity,
426 }))
427 }
428}