amazon_spapi/apis/
data_kiosk_2023_11_15.rs

1/*
2 * Selling Partner API for Data Kiosk
3 *
4 * The Selling Partner API for Data Kiosk lets you submit GraphQL queries from a variety of schemas to help selling partners manage their businesses.
5 *
6 * The version of the OpenAPI document: 2023-11-15
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`cancel_query`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CancelQueryError {
22    Status400(models::data_kiosk_2023_11_15::ErrorList),
23    Status403(models::data_kiosk_2023_11_15::ErrorList),
24    Status404(models::data_kiosk_2023_11_15::ErrorList),
25    Status413(models::data_kiosk_2023_11_15::ErrorList),
26    Status415(models::data_kiosk_2023_11_15::ErrorList),
27    Status429(models::data_kiosk_2023_11_15::ErrorList),
28    Status500(models::data_kiosk_2023_11_15::ErrorList),
29    Status503(models::data_kiosk_2023_11_15::ErrorList),
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method [`create_query`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum CreateQueryError {
37    Status400(models::data_kiosk_2023_11_15::ErrorList),
38    Status403(models::data_kiosk_2023_11_15::ErrorList),
39    Status404(models::data_kiosk_2023_11_15::ErrorList),
40    Status413(models::data_kiosk_2023_11_15::ErrorList),
41    Status415(models::data_kiosk_2023_11_15::ErrorList),
42    Status429(models::data_kiosk_2023_11_15::ErrorList),
43    Status500(models::data_kiosk_2023_11_15::ErrorList),
44    Status503(models::data_kiosk_2023_11_15::ErrorList),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`get_document`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum GetDocumentError {
52    Status400(models::data_kiosk_2023_11_15::ErrorList),
53    Status403(models::data_kiosk_2023_11_15::ErrorList),
54    Status404(models::data_kiosk_2023_11_15::ErrorList),
55    Status413(models::data_kiosk_2023_11_15::ErrorList),
56    Status415(models::data_kiosk_2023_11_15::ErrorList),
57    Status429(models::data_kiosk_2023_11_15::ErrorList),
58    Status500(models::data_kiosk_2023_11_15::ErrorList),
59    Status503(models::data_kiosk_2023_11_15::ErrorList),
60    UnknownValue(serde_json::Value),
61}
62
63/// struct for typed errors of method [`get_queries`]
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum GetQueriesError {
67    Status400(models::data_kiosk_2023_11_15::ErrorList),
68    Status403(models::data_kiosk_2023_11_15::ErrorList),
69    Status404(models::data_kiosk_2023_11_15::ErrorList),
70    Status413(models::data_kiosk_2023_11_15::ErrorList),
71    Status415(models::data_kiosk_2023_11_15::ErrorList),
72    Status429(models::data_kiosk_2023_11_15::ErrorList),
73    Status500(models::data_kiosk_2023_11_15::ErrorList),
74    Status503(models::data_kiosk_2023_11_15::ErrorList),
75    UnknownValue(serde_json::Value),
76}
77
78/// struct for typed errors of method [`get_query`]
79#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum GetQueryError {
82    Status400(models::data_kiosk_2023_11_15::ErrorList),
83    Status403(models::data_kiosk_2023_11_15::ErrorList),
84    Status404(models::data_kiosk_2023_11_15::ErrorList),
85    Status413(models::data_kiosk_2023_11_15::ErrorList),
86    Status415(models::data_kiosk_2023_11_15::ErrorList),
87    Status429(models::data_kiosk_2023_11_15::ErrorList),
88    Status500(models::data_kiosk_2023_11_15::ErrorList),
89    Status503(models::data_kiosk_2023_11_15::ErrorList),
90    UnknownValue(serde_json::Value),
91}
92
93
94/// Cancels the query specified by the `queryId` parameter. Only queries with a non-terminal `processingStatus` (`IN_QUEUE`, `IN_PROGRESS`) can be cancelled. Cancelling a query that already has a `processingStatus` of `CANCELLED` will no-op. Cancelled queries are returned in subsequent calls to the `getQuery` and `getQueries` operations.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.0222 | 10 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
95pub async fn cancel_query(configuration: &configuration::Configuration, query_id: &str) -> Result<(), Error<CancelQueryError>> {
96    // add a prefix to parameters to efficiently prevent name collisions
97    let p_query_id = query_id;
98
99    let uri_str = format!("{}/dataKiosk/2023-11-15/queries/{queryId}", configuration.base_path, queryId=crate::apis::urlencode(p_query_id));
100    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
101
102    if let Some(ref user_agent) = configuration.user_agent {
103        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
104    }
105
106    let req = req_builder.build()?;
107    let resp = configuration.client.execute(req).await?;
108
109    let status = resp.status();
110
111    if !status.is_client_error() && !status.is_server_error() {
112        Ok(())
113    } else {
114        let content = resp.text().await?;
115        let entity: Option<CancelQueryError> = serde_json::from_str(&content).ok();
116        Err(Error::ResponseError(ResponseContent { status, content, entity }))
117    }
118}
119
120/// Creates a Data Kiosk query request.  **Note:** The retention of a query varies based on the fields requested. Each field within a schema is annotated with a `@resultRetention` directive that defines how long a query containing that field will be retained. When a query contains multiple fields with different retentions, the shortest (minimum) retention is applied. The retention of a query's resulting documents always matches the retention of the query.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.0167 | 15 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
121pub async fn create_query(configuration: &configuration::Configuration, body: models::data_kiosk_2023_11_15::CreateQuerySpecification) -> Result<models::data_kiosk_2023_11_15::CreateQueryResponse, Error<CreateQueryError>> {
122    // add a prefix to parameters to efficiently prevent name collisions
123    let p_body = body;
124
125    let uri_str = format!("{}/dataKiosk/2023-11-15/queries", configuration.base_path);
126    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
127
128    if let Some(ref user_agent) = configuration.user_agent {
129        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
130    }
131    req_builder = req_builder.json(&p_body);
132
133    let req = req_builder.build()?;
134    let resp = configuration.client.execute(req).await?;
135
136    let status = resp.status();
137    let content_type = resp
138        .headers()
139        .get("content-type")
140        .and_then(|v| v.to_str().ok())
141        .unwrap_or("application/octet-stream");
142    let content_type = super::ContentType::from(content_type);
143
144    if !status.is_client_error() && !status.is_server_error() {
145        let content = resp.text().await?;
146        match content_type {
147            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
148            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::data_kiosk_2023_11_15::CreateQueryResponse`"))),
149            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::data_kiosk_2023_11_15::CreateQueryResponse`")))),
150        }
151    } else {
152        let content = resp.text().await?;
153        let entity: Option<CreateQueryError> = serde_json::from_str(&content).ok();
154        Err(Error::ResponseError(ResponseContent { status, content, entity }))
155    }
156}
157
158/// Returns the information required for retrieving a Data Kiosk document's contents. See the `createQuery` operation for details about document retention.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.0167 | 15 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
159pub async fn get_document(configuration: &configuration::Configuration, document_id: &str) -> Result<models::data_kiosk_2023_11_15::GetDocumentResponse, Error<GetDocumentError>> {
160    // add a prefix to parameters to efficiently prevent name collisions
161    let p_document_id = document_id;
162
163    let uri_str = format!("{}/dataKiosk/2023-11-15/documents/{documentId}", configuration.base_path, documentId=crate::apis::urlencode(p_document_id));
164    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
165
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
170    let req = req_builder.build()?;
171    let resp = configuration.client.execute(req).await?;
172
173    let status = resp.status();
174    let content_type = resp
175        .headers()
176        .get("content-type")
177        .and_then(|v| v.to_str().ok())
178        .unwrap_or("application/octet-stream");
179    let content_type = super::ContentType::from(content_type);
180
181    if !status.is_client_error() && !status.is_server_error() {
182        let content = resp.text().await?;
183        match content_type {
184            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
185            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::data_kiosk_2023_11_15::GetDocumentResponse`"))),
186            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::data_kiosk_2023_11_15::GetDocumentResponse`")))),
187        }
188    } else {
189        let content = resp.text().await?;
190        let entity: Option<GetDocumentError> = serde_json::from_str(&content).ok();
191        Err(Error::ResponseError(ResponseContent { status, content, entity }))
192    }
193}
194
195/// Returns details for the Data Kiosk queries that match the specified filters. See the `createQuery` operation for details about query retention.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.0222 | 10 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
196pub async fn get_queries(configuration: &configuration::Configuration, processing_statuses: Option<Vec<String>>, page_size: Option<i32>, created_since: Option<String>, created_until: Option<String>, pagination_token: Option<&str>) -> Result<models::data_kiosk_2023_11_15::GetQueriesResponse, Error<GetQueriesError>> {
197    // add a prefix to parameters to efficiently prevent name collisions
198    let p_processing_statuses = processing_statuses;
199    let p_page_size = page_size;
200    let p_created_since = created_since;
201    let p_created_until = created_until;
202    let p_pagination_token = pagination_token;
203
204    let uri_str = format!("{}/dataKiosk/2023-11-15/queries", configuration.base_path);
205    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
206
207    if let Some(ref param_value) = p_processing_statuses {
208        req_builder = match "csv" {
209            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("processingStatuses".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
210            _ => req_builder.query(&[("processingStatuses", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
211        };
212    }
213    if let Some(ref param_value) = p_page_size {
214        req_builder = req_builder.query(&[("pageSize", &param_value.to_string())]);
215    }
216    if let Some(ref param_value) = p_created_since {
217        req_builder = req_builder.query(&[("createdSince", &param_value.to_string())]);
218    }
219    if let Some(ref param_value) = p_created_until {
220        req_builder = req_builder.query(&[("createdUntil", &param_value.to_string())]);
221    }
222    if let Some(ref param_value) = p_pagination_token {
223        req_builder = req_builder.query(&[("paginationToken", &param_value.to_string())]);
224    }
225    if let Some(ref user_agent) = configuration.user_agent {
226        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
227    }
228
229    let req = req_builder.build()?;
230    let resp = configuration.client.execute(req).await?;
231
232    let status = resp.status();
233    let content_type = resp
234        .headers()
235        .get("content-type")
236        .and_then(|v| v.to_str().ok())
237        .unwrap_or("application/octet-stream");
238    let content_type = super::ContentType::from(content_type);
239
240    if !status.is_client_error() && !status.is_server_error() {
241        let content = resp.text().await?;
242        match content_type {
243            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
244            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::data_kiosk_2023_11_15::GetQueriesResponse`"))),
245            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::data_kiosk_2023_11_15::GetQueriesResponse`")))),
246        }
247    } else {
248        let content = resp.text().await?;
249        let entity: Option<GetQueriesError> = serde_json::from_str(&content).ok();
250        Err(Error::ResponseError(ResponseContent { status, content, entity }))
251    }
252}
253
254/// Returns query details for the query specified by the `queryId` parameter. See the `createQuery` operation for details about query retention.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 2.0 | 15 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
255pub async fn get_query(configuration: &configuration::Configuration, query_id: &str) -> Result<models::data_kiosk_2023_11_15::Query, Error<GetQueryError>> {
256    // add a prefix to parameters to efficiently prevent name collisions
257    let p_query_id = query_id;
258
259    let uri_str = format!("{}/dataKiosk/2023-11-15/queries/{queryId}", configuration.base_path, queryId=crate::apis::urlencode(p_query_id));
260    let mut req_builder = configuration.client.request(reqwest::Method::GET, &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
266    let req = req_builder.build()?;
267    let resp = configuration.client.execute(req).await?;
268
269    let status = resp.status();
270    let content_type = resp
271        .headers()
272        .get("content-type")
273        .and_then(|v| v.to_str().ok())
274        .unwrap_or("application/octet-stream");
275    let content_type = super::ContentType::from(content_type);
276
277    if !status.is_client_error() && !status.is_server_error() {
278        let content = resp.text().await?;
279        match content_type {
280            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
281            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::data_kiosk_2023_11_15::Query`"))),
282            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::data_kiosk_2023_11_15::Query`")))),
283        }
284    } else {
285        let content = resp.text().await?;
286        let entity: Option<GetQueryError> = serde_json::from_str(&content).ok();
287        Err(Error::ResponseError(ResponseContent { status, content, entity }))
288    }
289}
290