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 CreatePurgeScheduleParams {
20 pub schedule: models::Schedule,
22 pub x_request_id: Option<String>
24}
25
26#[derive(Clone, Debug)]
28pub struct GetPurgeHistoryParams {
29 pub x_request_id: Option<String>,
31 pub q: Option<String>,
33 pub sort: Option<String>,
35 pub page: Option<i64>,
37 pub page_size: Option<i64>
39}
40
41#[derive(Clone, Debug)]
43pub struct GetPurgeJobParams {
44 pub purge_id: i64,
46 pub x_request_id: Option<String>
48}
49
50#[derive(Clone, Debug)]
52pub struct GetPurgeJobLogParams {
53 pub purge_id: i64,
55 pub x_request_id: Option<String>
57}
58
59#[derive(Clone, Debug)]
61pub struct GetPurgeScheduleParams {
62 pub x_request_id: Option<String>
64}
65
66#[derive(Clone, Debug)]
68pub struct StopPurgeParams {
69 pub purge_id: i64,
71 pub x_request_id: Option<String>
73}
74
75#[derive(Clone, Debug)]
77pub struct UpdatePurgeScheduleParams {
78 pub schedule: models::Schedule,
80 pub x_request_id: Option<String>
82}
83
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum CreatePurgeScheduleError {
89 Status400(models::Errors),
90 Status401(models::Errors),
91 Status403(models::Errors),
92 Status500(models::Errors),
93 UnknownValue(serde_json::Value),
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum GetPurgeHistoryError {
100 Status401(models::Errors),
101 Status403(models::Errors),
102 Status500(models::Errors),
103 UnknownValue(serde_json::Value),
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum GetPurgeJobError {
110 Status401(models::Errors),
111 Status403(models::Errors),
112 Status404(models::Errors),
113 Status500(models::Errors),
114 UnknownValue(serde_json::Value),
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum GetPurgeJobLogError {
121 Status400(models::Errors),
122 Status401(models::Errors),
123 Status403(models::Errors),
124 Status404(models::Errors),
125 Status500(models::Errors),
126 UnknownValue(serde_json::Value),
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum GetPurgeScheduleError {
133 Status401(models::Errors),
134 Status403(models::Errors),
135 Status500(models::Errors),
136 UnknownValue(serde_json::Value),
137}
138
139#[derive(Debug, Clone, Serialize, Deserialize)]
141#[serde(untagged)]
142pub enum StopPurgeError {
143 Status401(models::Errors),
144 Status403(models::Errors),
145 Status404(models::Errors),
146 Status500(models::Errors),
147 UnknownValue(serde_json::Value),
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize)]
152#[serde(untagged)]
153pub enum UpdatePurgeScheduleError {
154 Status400(models::Errors),
155 Status401(models::Errors),
156 Status403(models::Errors),
157 Status500(models::Errors),
158 UnknownValue(serde_json::Value),
159}
160
161
162pub async fn create_purge_schedule(configuration: &configuration::Configuration, params: CreatePurgeScheduleParams) -> Result<(), Error<CreatePurgeScheduleError>> {
164
165 let uri_str = format!("{}/system/purgeaudit/schedule", configuration.base_path);
166 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
167
168 if let Some(ref user_agent) = configuration.user_agent {
169 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
170 }
171 if let Some(param_value) = params.x_request_id {
172 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
173 }
174 if let Some(ref auth_conf) = configuration.basic_auth {
175 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
176 };
177 req_builder = req_builder.json(¶ms.schedule);
178
179 let req = req_builder.build()?;
180 let resp = configuration.client.execute(req).await?;
181
182 let status = resp.status();
183
184 if !status.is_client_error() && !status.is_server_error() {
185 Ok(())
186 } else {
187 let content = resp.text().await?;
188 let entity: Option<CreatePurgeScheduleError> = serde_json::from_str(&content).ok();
189 Err(Error::ResponseError(ResponseContent { status, content, entity }))
190 }
191}
192
193pub async fn get_purge_history(configuration: &configuration::Configuration, params: GetPurgeHistoryParams) -> Result<Vec<models::ExecHistory>, Error<GetPurgeHistoryError>> {
195
196 let uri_str = format!("{}/system/purgeaudit", configuration.base_path);
197 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
198
199 if let Some(ref param_value) = params.q {
200 req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
201 }
202 if let Some(ref param_value) = params.sort {
203 req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
204 }
205 if let Some(ref param_value) = params.page {
206 req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
207 }
208 if let Some(ref param_value) = params.page_size {
209 req_builder = req_builder.query(&[("page_size", ¶m_value.to_string())]);
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(param_value) = params.x_request_id {
215 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
216 }
217 if let Some(ref auth_conf) = configuration.basic_auth {
218 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
219 };
220
221 let req = req_builder.build()?;
222 let resp = configuration.client.execute(req).await?;
223
224 let status = resp.status();
225 let content_type = resp
226 .headers()
227 .get("content-type")
228 .and_then(|v| v.to_str().ok())
229 .unwrap_or("application/octet-stream");
230 let content_type = super::ContentType::from(content_type);
231
232 if !status.is_client_error() && !status.is_server_error() {
233 let content = resp.text().await?;
234 match content_type {
235 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
236 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::ExecHistory>`"))),
237 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::ExecHistory>`")))),
238 }
239 } else {
240 let content = resp.text().await?;
241 let entity: Option<GetPurgeHistoryError> = serde_json::from_str(&content).ok();
242 Err(Error::ResponseError(ResponseContent { status, content, entity }))
243 }
244}
245
246pub async fn get_purge_job(configuration: &configuration::Configuration, params: GetPurgeJobParams) -> Result<models::ExecHistory, Error<GetPurgeJobError>> {
248
249 let uri_str = format!("{}/system/purgeaudit/{purge_id}", configuration.base_path, purge_id=params.purge_id);
250 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
251
252 if let Some(ref user_agent) = configuration.user_agent {
253 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
254 }
255 if let Some(param_value) = params.x_request_id {
256 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
257 }
258 if let Some(ref auth_conf) = configuration.basic_auth {
259 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
260 };
261
262 let req = req_builder.build()?;
263 let resp = configuration.client.execute(req).await?;
264
265 let status = resp.status();
266 let content_type = resp
267 .headers()
268 .get("content-type")
269 .and_then(|v| v.to_str().ok())
270 .unwrap_or("application/octet-stream");
271 let content_type = super::ContentType::from(content_type);
272
273 if !status.is_client_error() && !status.is_server_error() {
274 let content = resp.text().await?;
275 match content_type {
276 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
277 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExecHistory`"))),
278 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::ExecHistory`")))),
279 }
280 } else {
281 let content = resp.text().await?;
282 let entity: Option<GetPurgeJobError> = serde_json::from_str(&content).ok();
283 Err(Error::ResponseError(ResponseContent { status, content, entity }))
284 }
285}
286
287pub async fn get_purge_job_log(configuration: &configuration::Configuration, params: GetPurgeJobLogParams) -> Result<String, Error<GetPurgeJobLogError>> {
289
290 let uri_str = format!("{}/system/purgeaudit/{purge_id}/log", configuration.base_path, purge_id=params.purge_id);
291 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
292
293 if let Some(ref user_agent) = configuration.user_agent {
294 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
295 }
296 if let Some(param_value) = params.x_request_id {
297 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
298 }
299 if let Some(ref auth_conf) = configuration.basic_auth {
300 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
301 };
302
303 let req = req_builder.build()?;
304 let resp = configuration.client.execute(req).await?;
305
306 let status = resp.status();
307 let content_type = resp
308 .headers()
309 .get("content-type")
310 .and_then(|v| v.to_str().ok())
311 .unwrap_or("application/octet-stream");
312 let content_type = super::ContentType::from(content_type);
313
314 if !status.is_client_error() && !status.is_server_error() {
315 let content = resp.text().await?;
316 match content_type {
317 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
318 ContentType::Text => return Ok(content),
319 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`")))),
320 }
321 } else {
322 let content = resp.text().await?;
323 let entity: Option<GetPurgeJobLogError> = serde_json::from_str(&content).ok();
324 Err(Error::ResponseError(ResponseContent { status, content, entity }))
325 }
326}
327
328pub async fn get_purge_schedule(configuration: &configuration::Configuration, params: GetPurgeScheduleParams) -> Result<models::ExecHistory, Error<GetPurgeScheduleError>> {
330
331 let uri_str = format!("{}/system/purgeaudit/schedule", configuration.base_path);
332 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
333
334 if let Some(ref user_agent) = configuration.user_agent {
335 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
336 }
337 if let Some(param_value) = params.x_request_id {
338 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
339 }
340 if let Some(ref auth_conf) = configuration.basic_auth {
341 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
342 };
343
344 let req = req_builder.build()?;
345 let resp = configuration.client.execute(req).await?;
346
347 let status = resp.status();
348 let content_type = resp
349 .headers()
350 .get("content-type")
351 .and_then(|v| v.to_str().ok())
352 .unwrap_or("application/octet-stream");
353 let content_type = super::ContentType::from(content_type);
354
355 if !status.is_client_error() && !status.is_server_error() {
356 let content = resp.text().await?;
357 match content_type {
358 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
359 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExecHistory`"))),
360 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::ExecHistory`")))),
361 }
362 } else {
363 let content = resp.text().await?;
364 let entity: Option<GetPurgeScheduleError> = serde_json::from_str(&content).ok();
365 Err(Error::ResponseError(ResponseContent { status, content, entity }))
366 }
367}
368
369pub async fn stop_purge(configuration: &configuration::Configuration, params: StopPurgeParams) -> Result<(), Error<StopPurgeError>> {
371
372 let uri_str = format!("{}/system/purgeaudit/{purge_id}", configuration.base_path, purge_id=params.purge_id);
373 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
374
375 if let Some(ref user_agent) = configuration.user_agent {
376 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
377 }
378 if let Some(param_value) = params.x_request_id {
379 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
380 }
381 if let Some(ref auth_conf) = configuration.basic_auth {
382 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
383 };
384
385 let req = req_builder.build()?;
386 let resp = configuration.client.execute(req).await?;
387
388 let status = resp.status();
389
390 if !status.is_client_error() && !status.is_server_error() {
391 Ok(())
392 } else {
393 let content = resp.text().await?;
394 let entity: Option<StopPurgeError> = serde_json::from_str(&content).ok();
395 Err(Error::ResponseError(ResponseContent { status, content, entity }))
396 }
397}
398
399pub async fn update_purge_schedule(configuration: &configuration::Configuration, params: UpdatePurgeScheduleParams) -> Result<(), Error<UpdatePurgeScheduleError>> {
401
402 let uri_str = format!("{}/system/purgeaudit/schedule", configuration.base_path);
403 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
404
405 if let Some(ref user_agent) = configuration.user_agent {
406 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
407 }
408 if let Some(param_value) = params.x_request_id {
409 req_builder = req_builder.header("X-Request-Id", param_value.to_string());
410 }
411 if let Some(ref auth_conf) = configuration.basic_auth {
412 req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
413 };
414 req_builder = req_builder.json(¶ms.schedule);
415
416 let req = req_builder.build()?;
417 let resp = configuration.client.execute(req).await?;
418
419 let status = resp.status();
420
421 if !status.is_client_error() && !status.is_server_error() {
422 Ok(())
423 } else {
424 let content = resp.text().await?;
425 let entity: Option<UpdatePurgeScheduleError> = serde_json::from_str(&content).ok();
426 Err(Error::ResponseError(ResponseContent { status, content, entity }))
427 }
428}
429