1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CancelReportError {
22 Status400(models::reports_2021_06_30::ErrorList),
23 Status401(models::reports_2021_06_30::ErrorList),
24 Status403(models::reports_2021_06_30::ErrorList),
25 Status404(models::reports_2021_06_30::ErrorList),
26 Status415(models::reports_2021_06_30::ErrorList),
27 Status429(models::reports_2021_06_30::ErrorList),
28 Status500(models::reports_2021_06_30::ErrorList),
29 Status503(models::reports_2021_06_30::ErrorList),
30 UnknownValue(serde_json::Value),
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum CancelReportScheduleError {
37 Status400(models::reports_2021_06_30::ErrorList),
38 Status401(models::reports_2021_06_30::ErrorList),
39 Status403(models::reports_2021_06_30::ErrorList),
40 Status404(models::reports_2021_06_30::ErrorList),
41 Status415(models::reports_2021_06_30::ErrorList),
42 Status429(models::reports_2021_06_30::ErrorList),
43 Status500(models::reports_2021_06_30::ErrorList),
44 Status503(models::reports_2021_06_30::ErrorList),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum CreateReportError {
52 Status400(models::reports_2021_06_30::ErrorList),
53 Status401(models::reports_2021_06_30::ErrorList),
54 Status403(models::reports_2021_06_30::ErrorList),
55 Status404(models::reports_2021_06_30::ErrorList),
56 Status415(models::reports_2021_06_30::ErrorList),
57 Status429(models::reports_2021_06_30::ErrorList),
58 Status500(models::reports_2021_06_30::ErrorList),
59 Status503(models::reports_2021_06_30::ErrorList),
60 UnknownValue(serde_json::Value),
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum CreateReportScheduleError {
67 Status400(models::reports_2021_06_30::ErrorList),
68 Status401(models::reports_2021_06_30::ErrorList),
69 Status403(models::reports_2021_06_30::ErrorList),
70 Status404(models::reports_2021_06_30::ErrorList),
71 Status415(models::reports_2021_06_30::ErrorList),
72 Status429(models::reports_2021_06_30::ErrorList),
73 Status500(models::reports_2021_06_30::ErrorList),
74 Status503(models::reports_2021_06_30::ErrorList),
75 UnknownValue(serde_json::Value),
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum GetReportError {
82 Status400(models::reports_2021_06_30::ErrorList),
83 Status401(models::reports_2021_06_30::ErrorList),
84 Status403(models::reports_2021_06_30::ErrorList),
85 Status404(models::reports_2021_06_30::ErrorList),
86 Status415(models::reports_2021_06_30::ErrorList),
87 Status429(models::reports_2021_06_30::ErrorList),
88 Status500(models::reports_2021_06_30::ErrorList),
89 Status503(models::reports_2021_06_30::ErrorList),
90 UnknownValue(serde_json::Value),
91}
92
93#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum GetReportDocumentError {
97 Status400(models::reports_2021_06_30::ErrorList),
98 Status401(models::reports_2021_06_30::ErrorList),
99 Status403(models::reports_2021_06_30::ErrorList),
100 Status404(models::reports_2021_06_30::ErrorList),
101 Status415(models::reports_2021_06_30::ErrorList),
102 Status429(models::reports_2021_06_30::ErrorList),
103 Status500(models::reports_2021_06_30::ErrorList),
104 Status503(models::reports_2021_06_30::ErrorList),
105 UnknownValue(serde_json::Value),
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum GetReportScheduleError {
112 Status400(models::reports_2021_06_30::ErrorList),
113 Status401(models::reports_2021_06_30::ErrorList),
114 Status403(models::reports_2021_06_30::ErrorList),
115 Status404(models::reports_2021_06_30::ErrorList),
116 Status415(models::reports_2021_06_30::ErrorList),
117 Status429(models::reports_2021_06_30::ErrorList),
118 Status500(models::reports_2021_06_30::ErrorList),
119 Status503(models::reports_2021_06_30::ErrorList),
120 UnknownValue(serde_json::Value),
121}
122
123#[derive(Debug, Clone, Serialize, Deserialize)]
125#[serde(untagged)]
126pub enum GetReportSchedulesError {
127 Status400(models::reports_2021_06_30::ErrorList),
128 Status401(models::reports_2021_06_30::ErrorList),
129 Status403(models::reports_2021_06_30::ErrorList),
130 Status404(models::reports_2021_06_30::ErrorList),
131 Status415(models::reports_2021_06_30::ErrorList),
132 Status429(models::reports_2021_06_30::ErrorList),
133 Status500(models::reports_2021_06_30::ErrorList),
134 Status503(models::reports_2021_06_30::ErrorList),
135 UnknownValue(serde_json::Value),
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum GetReportsError {
142 Status400(models::reports_2021_06_30::ErrorList),
143 Status401(models::reports_2021_06_30::ErrorList),
144 Status403(models::reports_2021_06_30::ErrorList),
145 Status404(models::reports_2021_06_30::ErrorList),
146 Status415(models::reports_2021_06_30::ErrorList),
147 Status429(models::reports_2021_06_30::ErrorList),
148 Status500(models::reports_2021_06_30::ErrorList),
149 Status503(models::reports_2021_06_30::ErrorList),
150 UnknownValue(serde_json::Value),
151}
152
153
154pub async fn cancel_report(configuration: &configuration::Configuration, report_id: &str) -> Result<(), Error<CancelReportError>> {
156 let p_report_id = report_id;
158
159 let uri_str = format!("{}/reports/2021-06-30/reports/{reportId}", configuration.base_path, reportId=crate::apis::urlencode(p_report_id));
160 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
161
162 if let Some(ref user_agent) = configuration.user_agent {
163 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
164 }
165
166 let req = req_builder.build()?;
167 let resp = configuration.client.execute(req).await?;
168
169 let status = resp.status();
170
171 if !status.is_client_error() && !status.is_server_error() {
172 Ok(())
173 } else {
174 let content = resp.text().await?;
175 let entity: Option<CancelReportError> = serde_json::from_str(&content).ok();
176 Err(Error::ResponseError(ResponseContent { status, content, entity }))
177 }
178}
179
180pub async fn cancel_report_schedule(configuration: &configuration::Configuration, report_schedule_id: &str) -> Result<(), Error<CancelReportScheduleError>> {
182 let p_report_schedule_id = report_schedule_id;
184
185 let uri_str = format!("{}/reports/2021-06-30/schedules/{reportScheduleId}", configuration.base_path, reportScheduleId=crate::apis::urlencode(p_report_schedule_id));
186 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
187
188 if let Some(ref user_agent) = configuration.user_agent {
189 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
190 }
191
192 let req = req_builder.build()?;
193 let resp = configuration.client.execute(req).await?;
194
195 let status = resp.status();
196
197 if !status.is_client_error() && !status.is_server_error() {
198 Ok(())
199 } else {
200 let content = resp.text().await?;
201 let entity: Option<CancelReportScheduleError> = serde_json::from_str(&content).ok();
202 Err(Error::ResponseError(ResponseContent { status, content, entity }))
203 }
204}
205
206pub async fn create_report(configuration: &configuration::Configuration, body: models::reports_2021_06_30::CreateReportSpecification) -> Result<models::reports_2021_06_30::CreateReportResponse, Error<CreateReportError>> {
208 let p_body = body;
210
211 let uri_str = format!("{}/reports/2021-06-30/reports", configuration.base_path);
212 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
213
214 if let Some(ref user_agent) = configuration.user_agent {
215 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
216 }
217 req_builder = req_builder.json(&p_body);
218
219 let req = req_builder.build()?;
220 let resp = configuration.client.execute(req).await?;
221
222 let status = resp.status();
223 let content_type = resp
224 .headers()
225 .get("content-type")
226 .and_then(|v| v.to_str().ok())
227 .unwrap_or("application/octet-stream");
228 let content_type = super::ContentType::from(content_type);
229
230 if !status.is_client_error() && !status.is_server_error() {
231 let content = resp.text().await?;
232 match content_type {
233 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
234 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::reports_2021_06_30::CreateReportResponse`"))),
235 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::reports_2021_06_30::CreateReportResponse`")))),
236 }
237 } else {
238 let content = resp.text().await?;
239 let entity: Option<CreateReportError> = serde_json::from_str(&content).ok();
240 Err(Error::ResponseError(ResponseContent { status, content, entity }))
241 }
242}
243
244pub async fn create_report_schedule(configuration: &configuration::Configuration, body: models::reports_2021_06_30::CreateReportScheduleSpecification) -> Result<models::reports_2021_06_30::CreateReportScheduleResponse, Error<CreateReportScheduleError>> {
246 let p_body = body;
248
249 let uri_str = format!("{}/reports/2021-06-30/schedules", configuration.base_path);
250 let mut req_builder = configuration.client.request(reqwest::Method::POST, &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 req_builder = req_builder.json(&p_body);
256
257 let req = req_builder.build()?;
258 let resp = configuration.client.execute(req).await?;
259
260 let status = resp.status();
261 let content_type = resp
262 .headers()
263 .get("content-type")
264 .and_then(|v| v.to_str().ok())
265 .unwrap_or("application/octet-stream");
266 let content_type = super::ContentType::from(content_type);
267
268 if !status.is_client_error() && !status.is_server_error() {
269 let content = resp.text().await?;
270 match content_type {
271 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
272 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::reports_2021_06_30::CreateReportScheduleResponse`"))),
273 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::reports_2021_06_30::CreateReportScheduleResponse`")))),
274 }
275 } else {
276 let content = resp.text().await?;
277 let entity: Option<CreateReportScheduleError> = serde_json::from_str(&content).ok();
278 Err(Error::ResponseError(ResponseContent { status, content, entity }))
279 }
280}
281
282pub async fn get_report(configuration: &configuration::Configuration, report_id: &str) -> Result<models::reports_2021_06_30::Report, Error<GetReportError>> {
284 let p_report_id = report_id;
286
287 let uri_str = format!("{}/reports/2021-06-30/reports/{reportId}", configuration.base_path, reportId=crate::apis::urlencode(p_report_id));
288 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
289
290 if let Some(ref user_agent) = configuration.user_agent {
291 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
292 }
293
294 let req = req_builder.build()?;
295 let resp = configuration.client.execute(req).await?;
296
297 let status = resp.status();
298 let content_type = resp
299 .headers()
300 .get("content-type")
301 .and_then(|v| v.to_str().ok())
302 .unwrap_or("application/octet-stream");
303 let content_type = super::ContentType::from(content_type);
304
305 if !status.is_client_error() && !status.is_server_error() {
306 let content = resp.text().await?;
307 match content_type {
308 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
309 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::reports_2021_06_30::Report`"))),
310 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::reports_2021_06_30::Report`")))),
311 }
312 } else {
313 let content = resp.text().await?;
314 let entity: Option<GetReportError> = serde_json::from_str(&content).ok();
315 Err(Error::ResponseError(ResponseContent { status, content, entity }))
316 }
317}
318
319pub async fn get_report_document(configuration: &configuration::Configuration, report_document_id: &str) -> Result<models::reports_2021_06_30::ReportDocument, Error<GetReportDocumentError>> {
321 let p_report_document_id = report_document_id;
323
324 let uri_str = format!("{}/reports/2021-06-30/documents/{reportDocumentId}", configuration.base_path, reportDocumentId=crate::apis::urlencode(p_report_document_id));
325 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
326
327 if let Some(ref user_agent) = configuration.user_agent {
328 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
329 }
330
331 let req = req_builder.build()?;
332 let resp = configuration.client.execute(req).await?;
333
334 let status = resp.status();
335 let content_type = resp
336 .headers()
337 .get("content-type")
338 .and_then(|v| v.to_str().ok())
339 .unwrap_or("application/octet-stream");
340 let content_type = super::ContentType::from(content_type);
341
342 if !status.is_client_error() && !status.is_server_error() {
343 let content = resp.text().await?;
344 match content_type {
345 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
346 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::reports_2021_06_30::ReportDocument`"))),
347 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::reports_2021_06_30::ReportDocument`")))),
348 }
349 } else {
350 let content = resp.text().await?;
351 let entity: Option<GetReportDocumentError> = serde_json::from_str(&content).ok();
352 Err(Error::ResponseError(ResponseContent { status, content, entity }))
353 }
354}
355
356pub async fn get_report_schedule(configuration: &configuration::Configuration, report_schedule_id: &str) -> Result<models::reports_2021_06_30::ReportSchedule, Error<GetReportScheduleError>> {
358 let p_report_schedule_id = report_schedule_id;
360
361 let uri_str = format!("{}/reports/2021-06-30/schedules/{reportScheduleId}", configuration.base_path, reportScheduleId=crate::apis::urlencode(p_report_schedule_id));
362 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
363
364 if let Some(ref user_agent) = configuration.user_agent {
365 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
366 }
367
368 let req = req_builder.build()?;
369 let resp = configuration.client.execute(req).await?;
370
371 let status = resp.status();
372 let content_type = resp
373 .headers()
374 .get("content-type")
375 .and_then(|v| v.to_str().ok())
376 .unwrap_or("application/octet-stream");
377 let content_type = super::ContentType::from(content_type);
378
379 if !status.is_client_error() && !status.is_server_error() {
380 let content = resp.text().await?;
381 match content_type {
382 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
383 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::reports_2021_06_30::ReportSchedule`"))),
384 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::reports_2021_06_30::ReportSchedule`")))),
385 }
386 } else {
387 let content = resp.text().await?;
388 let entity: Option<GetReportScheduleError> = serde_json::from_str(&content).ok();
389 Err(Error::ResponseError(ResponseContent { status, content, entity }))
390 }
391}
392
393pub async fn get_report_schedules(configuration: &configuration::Configuration, report_types: Vec<String>) -> Result<models::reports_2021_06_30::ReportScheduleList, Error<GetReportSchedulesError>> {
395 let p_report_types = report_types;
397
398 let uri_str = format!("{}/reports/2021-06-30/schedules", configuration.base_path);
399 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
400
401 req_builder = match "csv" {
402 "multi" => req_builder.query(&p_report_types.into_iter().map(|p| ("reportTypes".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
403 _ => req_builder.query(&[("reportTypes", &p_report_types.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
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
409 let req = req_builder.build()?;
410 let resp = configuration.client.execute(req).await?;
411
412 let status = resp.status();
413 let content_type = resp
414 .headers()
415 .get("content-type")
416 .and_then(|v| v.to_str().ok())
417 .unwrap_or("application/octet-stream");
418 let content_type = super::ContentType::from(content_type);
419
420 if !status.is_client_error() && !status.is_server_error() {
421 let content = resp.text().await?;
422 match content_type {
423 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
424 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::reports_2021_06_30::ReportScheduleList`"))),
425 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::reports_2021_06_30::ReportScheduleList`")))),
426 }
427 } else {
428 let content = resp.text().await?;
429 let entity: Option<GetReportSchedulesError> = serde_json::from_str(&content).ok();
430 Err(Error::ResponseError(ResponseContent { status, content, entity }))
431 }
432}
433
434pub async fn get_reports(configuration: &configuration::Configuration, report_types: Option<Vec<String>>, processing_statuses: Option<Vec<String>>, marketplace_ids: Option<Vec<String>>, page_size: Option<i32>, created_since: Option<String>, created_until: Option<String>, next_token: Option<&str>) -> Result<models::reports_2021_06_30::GetReportsResponse, Error<GetReportsError>> {
436 let p_report_types = report_types;
438 let p_processing_statuses = processing_statuses;
439 let p_marketplace_ids = marketplace_ids;
440 let p_page_size = page_size;
441 let p_created_since = created_since;
442 let p_created_until = created_until;
443 let p_next_token = next_token;
444
445 let uri_str = format!("{}/reports/2021-06-30/reports", configuration.base_path);
446 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
447
448 if let Some(ref param_value) = p_report_types {
449 req_builder = match "csv" {
450 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("reportTypes".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
451 _ => req_builder.query(&[("reportTypes", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
452 };
453 }
454 if let Some(ref param_value) = p_processing_statuses {
455 req_builder = match "csv" {
456 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("processingStatuses".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
457 _ => req_builder.query(&[("processingStatuses", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
458 };
459 }
460 if let Some(ref param_value) = p_marketplace_ids {
461 req_builder = match "csv" {
462 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("marketplaceIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
463 _ => req_builder.query(&[("marketplaceIds", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
464 };
465 }
466 if let Some(ref param_value) = p_page_size {
467 req_builder = req_builder.query(&[("pageSize", ¶m_value.to_string())]);
468 }
469 if let Some(ref param_value) = p_created_since {
470 req_builder = req_builder.query(&[("createdSince", ¶m_value.to_string())]);
471 }
472 if let Some(ref param_value) = p_created_until {
473 req_builder = req_builder.query(&[("createdUntil", ¶m_value.to_string())]);
474 }
475 if let Some(ref param_value) = p_next_token {
476 req_builder = req_builder.query(&[("nextToken", ¶m_value.to_string())]);
477 }
478 if let Some(ref user_agent) = configuration.user_agent {
479 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
480 }
481
482 let req = req_builder.build()?;
483 let resp = configuration.client.execute(req).await?;
484
485 let status = resp.status();
486 let content_type = resp
487 .headers()
488 .get("content-type")
489 .and_then(|v| v.to_str().ok())
490 .unwrap_or("application/octet-stream");
491 let content_type = super::ContentType::from(content_type);
492
493 if !status.is_client_error() && !status.is_server_error() {
494 let content = resp.text().await?;
495 match content_type {
496 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
497 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::reports_2021_06_30::GetReportsResponse`"))),
498 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::reports_2021_06_30::GetReportsResponse`")))),
499 }
500 } else {
501 let content = resp.text().await?;
502 let entity: Option<GetReportsError> = serde_json::from_str(&content).ok();
503 Err(Error::ResponseError(ResponseContent { status, content, entity }))
504 }
505}
506