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 GetRiskHealthError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum RiskAdoptModelError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum RiskFeaturesError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum RiskLearnError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum RiskPolicyError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum RiskPublishModelError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum RiskScoreError {
64 UnknownValue(serde_json::Value),
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum RiskSearchError {
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum RiskSearchResultError {
78 UnknownValue(serde_json::Value),
79}
80
81#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum RiskSetPolicyError {
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum RiskStateError {
92 UnknownValue(serde_json::Value),
93}
94
95
96pub async fn get_risk_health(configuration: &configuration::Configuration, ) -> Result<(), Error<GetRiskHealthError>> {
98
99 let uri_str = format!("{}/v1/risk/health", configuration.base_path);
100 let mut req_builder = configuration.client.request(reqwest::Method::GET, &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 if let Some(ref token) = configuration.bearer_access_token {
106 req_builder = req_builder.bearer_auth(token.to_owned());
107 };
108
109 let req = req_builder.build()?;
110 let resp = configuration.client.execute(req).await?;
111
112 let status = resp.status();
113
114 if !status.is_client_error() && !status.is_server_error() {
115 Ok(())
116 } else {
117 let content = resp.text().await?;
118 let entity: Option<GetRiskHealthError> = serde_json::from_str(&content).ok();
119 Err(Error::ResponseError(ResponseContent { status, content, entity }))
120 }
121}
122
123pub async fn risk_adopt_model(configuration: &configuration::Configuration, risk_adopt_in: models::RiskAdoptIn) -> Result<models::RiskModelState, Error<RiskAdoptModelError>> {
125 let p_risk_adopt_in = risk_adopt_in;
127
128 let uri_str = format!("{}/v1/risk/state/model", configuration.base_path);
129 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
130
131 if let Some(ref user_agent) = configuration.user_agent {
132 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
133 }
134 if let Some(ref token) = configuration.bearer_access_token {
135 req_builder = req_builder.bearer_auth(token.to_owned());
136 };
137 req_builder = req_builder.json(&p_risk_adopt_in);
138
139 let req = req_builder.build()?;
140 let resp = configuration.client.execute(req).await?;
141
142 let status = resp.status();
143 let content_type = resp
144 .headers()
145 .get("content-type")
146 .and_then(|v| v.to_str().ok())
147 .unwrap_or("application/octet-stream");
148 let content_type = super::ContentType::from(content_type);
149
150 if !status.is_client_error() && !status.is_server_error() {
151 let content = resp.text().await?;
152 match content_type {
153 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
154 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskModelState`"))),
155 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::RiskModelState`")))),
156 }
157 } else {
158 let content = resp.text().await?;
159 let entity: Option<RiskAdoptModelError> = serde_json::from_str(&content).ok();
160 Err(Error::ResponseError(ResponseContent { status, content, entity }))
161 }
162}
163
164pub async fn risk_features(configuration: &configuration::Configuration, days: Option<i32>) -> Result<models::RiskCatalog, Error<RiskFeaturesError>> {
166 let p_days = days;
168
169 let uri_str = format!("{}/v1/risk/features", configuration.base_path);
170 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
171
172 if let Some(ref param_value) = p_days {
173 req_builder = req_builder.query(&[("days", ¶m_value.to_string())]);
174 }
175 if let Some(ref user_agent) = configuration.user_agent {
176 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
177 }
178 if let Some(ref token) = configuration.bearer_access_token {
179 req_builder = req_builder.bearer_auth(token.to_owned());
180 };
181
182 let req = req_builder.build()?;
183 let resp = configuration.client.execute(req).await?;
184
185 let status = resp.status();
186 let content_type = resp
187 .headers()
188 .get("content-type")
189 .and_then(|v| v.to_str().ok())
190 .unwrap_or("application/octet-stream");
191 let content_type = super::ContentType::from(content_type);
192
193 if !status.is_client_error() && !status.is_server_error() {
194 let content = resp.text().await?;
195 match content_type {
196 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
197 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskCatalog`"))),
198 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::RiskCatalog`")))),
199 }
200 } else {
201 let content = resp.text().await?;
202 let entity: Option<RiskFeaturesError> = serde_json::from_str(&content).ok();
203 Err(Error::ResponseError(ResponseContent { status, content, entity }))
204 }
205}
206
207pub async fn risk_learn(configuration: &configuration::Configuration, risk_learn_in: models::RiskLearnIn) -> Result<models::RiskLearnOut, Error<RiskLearnError>> {
209 let p_risk_learn_in = risk_learn_in;
211
212 let uri_str = format!("{}/v1/risk/learn", configuration.base_path);
213 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
214
215 if let Some(ref user_agent) = configuration.user_agent {
216 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
217 }
218 if let Some(ref token) = configuration.bearer_access_token {
219 req_builder = req_builder.bearer_auth(token.to_owned());
220 };
221 req_builder = req_builder.json(&p_risk_learn_in);
222
223 let req = req_builder.build()?;
224 let resp = configuration.client.execute(req).await?;
225
226 let status = resp.status();
227 let content_type = resp
228 .headers()
229 .get("content-type")
230 .and_then(|v| v.to_str().ok())
231 .unwrap_or("application/octet-stream");
232 let content_type = super::ContentType::from(content_type);
233
234 if !status.is_client_error() && !status.is_server_error() {
235 let content = resp.text().await?;
236 match content_type {
237 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
238 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskLearnOut`"))),
239 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::RiskLearnOut`")))),
240 }
241 } else {
242 let content = resp.text().await?;
243 let entity: Option<RiskLearnError> = serde_json::from_str(&content).ok();
244 Err(Error::ResponseError(ResponseContent { status, content, entity }))
245 }
246}
247
248pub async fn risk_policy(configuration: &configuration::Configuration, ) -> Result<models::RiskPolicyOut, Error<RiskPolicyError>> {
250
251 let uri_str = format!("{}/v1/risk/policy", configuration.base_path);
252 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
253
254 if let Some(ref user_agent) = configuration.user_agent {
255 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
256 }
257 if let Some(ref token) = configuration.bearer_access_token {
258 req_builder = req_builder.bearer_auth(token.to_owned());
259 };
260
261 let req = req_builder.build()?;
262 let resp = configuration.client.execute(req).await?;
263
264 let status = resp.status();
265 let content_type = resp
266 .headers()
267 .get("content-type")
268 .and_then(|v| v.to_str().ok())
269 .unwrap_or("application/octet-stream");
270 let content_type = super::ContentType::from(content_type);
271
272 if !status.is_client_error() && !status.is_server_error() {
273 let content = resp.text().await?;
274 match content_type {
275 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
276 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskPolicyOut`"))),
277 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::RiskPolicyOut`")))),
278 }
279 } else {
280 let content = resp.text().await?;
281 let entity: Option<RiskPolicyError> = serde_json::from_str(&content).ok();
282 Err(Error::ResponseError(ResponseContent { status, content, entity }))
283 }
284}
285
286pub async fn risk_publish_model(configuration: &configuration::Configuration, ) -> Result<models::RiskPublishOut, Error<RiskPublishModelError>> {
288
289 let uri_str = format!("{}/v1/risk/state/model", configuration.base_path);
290 let mut req_builder = configuration.client.request(reqwest::Method::POST, &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(ref token) = configuration.bearer_access_token {
296 req_builder = req_builder.bearer_auth(token.to_owned());
297 };
298
299 let req = req_builder.build()?;
300 let resp = configuration.client.execute(req).await?;
301
302 let status = resp.status();
303 let content_type = resp
304 .headers()
305 .get("content-type")
306 .and_then(|v| v.to_str().ok())
307 .unwrap_or("application/octet-stream");
308 let content_type = super::ContentType::from(content_type);
309
310 if !status.is_client_error() && !status.is_server_error() {
311 let content = resp.text().await?;
312 match content_type {
313 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
314 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskPublishOut`"))),
315 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::RiskPublishOut`")))),
316 }
317 } else {
318 let content = resp.text().await?;
319 let entity: Option<RiskPublishModelError> = serde_json::from_str(&content).ok();
320 Err(Error::ResponseError(ResponseContent { status, content, entity }))
321 }
322}
323
324pub async fn risk_score(configuration: &configuration::Configuration, risk_score_in: models::RiskScoreIn) -> Result<models::RiskScoreOut, Error<RiskScoreError>> {
326 let p_risk_score_in = risk_score_in;
328
329 let uri_str = format!("{}/v1/risk/score", configuration.base_path);
330 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
331
332 if let Some(ref user_agent) = configuration.user_agent {
333 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
334 }
335 if let Some(ref token) = configuration.bearer_access_token {
336 req_builder = req_builder.bearer_auth(token.to_owned());
337 };
338 req_builder = req_builder.json(&p_risk_score_in);
339
340 let req = req_builder.build()?;
341 let resp = configuration.client.execute(req).await?;
342
343 let status = resp.status();
344 let content_type = resp
345 .headers()
346 .get("content-type")
347 .and_then(|v| v.to_str().ok())
348 .unwrap_or("application/octet-stream");
349 let content_type = super::ContentType::from(content_type);
350
351 if !status.is_client_error() && !status.is_server_error() {
352 let content = resp.text().await?;
353 match content_type {
354 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
355 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskScoreOut`"))),
356 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::RiskScoreOut`")))),
357 }
358 } else {
359 let content = resp.text().await?;
360 let entity: Option<RiskScoreError> = serde_json::from_str(&content).ok();
361 Err(Error::ResponseError(ResponseContent { status, content, entity }))
362 }
363}
364
365pub async fn risk_search(configuration: &configuration::Configuration, risk_search_in: models::RiskSearchIn) -> Result<models::RiskSearchRun, Error<RiskSearchError>> {
367 let p_risk_search_in = risk_search_in;
369
370 let uri_str = format!("{}/v1/risk/search", configuration.base_path);
371 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
372
373 if let Some(ref user_agent) = configuration.user_agent {
374 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
375 }
376 if let Some(ref token) = configuration.bearer_access_token {
377 req_builder = req_builder.bearer_auth(token.to_owned());
378 };
379 req_builder = req_builder.json(&p_risk_search_in);
380
381 let req = req_builder.build()?;
382 let resp = configuration.client.execute(req).await?;
383
384 let status = resp.status();
385 let content_type = resp
386 .headers()
387 .get("content-type")
388 .and_then(|v| v.to_str().ok())
389 .unwrap_or("application/octet-stream");
390 let content_type = super::ContentType::from(content_type);
391
392 if !status.is_client_error() && !status.is_server_error() {
393 let content = resp.text().await?;
394 match content_type {
395 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
396 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskSearchRun`"))),
397 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::RiskSearchRun`")))),
398 }
399 } else {
400 let content = resp.text().await?;
401 let entity: Option<RiskSearchError> = serde_json::from_str(&content).ok();
402 Err(Error::ResponseError(ResponseContent { status, content, entity }))
403 }
404}
405
406pub async fn risk_search_result(configuration: &configuration::Configuration, id: &str) -> Result<models::RiskSearchReport, Error<RiskSearchResultError>> {
408 let p_id = id;
410
411 let uri_str = format!("{}/v1/risk/search/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
412 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
413
414 if let Some(ref user_agent) = configuration.user_agent {
415 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
416 }
417 if let Some(ref token) = configuration.bearer_access_token {
418 req_builder = req_builder.bearer_auth(token.to_owned());
419 };
420
421 let req = req_builder.build()?;
422 let resp = configuration.client.execute(req).await?;
423
424 let status = resp.status();
425 let content_type = resp
426 .headers()
427 .get("content-type")
428 .and_then(|v| v.to_str().ok())
429 .unwrap_or("application/octet-stream");
430 let content_type = super::ContentType::from(content_type);
431
432 if !status.is_client_error() && !status.is_server_error() {
433 let content = resp.text().await?;
434 match content_type {
435 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
436 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskSearchReport`"))),
437 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::RiskSearchReport`")))),
438 }
439 } else {
440 let content = resp.text().await?;
441 let entity: Option<RiskSearchResultError> = serde_json::from_str(&content).ok();
442 Err(Error::ResponseError(ResponseContent { status, content, entity }))
443 }
444}
445
446pub async fn risk_set_policy(configuration: &configuration::Configuration, risk_appetite_in: models::RiskAppetiteIn) -> Result<models::RiskPolicyOut, Error<RiskSetPolicyError>> {
448 let p_risk_appetite_in = risk_appetite_in;
450
451 let uri_str = format!("{}/v1/risk/policy", configuration.base_path);
452 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
453
454 if let Some(ref user_agent) = configuration.user_agent {
455 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
456 }
457 if let Some(ref token) = configuration.bearer_access_token {
458 req_builder = req_builder.bearer_auth(token.to_owned());
459 };
460 req_builder = req_builder.json(&p_risk_appetite_in);
461
462 let req = req_builder.build()?;
463 let resp = configuration.client.execute(req).await?;
464
465 let status = resp.status();
466 let content_type = resp
467 .headers()
468 .get("content-type")
469 .and_then(|v| v.to_str().ok())
470 .unwrap_or("application/octet-stream");
471 let content_type = super::ContentType::from(content_type);
472
473 if !status.is_client_error() && !status.is_server_error() {
474 let content = resp.text().await?;
475 match content_type {
476 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
477 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskPolicyOut`"))),
478 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::RiskPolicyOut`")))),
479 }
480 } else {
481 let content = resp.text().await?;
482 let entity: Option<RiskSetPolicyError> = serde_json::from_str(&content).ok();
483 Err(Error::ResponseError(ResponseContent { status, content, entity }))
484 }
485}
486
487pub async fn risk_state(configuration: &configuration::Configuration, ) -> Result<models::RiskModelState, Error<RiskStateError>> {
489
490 let uri_str = format!("{}/v1/risk/state", configuration.base_path);
491 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
492
493 if let Some(ref user_agent) = configuration.user_agent {
494 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
495 }
496 if let Some(ref token) = configuration.bearer_access_token {
497 req_builder = req_builder.bearer_auth(token.to_owned());
498 };
499
500 let req = req_builder.build()?;
501 let resp = configuration.client.execute(req).await?;
502
503 let status = resp.status();
504 let content_type = resp
505 .headers()
506 .get("content-type")
507 .and_then(|v| v.to_str().ok())
508 .unwrap_or("application/octet-stream");
509 let content_type = super::ContentType::from(content_type);
510
511 if !status.is_client_error() && !status.is_server_error() {
512 let content = resp.text().await?;
513 match content_type {
514 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
515 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskModelState`"))),
516 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::RiskModelState`")))),
517 }
518 } else {
519 let content = resp.text().await?;
520 let entity: Option<RiskStateError> = serde_json::from_str(&content).ok();
521 Err(Error::ResponseError(ResponseContent { status, content, entity }))
522 }
523}
524