1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17#[derive(Clone, Debug)]
19pub struct CreateRetentionParams {
20 pub policy: models::RetentionPolicy,
22 pub x_request_id: Option<String>
24}
25
26#[derive(Clone, Debug)]
28pub struct DeleteRetentionParams {
29 pub id: i64,
31 pub x_request_id: Option<String>
33}
34
35#[derive(Clone, Debug)]
37pub struct GetRentenitionMetadataParams {
38 pub x_request_id: Option<String>
40}
41
42#[derive(Clone, Debug)]
44pub struct GetRetentionParams {
45 pub id: i64,
47 pub x_request_id: Option<String>
49}
50
51#[derive(Clone, Debug)]
53pub struct GetRetentionTaskLogParams {
54 pub id: i64,
56 pub eid: i64,
58 pub tid: i64,
60 pub x_request_id: Option<String>
62}
63
64#[derive(Clone, Debug)]
66pub struct ListRetentionExecutionsParams {
67 pub id: i64,
69 pub x_request_id: Option<String>,
71 pub page: Option<i64>,
73 pub page_size: Option<i64>
75}
76
77#[derive(Clone, Debug)]
79pub struct ListRetentionTasksParams {
80 pub id: i64,
82 pub eid: i64,
84 pub x_request_id: Option<String>,
86 pub page: Option<i64>,
88 pub page_size: Option<i64>
90}
91
92#[derive(Clone, Debug)]
94pub struct OperateRetentionExecutionParams {
95 pub id: i64,
97 pub eid: i64,
99 pub body: models::OperateRetentionExecutionRequest,
101 pub x_request_id: Option<String>
103}
104
105#[derive(Clone, Debug)]
107pub struct TriggerRetentionExecutionParams {
108 pub id: i64,
110 pub body: models::TriggerRetentionExecutionRequest,
111 pub x_request_id: Option<String>
113}
114
115#[derive(Clone, Debug)]
117pub struct UpdateRetentionParams {
118 pub id: i64,
120 pub policy: models::RetentionPolicy,
121 pub x_request_id: Option<String>
123}
124
125
126#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum CreateRetentionError {
130 Status400(models::Errors),
131 Status401(models::Errors),
132 Status403(models::Errors),
133 Status500(models::Errors),
134 UnknownValue(serde_json::Value),
135}
136
137#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum DeleteRetentionError {
141 Status401(models::Errors),
142 Status403(models::Errors),
143 Status500(models::Errors),
144 UnknownValue(serde_json::Value),
145}
146
147#[derive(Debug, Clone, Serialize, Deserialize)]
149#[serde(untagged)]
150pub enum GetRentenitionMetadataError {
151 UnknownValue(serde_json::Value),
152}
153
154#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum GetRetentionError {
158 Status401(models::Errors),
159 Status403(models::Errors),
160 Status500(models::Errors),
161 UnknownValue(serde_json::Value),
162}
163
164#[derive(Debug, Clone, Serialize, Deserialize)]
166#[serde(untagged)]
167pub enum GetRetentionTaskLogError {
168 Status401(models::Errors),
169 Status403(models::Errors),
170 Status500(models::Errors),
171 UnknownValue(serde_json::Value),
172}
173
174#[derive(Debug, Clone, Serialize, Deserialize)]
176#[serde(untagged)]
177pub enum ListRetentionExecutionsError {
178 Status401(models::Errors),
179 Status403(models::Errors),
180 Status500(models::Errors),
181 UnknownValue(serde_json::Value),
182}
183
184#[derive(Debug, Clone, Serialize, Deserialize)]
186#[serde(untagged)]
187pub enum ListRetentionTasksError {
188 Status401(models::Errors),
189 Status403(models::Errors),
190 Status500(models::Errors),
191 UnknownValue(serde_json::Value),
192}
193
194#[derive(Debug, Clone, Serialize, Deserialize)]
196#[serde(untagged)]
197pub enum OperateRetentionExecutionError {
198 Status401(models::Errors),
199 Status403(models::Errors),
200 Status500(models::Errors),
201 UnknownValue(serde_json::Value),
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
206#[serde(untagged)]
207pub enum TriggerRetentionExecutionError {
208 Status401(models::Errors),
209 Status403(models::Errors),
210 Status500(models::Errors),
211 UnknownValue(serde_json::Value),
212}
213
214#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum UpdateRetentionError {
218 Status401(models::Errors),
219 Status403(models::Errors),
220 Status500(models::Errors),
221 UnknownValue(serde_json::Value),
222}
223
224
225pub async fn create_retention(configuration: &configuration::Configuration, params: CreateRetentionParams) -> Result<(), Error<CreateRetentionError>> {
227
228 let uri_str = format!("{}/retentions", configuration.base_path);
229 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
230
231 if let Some(ref user_agent) = configuration.user_agent {
232 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
233 }
234 if let Some(param_value) = params.x_request_id {
235 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
236 }
237 if let Some(ref auth_conf) = configuration.basic_auth {
238 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
239 };
240 req_builder = req_builder.json(¶ms.policy);
241
242 let req = req_builder.build()?;
243 let resp = configuration.client.execute(req).await?;
244
245 let status = resp.status();
246
247 if !status.is_client_error() && !status.is_server_error() {
248 Ok(())
249 } else {
250 let content = resp.text().await?;
251 let entity: Option<CreateRetentionError> = serde_json::from_str(&content).ok();
252 Err(Error::ResponseError(ResponseContent { status, content, entity }))
253 }
254}
255
256pub async fn delete_retention(configuration: &configuration::Configuration, params: DeleteRetentionParams) -> Result<(), Error<DeleteRetentionError>> {
258
259 let uri_str = format!("{}/retentions/{id}", configuration.base_path, id=params.id);
260 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
261
262 if let Some(ref user_agent) = configuration.user_agent {
263 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
264 }
265 if let Some(param_value) = params.x_request_id {
266 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
267 }
268 if let Some(ref auth_conf) = configuration.basic_auth {
269 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
270 };
271
272 let req = req_builder.build()?;
273 let resp = configuration.client.execute(req).await?;
274
275 let status = resp.status();
276
277 if !status.is_client_error() && !status.is_server_error() {
278 Ok(())
279 } else {
280 let content = resp.text().await?;
281 let entity: Option<DeleteRetentionError> = serde_json::from_str(&content).ok();
282 Err(Error::ResponseError(ResponseContent { status, content, entity }))
283 }
284}
285
286pub async fn get_rentenition_metadata(configuration: &configuration::Configuration, params: GetRentenitionMetadataParams) -> Result<models::RetentionMetadata, Error<GetRentenitionMetadataError>> {
288
289 let uri_str = format!("{}/retentions/metadatas", configuration.base_path);
290 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
291
292 if let Some(ref user_agent) = configuration.user_agent {
293 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
294 }
295 if let Some(param_value) = params.x_request_id {
296 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
297 }
298 if let Some(ref auth_conf) = configuration.basic_auth {
299 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
300 };
301
302 let req = req_builder.build()?;
303 let resp = configuration.client.execute(req).await?;
304
305 let status = resp.status();
306 let content_type = resp
307 .headers()
308 .get("content-type")
309 .and_then(|v| v.to_str().ok())
310 .unwrap_or("application/octet-stream");
311 let content_type = super::ContentType::from(content_type);
312
313 if !status.is_client_error() && !status.is_server_error() {
314 let content = resp.text().await?;
315 match content_type {
316 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
317 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RetentionMetadata`"))),
318 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RetentionMetadata`")))),
319 }
320 } else {
321 let content = resp.text().await?;
322 let entity: Option<GetRentenitionMetadataError> = serde_json::from_str(&content).ok();
323 Err(Error::ResponseError(ResponseContent { status, content, entity }))
324 }
325}
326
327pub async fn get_retention(configuration: &configuration::Configuration, params: GetRetentionParams) -> Result<models::RetentionPolicy, Error<GetRetentionError>> {
329
330 let uri_str = format!("{}/retentions/{id}", configuration.base_path, id=params.id);
331 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
332
333 if let Some(ref user_agent) = configuration.user_agent {
334 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
335 }
336 if let Some(param_value) = params.x_request_id {
337 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
338 }
339 if let Some(ref auth_conf) = configuration.basic_auth {
340 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
341 };
342
343 let req = req_builder.build()?;
344 let resp = configuration.client.execute(req).await?;
345
346 let status = resp.status();
347 let content_type = resp
348 .headers()
349 .get("content-type")
350 .and_then(|v| v.to_str().ok())
351 .unwrap_or("application/octet-stream");
352 let content_type = super::ContentType::from(content_type);
353
354 if !status.is_client_error() && !status.is_server_error() {
355 let content = resp.text().await?;
356 match content_type {
357 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
358 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RetentionPolicy`"))),
359 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RetentionPolicy`")))),
360 }
361 } else {
362 let content = resp.text().await?;
363 let entity: Option<GetRetentionError> = serde_json::from_str(&content).ok();
364 Err(Error::ResponseError(ResponseContent { status, content, entity }))
365 }
366}
367
368pub async fn get_retention_task_log(configuration: &configuration::Configuration, params: GetRetentionTaskLogParams) -> Result<String, Error<GetRetentionTaskLogError>> {
370
371 let uri_str = format!("{}/retentions/{id}/executions/{eid}/tasks/{tid}", configuration.base_path, id=params.id, eid=params.eid, tid=params.tid);
372 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
373
374 if let Some(ref user_agent) = configuration.user_agent {
375 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
376 }
377 if let Some(param_value) = params.x_request_id {
378 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
379 }
380 if let Some(ref auth_conf) = configuration.basic_auth {
381 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
382 };
383
384 let req = req_builder.build()?;
385 let resp = configuration.client.execute(req).await?;
386
387 let status = resp.status();
388 let content_type = resp
389 .headers()
390 .get("content-type")
391 .and_then(|v| v.to_str().ok())
392 .unwrap_or("application/octet-stream");
393 let content_type = super::ContentType::from(content_type);
394
395 if !status.is_client_error() && !status.is_server_error() {
396 let content = resp.text().await?;
397 match content_type {
398 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
399 ContentType::Text => return Ok(content),
400 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
401 }
402 } else {
403 let content = resp.text().await?;
404 let entity: Option<GetRetentionTaskLogError> = serde_json::from_str(&content).ok();
405 Err(Error::ResponseError(ResponseContent { status, content, entity }))
406 }
407}
408
409pub async fn list_retention_executions(configuration: &configuration::Configuration, params: ListRetentionExecutionsParams) -> Result<Vec<models::RetentionExecution>, Error<ListRetentionExecutionsError>> {
411
412 let uri_str = format!("{}/retentions/{id}/executions", configuration.base_path, id=params.id);
413 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
414
415 if let Some(ref param_value) = params.page {
416 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
417 }
418 if let Some(ref param_value) = params.page_size {
419 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
420 }
421 if let Some(ref user_agent) = configuration.user_agent {
422 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
423 }
424 if let Some(param_value) = params.x_request_id {
425 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
426 }
427 if let Some(ref auth_conf) = configuration.basic_auth {
428 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
429 };
430
431 let req = req_builder.build()?;
432 let resp = configuration.client.execute(req).await?;
433
434 let status = resp.status();
435 let content_type = resp
436 .headers()
437 .get("content-type")
438 .and_then(|v| v.to_str().ok())
439 .unwrap_or("application/octet-stream");
440 let content_type = super::ContentType::from(content_type);
441
442 if !status.is_client_error() && !status.is_server_error() {
443 let content = resp.text().await?;
444 match content_type {
445 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
446 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::RetentionExecution>`"))),
447 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::RetentionExecution>`")))),
448 }
449 } else {
450 let content = resp.text().await?;
451 let entity: Option<ListRetentionExecutionsError> = serde_json::from_str(&content).ok();
452 Err(Error::ResponseError(ResponseContent { status, content, entity }))
453 }
454}
455
456pub async fn list_retention_tasks(configuration: &configuration::Configuration, params: ListRetentionTasksParams) -> Result<Vec<models::RetentionExecutionTask>, Error<ListRetentionTasksError>> {
458
459 let uri_str = format!("{}/retentions/{id}/executions/{eid}/tasks", configuration.base_path, id=params.id, eid=params.eid);
460 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
461
462 if let Some(ref param_value) = params.page {
463 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
464 }
465 if let Some(ref param_value) = params.page_size {
466 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
467 }
468 if let Some(ref user_agent) = configuration.user_agent {
469 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
470 }
471 if let Some(param_value) = params.x_request_id {
472 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
473 }
474 if let Some(ref auth_conf) = configuration.basic_auth {
475 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
476 };
477
478 let req = req_builder.build()?;
479 let resp = configuration.client.execute(req).await?;
480
481 let status = resp.status();
482 let content_type = resp
483 .headers()
484 .get("content-type")
485 .and_then(|v| v.to_str().ok())
486 .unwrap_or("application/octet-stream");
487 let content_type = super::ContentType::from(content_type);
488
489 if !status.is_client_error() && !status.is_server_error() {
490 let content = resp.text().await?;
491 match content_type {
492 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
493 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::RetentionExecutionTask>`"))),
494 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::RetentionExecutionTask>`")))),
495 }
496 } else {
497 let content = resp.text().await?;
498 let entity: Option<ListRetentionTasksError> = serde_json::from_str(&content).ok();
499 Err(Error::ResponseError(ResponseContent { status, content, entity }))
500 }
501}
502
503pub async fn operate_retention_execution(configuration: &configuration::Configuration, params: OperateRetentionExecutionParams) -> Result<(), Error<OperateRetentionExecutionError>> {
505
506 let uri_str = format!("{}/retentions/{id}/executions/{eid}", configuration.base_path, id=params.id, eid=params.eid);
507 let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
508
509 if let Some(ref user_agent) = configuration.user_agent {
510 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
511 }
512 if let Some(param_value) = params.x_request_id {
513 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
514 }
515 if let Some(ref auth_conf) = configuration.basic_auth {
516 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
517 };
518 req_builder = req_builder.json(¶ms.body);
519
520 let req = req_builder.build()?;
521 let resp = configuration.client.execute(req).await?;
522
523 let status = resp.status();
524
525 if !status.is_client_error() && !status.is_server_error() {
526 Ok(())
527 } else {
528 let content = resp.text().await?;
529 let entity: Option<OperateRetentionExecutionError> = serde_json::from_str(&content).ok();
530 Err(Error::ResponseError(ResponseContent { status, content, entity }))
531 }
532}
533
534pub async fn trigger_retention_execution(configuration: &configuration::Configuration, params: TriggerRetentionExecutionParams) -> Result<(), Error<TriggerRetentionExecutionError>> {
536
537 let uri_str = format!("{}/retentions/{id}/executions", configuration.base_path, id=params.id);
538 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
539
540 if let Some(ref user_agent) = configuration.user_agent {
541 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
542 }
543 if let Some(param_value) = params.x_request_id {
544 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
545 }
546 if let Some(ref auth_conf) = configuration.basic_auth {
547 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
548 };
549 req_builder = req_builder.json(¶ms.body);
550
551 let req = req_builder.build()?;
552 let resp = configuration.client.execute(req).await?;
553
554 let status = resp.status();
555
556 if !status.is_client_error() && !status.is_server_error() {
557 Ok(())
558 } else {
559 let content = resp.text().await?;
560 let entity: Option<TriggerRetentionExecutionError> = serde_json::from_str(&content).ok();
561 Err(Error::ResponseError(ResponseContent { status, content, entity }))
562 }
563}
564
565pub async fn update_retention(configuration: &configuration::Configuration, params: UpdateRetentionParams) -> Result<(), Error<UpdateRetentionError>> {
567
568 let uri_str = format!("{}/retentions/{id}", configuration.base_path, id=params.id);
569 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
570
571 if let Some(ref user_agent) = configuration.user_agent {
572 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
573 }
574 if let Some(param_value) = params.x_request_id {
575 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
576 }
577 if let Some(ref auth_conf) = configuration.basic_auth {
578 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
579 };
580 req_builder = req_builder.json(¶ms.policy);
581
582 let req = req_builder.build()?;
583 let resp = configuration.client.execute(req).await?;
584
585 let status = resp.status();
586
587 if !status.is_client_error() && !status.is_server_error() {
588 Ok(())
589 } else {
590 let content = resp.text().await?;
591 let entity: Option<UpdateRetentionError> = serde_json::from_str(&content).ok();
592 Err(Error::ResponseError(ResponseContent { status, content, entity }))
593 }
594}
595