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 RiskClearReferenceError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum RiskReferenceError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum RiskReferenceSetsError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum RiskRefreshReferenceError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum RiskResolveReferenceError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum RiskSetReferenceError {
57 UnknownValue(serde_json::Value),
58}
59
60
61pub async fn risk_clear_reference(configuration: &configuration::Configuration, set: &str, key: Option<&str>) -> Result<models::ClearReferenceOut, Error<RiskClearReferenceError>> {
63 let p_set = set;
65 let p_key = key;
66
67 let uri_str = format!("{}/v1/reference/{set}", configuration.base_path, set=crate::apis::urlencode(p_set));
68 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
69
70 if let Some(ref param_value) = p_key {
71 req_builder = req_builder.query(&[("key", ¶m_value.to_string())]);
72 }
73 if let Some(ref user_agent) = configuration.user_agent {
74 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
75 }
76 if let Some(ref token) = configuration.bearer_access_token {
77 req_builder = req_builder.bearer_auth(token.to_owned());
78 };
79
80 let req = req_builder.build()?;
81 let resp = configuration.client.execute(req).await?;
82
83 let status = resp.status();
84 let content_type = resp
85 .headers()
86 .get("content-type")
87 .and_then(|v| v.to_str().ok())
88 .unwrap_or("application/octet-stream");
89 let content_type = super::ContentType::from(content_type);
90
91 if !status.is_client_error() && !status.is_server_error() {
92 let content = resp.text().await?;
93 match content_type {
94 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
95 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ClearReferenceOut`"))),
96 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::ClearReferenceOut`")))),
97 }
98 } else {
99 let content = resp.text().await?;
100 let entity: Option<RiskClearReferenceError> = serde_json::from_str(&content).ok();
101 Err(Error::ResponseError(ResponseContent { status, content, entity }))
102 }
103}
104
105pub async fn risk_reference(configuration: &configuration::Configuration, set: &str, after: Option<&str>, limit: Option<i32>) -> Result<models::ReferenceOut, Error<RiskReferenceError>> {
107 let p_set = set;
109 let p_after = after;
110 let p_limit = limit;
111
112 let uri_str = format!("{}/v1/reference/{set}", configuration.base_path, set=crate::apis::urlencode(p_set));
113 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
114
115 if let Some(ref param_value) = p_after {
116 req_builder = req_builder.query(&[("after", ¶m_value.to_string())]);
117 }
118 if let Some(ref param_value) = p_limit {
119 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
120 }
121 if let Some(ref user_agent) = configuration.user_agent {
122 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
123 }
124 if let Some(ref token) = configuration.bearer_access_token {
125 req_builder = req_builder.bearer_auth(token.to_owned());
126 };
127
128 let req = req_builder.build()?;
129 let resp = configuration.client.execute(req).await?;
130
131 let status = resp.status();
132 let content_type = resp
133 .headers()
134 .get("content-type")
135 .and_then(|v| v.to_str().ok())
136 .unwrap_or("application/octet-stream");
137 let content_type = super::ContentType::from(content_type);
138
139 if !status.is_client_error() && !status.is_server_error() {
140 let content = resp.text().await?;
141 match content_type {
142 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
143 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReferenceOut`"))),
144 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::ReferenceOut`")))),
145 }
146 } else {
147 let content = resp.text().await?;
148 let entity: Option<RiskReferenceError> = serde_json::from_str(&content).ok();
149 Err(Error::ResponseError(ResponseContent { status, content, entity }))
150 }
151}
152
153pub async fn risk_reference_sets(configuration: &configuration::Configuration, ) -> Result<models::ReferenceSetsOut, Error<RiskReferenceSetsError>> {
155
156 let uri_str = format!("{}/v1/reference", configuration.base_path);
157 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
158
159 if let Some(ref user_agent) = configuration.user_agent {
160 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
161 }
162 if let Some(ref token) = configuration.bearer_access_token {
163 req_builder = req_builder.bearer_auth(token.to_owned());
164 };
165
166 let req = req_builder.build()?;
167 let resp = configuration.client.execute(req).await?;
168
169 let status = resp.status();
170 let content_type = resp
171 .headers()
172 .get("content-type")
173 .and_then(|v| v.to_str().ok())
174 .unwrap_or("application/octet-stream");
175 let content_type = super::ContentType::from(content_type);
176
177 if !status.is_client_error() && !status.is_server_error() {
178 let content = resp.text().await?;
179 match content_type {
180 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
181 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReferenceSetsOut`"))),
182 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::ReferenceSetsOut`")))),
183 }
184 } else {
185 let content = resp.text().await?;
186 let entity: Option<RiskReferenceSetsError> = serde_json::from_str(&content).ok();
187 Err(Error::ResponseError(ResponseContent { status, content, entity }))
188 }
189}
190
191pub async fn risk_refresh_reference(configuration: &configuration::Configuration, refresh_reference_in: models::RefreshReferenceIn) -> Result<models::RefreshReferenceOut, Error<RiskRefreshReferenceError>> {
193 let p_refresh_reference_in = refresh_reference_in;
195
196 let uri_str = format!("{}/v1/reference/refresh", configuration.base_path);
197 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
198
199 if let Some(ref user_agent) = configuration.user_agent {
200 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
201 }
202 if let Some(ref token) = configuration.bearer_access_token {
203 req_builder = req_builder.bearer_auth(token.to_owned());
204 };
205 req_builder = req_builder.json(&p_refresh_reference_in);
206
207 let req = req_builder.build()?;
208 let resp = configuration.client.execute(req).await?;
209
210 let status = resp.status();
211 let content_type = resp
212 .headers()
213 .get("content-type")
214 .and_then(|v| v.to_str().ok())
215 .unwrap_or("application/octet-stream");
216 let content_type = super::ContentType::from(content_type);
217
218 if !status.is_client_error() && !status.is_server_error() {
219 let content = resp.text().await?;
220 match content_type {
221 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
222 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RefreshReferenceOut`"))),
223 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::RefreshReferenceOut`")))),
224 }
225 } else {
226 let content = resp.text().await?;
227 let entity: Option<RiskRefreshReferenceError> = serde_json::from_str(&content).ok();
228 Err(Error::ResponseError(ResponseContent { status, content, entity }))
229 }
230}
231
232pub async fn risk_resolve_reference(configuration: &configuration::Configuration, resolve_reference_in: models::ResolveReferenceIn) -> Result<models::ResolveReferenceOut, Error<RiskResolveReferenceError>> {
234 let p_resolve_reference_in = resolve_reference_in;
236
237 let uri_str = format!("{}/v1/reference/resolve", configuration.base_path);
238 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
239
240 if let Some(ref user_agent) = configuration.user_agent {
241 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
242 }
243 if let Some(ref token) = configuration.bearer_access_token {
244 req_builder = req_builder.bearer_auth(token.to_owned());
245 };
246 req_builder = req_builder.json(&p_resolve_reference_in);
247
248 let req = req_builder.build()?;
249 let resp = configuration.client.execute(req).await?;
250
251 let status = resp.status();
252 let content_type = resp
253 .headers()
254 .get("content-type")
255 .and_then(|v| v.to_str().ok())
256 .unwrap_or("application/octet-stream");
257 let content_type = super::ContentType::from(content_type);
258
259 if !status.is_client_error() && !status.is_server_error() {
260 let content = resp.text().await?;
261 match content_type {
262 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
263 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResolveReferenceOut`"))),
264 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::ResolveReferenceOut`")))),
265 }
266 } else {
267 let content = resp.text().await?;
268 let entity: Option<RiskResolveReferenceError> = serde_json::from_str(&content).ok();
269 Err(Error::ResponseError(ResponseContent { status, content, entity }))
270 }
271}
272
273pub async fn risk_set_reference(configuration: &configuration::Configuration, set: &str, set_reference_in: models::SetReferenceIn) -> Result<models::SetReferenceOut, Error<RiskSetReferenceError>> {
275 let p_set = set;
277 let p_set_reference_in = set_reference_in;
278
279 let uri_str = format!("{}/v1/reference/{set}", configuration.base_path, set=crate::apis::urlencode(p_set));
280 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
281
282 if let Some(ref user_agent) = configuration.user_agent {
283 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
284 }
285 if let Some(ref token) = configuration.bearer_access_token {
286 req_builder = req_builder.bearer_auth(token.to_owned());
287 };
288 req_builder = req_builder.json(&p_set_reference_in);
289
290 let req = req_builder.build()?;
291 let resp = configuration.client.execute(req).await?;
292
293 let status = resp.status();
294 let content_type = resp
295 .headers()
296 .get("content-type")
297 .and_then(|v| v.to_str().ok())
298 .unwrap_or("application/octet-stream");
299 let content_type = super::ContentType::from(content_type);
300
301 if !status.is_client_error() && !status.is_server_error() {
302 let content = resp.text().await?;
303 match content_type {
304 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
305 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SetReferenceOut`"))),
306 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::SetReferenceOut`")))),
307 }
308 } else {
309 let content = resp.text().await?;
310 let entity: Option<RiskSetReferenceError> = serde_json::from_str(&content).ok();
311 Err(Error::ResponseError(ResponseContent { status, content, entity }))
312 }
313}
314