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 AddAnalystDataError {
22 Status403(models::UnauthorizedApiError),
23 DefaultResponse(models::ApiError),
24 UnknownValue(serde_json::Value),
25}
26
27#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum DeleteAnalystDataError {
31 Status403(models::UnauthorizedApiError),
32 Status404(models::NotFoundApiError),
33 DefaultResponse(models::ApiError),
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum EditAnalystDataError {
41 Status403(models::UnauthorizedApiError),
42 DefaultResponse(models::ApiError),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetAnalystDataByIdError {
50 Status403(models::UnauthorizedApiError),
51 DefaultResponse(models::ApiError),
52 UnknownValue(serde_json::Value),
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum IndexAnalystDataError {
59 Status403(models::UnauthorizedApiError),
60 Status404(models::NotFoundApiError),
61 DefaultResponse(models::ApiError),
62 UnknownValue(serde_json::Value),
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum IndexMinimalAnalystDataError {
69 Status403(models::UnauthorizedApiError),
70 Status404(models::NotFoundApiError),
71 DefaultResponse(models::ApiError),
72 UnknownValue(serde_json::Value),
73}
74
75
76pub async fn add_analyst_data(configuration: &configuration::Configuration, analyst_type: models::AnalystDataType, analyst_object_uuid: &str, analyst_object_type: models::AnalystObjectType, add_analyst_data_request: models::AddAnalystDataRequest) -> Result<models::AddAnalystDataRequest, Error<AddAnalystDataError>> {
77 let p_analyst_type = analyst_type;
79 let p_analyst_object_uuid = analyst_object_uuid;
80 let p_analyst_object_type = analyst_object_type;
81 let p_add_analyst_data_request = add_analyst_data_request;
82
83 let uri_str = format!("{}/analystData/add/{analystType}/{analystObjectUUID}/{analystObjectType}", configuration.base_path, analystType=p_analyst_type.to_string(), analystObjectUUID=crate::apis::urlencode(p_analyst_object_uuid), analystObjectType=p_analyst_object_type.to_string());
84 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
85
86 if let Some(ref user_agent) = configuration.user_agent {
87 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
88 }
89 if let Some(ref apikey) = configuration.api_key {
90 let key = apikey.key.clone();
91 let value = match apikey.prefix {
92 Some(ref prefix) => format!("{} {}", prefix, key),
93 None => key,
94 };
95 req_builder = req_builder.header("Authorization", value);
96 };
97 req_builder = req_builder.json(&p_add_analyst_data_request);
98
99 let req = req_builder.build()?;
100 let resp = configuration.client.execute(req).await?;
101
102 let status = resp.status();
103 let content_type = resp
104 .headers()
105 .get("content-type")
106 .and_then(|v| v.to_str().ok())
107 .unwrap_or("application/octet-stream");
108 let content_type = super::ContentType::from(content_type);
109
110 if !status.is_client_error() && !status.is_server_error() {
111 let content = resp.text().await?;
112 match content_type {
113 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
114 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddAnalystDataRequest`"))),
115 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::AddAnalystDataRequest`")))),
116 }
117 } else {
118 let content = resp.text().await?;
119 let entity: Option<AddAnalystDataError> = serde_json::from_str(&content).ok();
120 Err(Error::ResponseError(ResponseContent { status, content, entity }))
121 }
122}
123
124pub async fn delete_analyst_data(configuration: &configuration::Configuration, analyst_type: models::AnalystDataType, analyst_data_id: &str) -> Result<models::DeleteAnalystData200Response, Error<DeleteAnalystDataError>> {
125 let p_analyst_type = analyst_type;
127 let p_analyst_data_id = analyst_data_id;
128
129 let uri_str = format!("{}/analystData/delete/{analystType}/{analystDataID}", configuration.base_path, analystType=p_analyst_type.to_string(), analystDataID=p_analyst_data_id.to_string());
130 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
131
132 if let Some(ref user_agent) = configuration.user_agent {
133 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
134 }
135 if let Some(ref apikey) = configuration.api_key {
136 let key = apikey.key.clone();
137 let value = match apikey.prefix {
138 Some(ref prefix) => format!("{} {}", prefix, key),
139 None => key,
140 };
141 req_builder = req_builder.header("Authorization", value);
142 };
143
144 let req = req_builder.build()?;
145 let resp = configuration.client.execute(req).await?;
146
147 let status = resp.status();
148 let content_type = resp
149 .headers()
150 .get("content-type")
151 .and_then(|v| v.to_str().ok())
152 .unwrap_or("application/octet-stream");
153 let content_type = super::ContentType::from(content_type);
154
155 if !status.is_client_error() && !status.is_server_error() {
156 let content = resp.text().await?;
157 match content_type {
158 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
159 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAnalystData200Response`"))),
160 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::DeleteAnalystData200Response`")))),
161 }
162 } else {
163 let content = resp.text().await?;
164 let entity: Option<DeleteAnalystDataError> = serde_json::from_str(&content).ok();
165 Err(Error::ResponseError(ResponseContent { status, content, entity }))
166 }
167}
168
169pub async fn edit_analyst_data(configuration: &configuration::Configuration, analyst_type: models::AnalystDataType, analyst_data_id: &str, add_analyst_data_request: models::AddAnalystDataRequest) -> Result<models::AddAnalystDataRequest, Error<EditAnalystDataError>> {
170 let p_analyst_type = analyst_type;
172 let p_analyst_data_id = analyst_data_id;
173 let p_add_analyst_data_request = add_analyst_data_request;
174
175 let uri_str = format!("{}/analystData/edit/{analystType}/{analystDataID}", configuration.base_path, analystType=p_analyst_type.to_string(), analystDataID=p_analyst_data_id.to_string());
176 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
177
178 if let Some(ref user_agent) = configuration.user_agent {
179 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
180 }
181 if let Some(ref apikey) = configuration.api_key {
182 let key = apikey.key.clone();
183 let value = match apikey.prefix {
184 Some(ref prefix) => format!("{} {}", prefix, key),
185 None => key,
186 };
187 req_builder = req_builder.header("Authorization", value);
188 };
189 req_builder = req_builder.json(&p_add_analyst_data_request);
190
191 let req = req_builder.build()?;
192 let resp = configuration.client.execute(req).await?;
193
194 let status = resp.status();
195 let content_type = resp
196 .headers()
197 .get("content-type")
198 .and_then(|v| v.to_str().ok())
199 .unwrap_or("application/octet-stream");
200 let content_type = super::ContentType::from(content_type);
201
202 if !status.is_client_error() && !status.is_server_error() {
203 let content = resp.text().await?;
204 match content_type {
205 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
206 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddAnalystDataRequest`"))),
207 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::AddAnalystDataRequest`")))),
208 }
209 } else {
210 let content = resp.text().await?;
211 let entity: Option<EditAnalystDataError> = serde_json::from_str(&content).ok();
212 Err(Error::ResponseError(ResponseContent { status, content, entity }))
213 }
214}
215
216pub async fn get_analyst_data_by_id(configuration: &configuration::Configuration, analyst_type: models::AnalystDataType, analyst_data_id: &str) -> Result<models::AddAnalystDataRequest, Error<GetAnalystDataByIdError>> {
217 let p_analyst_type = analyst_type;
219 let p_analyst_data_id = analyst_data_id;
220
221 let uri_str = format!("{}/analystData/view/{analystType}/{analystDataID}", configuration.base_path, analystType=p_analyst_type.to_string(), analystDataID=p_analyst_data_id.to_string());
222 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
223
224 if let Some(ref user_agent) = configuration.user_agent {
225 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
226 }
227 if let Some(ref apikey) = configuration.api_key {
228 let key = apikey.key.clone();
229 let value = match apikey.prefix {
230 Some(ref prefix) => format!("{} {}", prefix, key),
231 None => key,
232 };
233 req_builder = req_builder.header("Authorization", value);
234 };
235
236 let req = req_builder.build()?;
237 let resp = configuration.client.execute(req).await?;
238
239 let status = resp.status();
240 let content_type = resp
241 .headers()
242 .get("content-type")
243 .and_then(|v| v.to_str().ok())
244 .unwrap_or("application/octet-stream");
245 let content_type = super::ContentType::from(content_type);
246
247 if !status.is_client_error() && !status.is_server_error() {
248 let content = resp.text().await?;
249 match content_type {
250 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
251 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AddAnalystDataRequest`"))),
252 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::AddAnalystDataRequest`")))),
253 }
254 } else {
255 let content = resp.text().await?;
256 let entity: Option<GetAnalystDataByIdError> = serde_json::from_str(&content).ok();
257 Err(Error::ResponseError(ResponseContent { status, content, entity }))
258 }
259}
260
261pub async fn index_analyst_data(configuration: &configuration::Configuration, analyst_type: models::AnalystDataType) -> Result<Vec<models::AddAnalystDataRequest>, Error<IndexAnalystDataError>> {
262 let p_analyst_type = analyst_type;
264
265 let uri_str = format!("{}/analystData/index/{analystType}", configuration.base_path, analystType=p_analyst_type.to_string());
266 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
267
268 if let Some(ref user_agent) = configuration.user_agent {
269 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
270 }
271 if let Some(ref apikey) = configuration.api_key {
272 let key = apikey.key.clone();
273 let value = match apikey.prefix {
274 Some(ref prefix) => format!("{} {}", prefix, key),
275 None => key,
276 };
277 req_builder = req_builder.header("Authorization", value);
278 };
279
280 let req = req_builder.build()?;
281 let resp = configuration.client.execute(req).await?;
282
283 let status = resp.status();
284 let content_type = resp
285 .headers()
286 .get("content-type")
287 .and_then(|v| v.to_str().ok())
288 .unwrap_or("application/octet-stream");
289 let content_type = super::ContentType::from(content_type);
290
291 if !status.is_client_error() && !status.is_server_error() {
292 let content = resp.text().await?;
293 match content_type {
294 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
295 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::AddAnalystDataRequest>`"))),
296 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::AddAnalystDataRequest>`")))),
297 }
298 } else {
299 let content = resp.text().await?;
300 let entity: Option<IndexAnalystDataError> = serde_json::from_str(&content).ok();
301 Err(Error::ResponseError(ResponseContent { status, content, entity }))
302 }
303}
304
305pub async fn index_minimal_analyst_data(configuration: &configuration::Configuration, index_minimal_analyst_data_request: Option<models::IndexMinimalAnalystDataRequest>) -> Result<models::IndexMinimalAnalystData200Response, Error<IndexMinimalAnalystDataError>> {
306 let p_index_minimal_analyst_data_request = index_minimal_analyst_data_request;
308
309 let uri_str = format!("{}/analystData/indexMinimal", configuration.base_path);
310 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
311
312 if let Some(ref user_agent) = configuration.user_agent {
313 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
314 }
315 if let Some(ref apikey) = configuration.api_key {
316 let key = apikey.key.clone();
317 let value = match apikey.prefix {
318 Some(ref prefix) => format!("{} {}", prefix, key),
319 None => key,
320 };
321 req_builder = req_builder.header("Authorization", value);
322 };
323 req_builder = req_builder.json(&p_index_minimal_analyst_data_request);
324
325 let req = req_builder.build()?;
326 let resp = configuration.client.execute(req).await?;
327
328 let status = resp.status();
329 let content_type = resp
330 .headers()
331 .get("content-type")
332 .and_then(|v| v.to_str().ok())
333 .unwrap_or("application/octet-stream");
334 let content_type = super::ContentType::from(content_type);
335
336 if !status.is_client_error() && !status.is_server_error() {
337 let content = resp.text().await?;
338 match content_type {
339 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
340 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::IndexMinimalAnalystData200Response`"))),
341 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::IndexMinimalAnalystData200Response`")))),
342 }
343 } else {
344 let content = resp.text().await?;
345 let entity: Option<IndexMinimalAnalystDataError> = serde_json::from_str(&content).ok();
346 Err(Error::ResponseError(ResponseContent { status, content, entity }))
347 }
348}
349