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 RiskCreateDatasetError {
22 UnknownValue(serde_json::Value),
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum RiskDatasetError {
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum RiskDatasetLineageError {
36 UnknownValue(serde_json::Value),
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum RiskDatasetsError {
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum RiskDeleteDatasetError {
50 UnknownValue(serde_json::Value),
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum RiskExportDatasetError {
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum RiskMaterializeDatasetError {
64 UnknownValue(serde_json::Value),
65}
66
67
68pub async fn risk_create_dataset(configuration: &configuration::Configuration, risk_dataset_spec: models::RiskDatasetSpec) -> Result<models::RiskDataset, Error<RiskCreateDatasetError>> {
70 let p_risk_dataset_spec = risk_dataset_spec;
72
73 let uri_str = format!("{}/v1/dataset", configuration.base_path);
74 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
75
76 if let Some(ref user_agent) = configuration.user_agent {
77 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
78 }
79 if let Some(ref token) = configuration.bearer_access_token {
80 req_builder = req_builder.bearer_auth(token.to_owned());
81 };
82 req_builder = req_builder.json(&p_risk_dataset_spec);
83
84 let req = req_builder.build()?;
85 let resp = configuration.client.execute(req).await?;
86
87 let status = resp.status();
88 let content_type = resp
89 .headers()
90 .get("content-type")
91 .and_then(|v| v.to_str().ok())
92 .unwrap_or("application/octet-stream");
93 let content_type = super::ContentType::from(content_type);
94
95 if !status.is_client_error() && !status.is_server_error() {
96 let content = resp.text().await?;
97 match content_type {
98 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
99 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskDataset`"))),
100 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::RiskDataset`")))),
101 }
102 } else {
103 let content = resp.text().await?;
104 let entity: Option<RiskCreateDatasetError> = serde_json::from_str(&content).ok();
105 Err(Error::ResponseError(ResponseContent { status, content, entity }))
106 }
107}
108
109pub async fn risk_dataset(configuration: &configuration::Configuration, name: &str) -> Result<models::RiskDatasetVersions, Error<RiskDatasetError>> {
111 let p_name = name;
113
114 let uri_str = format!("{}/v1/dataset/{name}", configuration.base_path, name=crate::apis::urlencode(p_name));
115 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
116
117 if let Some(ref user_agent) = configuration.user_agent {
118 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
119 }
120 if let Some(ref token) = configuration.bearer_access_token {
121 req_builder = req_builder.bearer_auth(token.to_owned());
122 };
123
124 let req = req_builder.build()?;
125 let resp = configuration.client.execute(req).await?;
126
127 let status = resp.status();
128 let content_type = resp
129 .headers()
130 .get("content-type")
131 .and_then(|v| v.to_str().ok())
132 .unwrap_or("application/octet-stream");
133 let content_type = super::ContentType::from(content_type);
134
135 if !status.is_client_error() && !status.is_server_error() {
136 let content = resp.text().await?;
137 match content_type {
138 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
139 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskDatasetVersions`"))),
140 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::RiskDatasetVersions`")))),
141 }
142 } else {
143 let content = resp.text().await?;
144 let entity: Option<RiskDatasetError> = serde_json::from_str(&content).ok();
145 Err(Error::ResponseError(ResponseContent { status, content, entity }))
146 }
147}
148
149pub async fn risk_dataset_lineage(configuration: &configuration::Configuration, name: &str, version: Option<i32>) -> Result<models::RiskLineage, Error<RiskDatasetLineageError>> {
151 let p_name = name;
153 let p_version = version;
154
155 let uri_str = format!("{}/v1/dataset/{name}/lineage", configuration.base_path, name=crate::apis::urlencode(p_name));
156 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
157
158 if let Some(ref param_value) = p_version {
159 req_builder = req_builder.query(&[("version", ¶m_value.to_string())]);
160 }
161 if let Some(ref user_agent) = configuration.user_agent {
162 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
163 }
164 if let Some(ref token) = configuration.bearer_access_token {
165 req_builder = req_builder.bearer_auth(token.to_owned());
166 };
167
168 let req = req_builder.build()?;
169 let resp = configuration.client.execute(req).await?;
170
171 let status = resp.status();
172 let content_type = resp
173 .headers()
174 .get("content-type")
175 .and_then(|v| v.to_str().ok())
176 .unwrap_or("application/octet-stream");
177 let content_type = super::ContentType::from(content_type);
178
179 if !status.is_client_error() && !status.is_server_error() {
180 let content = resp.text().await?;
181 match content_type {
182 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
183 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskLineage`"))),
184 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::RiskLineage`")))),
185 }
186 } else {
187 let content = resp.text().await?;
188 let entity: Option<RiskDatasetLineageError> = serde_json::from_str(&content).ok();
189 Err(Error::ResponseError(ResponseContent { status, content, entity }))
190 }
191}
192
193pub async fn risk_datasets(configuration: &configuration::Configuration, ) -> Result<models::RiskDatasetList, Error<RiskDatasetsError>> {
195
196 let uri_str = format!("{}/v1/dataset", configuration.base_path);
197 let mut req_builder = configuration.client.request(reqwest::Method::GET, &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
206 let req = req_builder.build()?;
207 let resp = configuration.client.execute(req).await?;
208
209 let status = resp.status();
210 let content_type = resp
211 .headers()
212 .get("content-type")
213 .and_then(|v| v.to_str().ok())
214 .unwrap_or("application/octet-stream");
215 let content_type = super::ContentType::from(content_type);
216
217 if !status.is_client_error() && !status.is_server_error() {
218 let content = resp.text().await?;
219 match content_type {
220 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
221 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskDatasetList`"))),
222 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::RiskDatasetList`")))),
223 }
224 } else {
225 let content = resp.text().await?;
226 let entity: Option<RiskDatasetsError> = serde_json::from_str(&content).ok();
227 Err(Error::ResponseError(ResponseContent { status, content, entity }))
228 }
229}
230
231pub async fn risk_delete_dataset(configuration: &configuration::Configuration, name: &str) -> Result<models::RiskDatasetDisposal, Error<RiskDeleteDatasetError>> {
233 let p_name = name;
235
236 let uri_str = format!("{}/v1/dataset/{name}", configuration.base_path, name=crate::apis::urlencode(p_name));
237 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
238
239 if let Some(ref user_agent) = configuration.user_agent {
240 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
241 }
242 if let Some(ref token) = configuration.bearer_access_token {
243 req_builder = req_builder.bearer_auth(token.to_owned());
244 };
245
246 let req = req_builder.build()?;
247 let resp = configuration.client.execute(req).await?;
248
249 let status = resp.status();
250 let content_type = resp
251 .headers()
252 .get("content-type")
253 .and_then(|v| v.to_str().ok())
254 .unwrap_or("application/octet-stream");
255 let content_type = super::ContentType::from(content_type);
256
257 if !status.is_client_error() && !status.is_server_error() {
258 let content = resp.text().await?;
259 match content_type {
260 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
261 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskDatasetDisposal`"))),
262 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::RiskDatasetDisposal`")))),
263 }
264 } else {
265 let content = resp.text().await?;
266 let entity: Option<RiskDeleteDatasetError> = serde_json::from_str(&content).ok();
267 Err(Error::ResponseError(ResponseContent { status, content, entity }))
268 }
269}
270
271pub async fn risk_export_dataset(configuration: &configuration::Configuration, name: &str, version: Option<i32>, split: Option<&str>, offset: Option<i32>, limit: Option<i32>) -> Result<models::RiskDatasetRows, Error<RiskExportDatasetError>> {
273 let p_name = name;
275 let p_version = version;
276 let p_split = split;
277 let p_offset = offset;
278 let p_limit = limit;
279
280 let uri_str = format!("{}/v1/dataset/{name}/export", configuration.base_path, name=crate::apis::urlencode(p_name));
281 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
282
283 if let Some(ref param_value) = p_version {
284 req_builder = req_builder.query(&[("version", ¶m_value.to_string())]);
285 }
286 if let Some(ref param_value) = p_split {
287 req_builder = req_builder.query(&[("split", ¶m_value.to_string())]);
288 }
289 if let Some(ref param_value) = p_offset {
290 req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
291 }
292 if let Some(ref param_value) = p_limit {
293 req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
294 }
295 if let Some(ref user_agent) = configuration.user_agent {
296 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
297 }
298 if let Some(ref token) = configuration.bearer_access_token {
299 req_builder = req_builder.bearer_auth(token.to_owned());
300 };
301
302 let req = req_builder.build()?;
303 let resp = configuration.client.execute(req).await?;
304
305 let status = resp.status();
306 let content_type = resp
307 .headers()
308 .get("content-type")
309 .and_then(|v| v.to_str().ok())
310 .unwrap_or("application/octet-stream");
311 let content_type = super::ContentType::from(content_type);
312
313 if !status.is_client_error() && !status.is_server_error() {
314 let content = resp.text().await?;
315 match content_type {
316 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
317 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskDatasetRows`"))),
318 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::RiskDatasetRows`")))),
319 }
320 } else {
321 let content = resp.text().await?;
322 let entity: Option<RiskExportDatasetError> = serde_json::from_str(&content).ok();
323 Err(Error::ResponseError(ResponseContent { status, content, entity }))
324 }
325}
326
327pub async fn risk_materialize_dataset(configuration: &configuration::Configuration, name: &str) -> Result<models::RiskDataset, Error<RiskMaterializeDatasetError>> {
329 let p_name = name;
331
332 let uri_str = format!("{}/v1/dataset/{name}/materialize", configuration.base_path, name=crate::apis::urlencode(p_name));
333 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
334
335 if let Some(ref user_agent) = configuration.user_agent {
336 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
337 }
338 if let Some(ref token) = configuration.bearer_access_token {
339 req_builder = req_builder.bearer_auth(token.to_owned());
340 };
341
342 let req = req_builder.build()?;
343 let resp = configuration.client.execute(req).await?;
344
345 let status = resp.status();
346 let content_type = resp
347 .headers()
348 .get("content-type")
349 .and_then(|v| v.to_str().ok())
350 .unwrap_or("application/octet-stream");
351 let content_type = super::ContentType::from(content_type);
352
353 if !status.is_client_error() && !status.is_server_error() {
354 let content = resp.text().await?;
355 match content_type {
356 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
357 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RiskDataset`"))),
358 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::RiskDataset`")))),
359 }
360 } else {
361 let content = resp.text().await?;
362 let entity: Option<RiskMaterializeDatasetError> = serde_json::from_str(&content).ok();
363 Err(Error::ResponseError(ResponseContent { status, content, entity }))
364 }
365}
366