1use reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum CiphersIdEventsGetError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum EventsGetError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum OrganizationsIdEventsGetError {
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum OrganizationsOrgIdUsersIdEventsGetError {
42 UnknownValue(serde_json::Value),
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum ProvidersProviderIdEventsGetError {
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum ProvidersProviderIdUsersIdEventsGetError {
56 UnknownValue(serde_json::Value),
57}
58
59pub async fn ciphers_id_events_get(
60 configuration: &configuration::Configuration,
61 id: &str,
62 start: Option<String>,
63 end: Option<String>,
64 continuation_token: Option<&str>,
65) -> Result<models::EventResponseModelListResponseModel, Error<CiphersIdEventsGetError>> {
66 let p_id = id;
68 let p_start = start;
69 let p_end = end;
70 let p_continuation_token = continuation_token;
71
72 let uri_str = format!(
73 "{}/ciphers/{id}/events",
74 configuration.base_path,
75 id = crate::apis::urlencode(p_id)
76 );
77 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
78
79 if let Some(ref param_value) = p_start {
80 req_builder = req_builder.query(&[("start", ¶m_value.to_string())]);
81 }
82 if let Some(ref param_value) = p_end {
83 req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
84 }
85 if let Some(ref param_value) = p_continuation_token {
86 req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
87 }
88 if let Some(ref user_agent) = configuration.user_agent {
89 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
90 }
91 if let Some(ref token) = configuration.oauth_access_token {
92 req_builder = req_builder.bearer_auth(token.to_owned());
93 };
94
95 let req = req_builder.build()?;
96 let resp = configuration.client.execute(req).await?;
97
98 let status = resp.status();
99 let content_type = resp
100 .headers()
101 .get("content-type")
102 .and_then(|v| v.to_str().ok())
103 .unwrap_or("application/octet-stream");
104 let content_type = super::ContentType::from(content_type);
105
106 if !status.is_client_error() && !status.is_server_error() {
107 let content = resp.text().await?;
108 match content_type {
109 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
110 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))),
111 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::EventResponseModelListResponseModel`")))),
112 }
113 } else {
114 let content = resp.text().await?;
115 let entity: Option<CiphersIdEventsGetError> = serde_json::from_str(&content).ok();
116 Err(Error::ResponseError(ResponseContent {
117 status,
118 content,
119 entity,
120 }))
121 }
122}
123
124pub async fn events_get(
125 configuration: &configuration::Configuration,
126 start: Option<String>,
127 end: Option<String>,
128 continuation_token: Option<&str>,
129) -> Result<models::EventResponseModelListResponseModel, Error<EventsGetError>> {
130 let p_start = start;
132 let p_end = end;
133 let p_continuation_token = continuation_token;
134
135 let uri_str = format!("{}/events", configuration.base_path);
136 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
137
138 if let Some(ref param_value) = p_start {
139 req_builder = req_builder.query(&[("start", ¶m_value.to_string())]);
140 }
141 if let Some(ref param_value) = p_end {
142 req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
143 }
144 if let Some(ref param_value) = p_continuation_token {
145 req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
146 }
147 if let Some(ref user_agent) = configuration.user_agent {
148 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
149 }
150 if let Some(ref token) = configuration.oauth_access_token {
151 req_builder = req_builder.bearer_auth(token.to_owned());
152 };
153
154 let req = req_builder.build()?;
155 let resp = configuration.client.execute(req).await?;
156
157 let status = resp.status();
158 let content_type = resp
159 .headers()
160 .get("content-type")
161 .and_then(|v| v.to_str().ok())
162 .unwrap_or("application/octet-stream");
163 let content_type = super::ContentType::from(content_type);
164
165 if !status.is_client_error() && !status.is_server_error() {
166 let content = resp.text().await?;
167 match content_type {
168 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
169 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))),
170 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::EventResponseModelListResponseModel`")))),
171 }
172 } else {
173 let content = resp.text().await?;
174 let entity: Option<EventsGetError> = serde_json::from_str(&content).ok();
175 Err(Error::ResponseError(ResponseContent {
176 status,
177 content,
178 entity,
179 }))
180 }
181}
182
183pub async fn organizations_id_events_get(
184 configuration: &configuration::Configuration,
185 id: &str,
186 start: Option<String>,
187 end: Option<String>,
188 continuation_token: Option<&str>,
189) -> Result<models::EventResponseModelListResponseModel, Error<OrganizationsIdEventsGetError>> {
190 let p_id = id;
192 let p_start = start;
193 let p_end = end;
194 let p_continuation_token = continuation_token;
195
196 let uri_str = format!(
197 "{}/organizations/{id}/events",
198 configuration.base_path,
199 id = crate::apis::urlencode(p_id)
200 );
201 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
202
203 if let Some(ref param_value) = p_start {
204 req_builder = req_builder.query(&[("start", ¶m_value.to_string())]);
205 }
206 if let Some(ref param_value) = p_end {
207 req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
208 }
209 if let Some(ref param_value) = p_continuation_token {
210 req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
211 }
212 if let Some(ref user_agent) = configuration.user_agent {
213 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
214 }
215 if let Some(ref token) = configuration.oauth_access_token {
216 req_builder = req_builder.bearer_auth(token.to_owned());
217 };
218
219 let req = req_builder.build()?;
220 let resp = configuration.client.execute(req).await?;
221
222 let status = resp.status();
223 let content_type = resp
224 .headers()
225 .get("content-type")
226 .and_then(|v| v.to_str().ok())
227 .unwrap_or("application/octet-stream");
228 let content_type = super::ContentType::from(content_type);
229
230 if !status.is_client_error() && !status.is_server_error() {
231 let content = resp.text().await?;
232 match content_type {
233 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
234 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))),
235 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::EventResponseModelListResponseModel`")))),
236 }
237 } else {
238 let content = resp.text().await?;
239 let entity: Option<OrganizationsIdEventsGetError> = serde_json::from_str(&content).ok();
240 Err(Error::ResponseError(ResponseContent {
241 status,
242 content,
243 entity,
244 }))
245 }
246}
247
248pub async fn organizations_org_id_users_id_events_get(
249 configuration: &configuration::Configuration,
250 org_id: &str,
251 id: &str,
252 start: Option<String>,
253 end: Option<String>,
254 continuation_token: Option<&str>,
255) -> Result<
256 models::EventResponseModelListResponseModel,
257 Error<OrganizationsOrgIdUsersIdEventsGetError>,
258> {
259 let p_org_id = org_id;
261 let p_id = id;
262 let p_start = start;
263 let p_end = end;
264 let p_continuation_token = continuation_token;
265
266 let uri_str = format!(
267 "{}/organizations/{orgId}/users/{id}/events",
268 configuration.base_path,
269 orgId = crate::apis::urlencode(p_org_id),
270 id = crate::apis::urlencode(p_id)
271 );
272 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
273
274 if let Some(ref param_value) = p_start {
275 req_builder = req_builder.query(&[("start", ¶m_value.to_string())]);
276 }
277 if let Some(ref param_value) = p_end {
278 req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
279 }
280 if let Some(ref param_value) = p_continuation_token {
281 req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
282 }
283 if let Some(ref user_agent) = configuration.user_agent {
284 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
285 }
286 if let Some(ref token) = configuration.oauth_access_token {
287 req_builder = req_builder.bearer_auth(token.to_owned());
288 };
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::EventResponseModelListResponseModel`"))),
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::EventResponseModelListResponseModel`")))),
307 }
308 } else {
309 let content = resp.text().await?;
310 let entity: Option<OrganizationsOrgIdUsersIdEventsGetError> =
311 serde_json::from_str(&content).ok();
312 Err(Error::ResponseError(ResponseContent {
313 status,
314 content,
315 entity,
316 }))
317 }
318}
319
320pub async fn providers_provider_id_events_get(
321 configuration: &configuration::Configuration,
322 provider_id: uuid::Uuid,
323 start: Option<String>,
324 end: Option<String>,
325 continuation_token: Option<&str>,
326) -> Result<models::EventResponseModelListResponseModel, Error<ProvidersProviderIdEventsGetError>> {
327 let p_provider_id = provider_id;
329 let p_start = start;
330 let p_end = end;
331 let p_continuation_token = continuation_token;
332
333 let uri_str = format!(
334 "{}/providers/{providerId}/events",
335 configuration.base_path,
336 providerId = crate::apis::urlencode(p_provider_id.to_string())
337 );
338 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
339
340 if let Some(ref param_value) = p_start {
341 req_builder = req_builder.query(&[("start", ¶m_value.to_string())]);
342 }
343 if let Some(ref param_value) = p_end {
344 req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
345 }
346 if let Some(ref param_value) = p_continuation_token {
347 req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
348 }
349 if let Some(ref user_agent) = configuration.user_agent {
350 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
351 }
352 if let Some(ref token) = configuration.oauth_access_token {
353 req_builder = req_builder.bearer_auth(token.to_owned());
354 };
355
356 let req = req_builder.build()?;
357 let resp = configuration.client.execute(req).await?;
358
359 let status = resp.status();
360 let content_type = resp
361 .headers()
362 .get("content-type")
363 .and_then(|v| v.to_str().ok())
364 .unwrap_or("application/octet-stream");
365 let content_type = super::ContentType::from(content_type);
366
367 if !status.is_client_error() && !status.is_server_error() {
368 let content = resp.text().await?;
369 match content_type {
370 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
371 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))),
372 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::EventResponseModelListResponseModel`")))),
373 }
374 } else {
375 let content = resp.text().await?;
376 let entity: Option<ProvidersProviderIdEventsGetError> = serde_json::from_str(&content).ok();
377 Err(Error::ResponseError(ResponseContent {
378 status,
379 content,
380 entity,
381 }))
382 }
383}
384
385pub async fn providers_provider_id_users_id_events_get(
386 configuration: &configuration::Configuration,
387 provider_id: uuid::Uuid,
388 id: uuid::Uuid,
389 start: Option<String>,
390 end: Option<String>,
391 continuation_token: Option<&str>,
392) -> Result<
393 models::EventResponseModelListResponseModel,
394 Error<ProvidersProviderIdUsersIdEventsGetError>,
395> {
396 let p_provider_id = provider_id;
398 let p_id = id;
399 let p_start = start;
400 let p_end = end;
401 let p_continuation_token = continuation_token;
402
403 let uri_str = format!(
404 "{}/providers/{providerId}/users/{id}/events",
405 configuration.base_path,
406 providerId = crate::apis::urlencode(p_provider_id.to_string()),
407 id = crate::apis::urlencode(p_id.to_string())
408 );
409 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
410
411 if let Some(ref param_value) = p_start {
412 req_builder = req_builder.query(&[("start", ¶m_value.to_string())]);
413 }
414 if let Some(ref param_value) = p_end {
415 req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
416 }
417 if let Some(ref param_value) = p_continuation_token {
418 req_builder = req_builder.query(&[("continuationToken", ¶m_value.to_string())]);
419 }
420 if let Some(ref user_agent) = configuration.user_agent {
421 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
422 }
423 if let Some(ref token) = configuration.oauth_access_token {
424 req_builder = req_builder.bearer_auth(token.to_owned());
425 };
426
427 let req = req_builder.build()?;
428 let resp = configuration.client.execute(req).await?;
429
430 let status = resp.status();
431 let content_type = resp
432 .headers()
433 .get("content-type")
434 .and_then(|v| v.to_str().ok())
435 .unwrap_or("application/octet-stream");
436 let content_type = super::ContentType::from(content_type);
437
438 if !status.is_client_error() && !status.is_server_error() {
439 let content = resp.text().await?;
440 match content_type {
441 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
442 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EventResponseModelListResponseModel`"))),
443 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::EventResponseModelListResponseModel`")))),
444 }
445 } else {
446 let content = resp.text().await?;
447 let entity: Option<ProvidersProviderIdUsersIdEventsGetError> =
448 serde_json::from_str(&content).ok();
449 Err(Error::ResponseError(ResponseContent {
450 status,
451 content,
452 entity,
453 }))
454 }
455}