bitwarden_api_api/apis/
events_api.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`ciphers_id_events_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum CiphersIdEventsGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`events_get`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum EventsGetError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`organizations_id_events_get`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum OrganizationsIdEventsGetError {
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`organizations_org_id_users_id_events_get`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum OrganizationsOrgIdUsersIdEventsGetError {
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`providers_provider_id_events_get`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum ProvidersProviderIdEventsGetError {
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`providers_provider_id_users_id_events_get`]
53#[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 local_var_configuration = configuration;
67
68    let local_var_client = &local_var_configuration.client;
69
70    let local_var_uri_str = format!(
71        "{}/ciphers/{id}/events",
72        local_var_configuration.base_path,
73        id = crate::apis::urlencode(id)
74    );
75    let mut local_var_req_builder =
76        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
77
78    if let Some(ref local_var_str) = start {
79        local_var_req_builder =
80            local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
81    }
82    if let Some(ref local_var_str) = end {
83        local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]);
84    }
85    if let Some(ref local_var_str) = continuation_token {
86        local_var_req_builder =
87            local_var_req_builder.query(&[("continuationToken", &local_var_str.to_string())]);
88    }
89    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
90        local_var_req_builder =
91            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
92    }
93    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
94        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
95    };
96
97    let local_var_req = local_var_req_builder.build()?;
98    let local_var_resp = local_var_client.execute(local_var_req).await?;
99
100    let local_var_status = local_var_resp.status();
101    let local_var_content = local_var_resp.text().await?;
102
103    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
104        serde_json::from_str(&local_var_content).map_err(Error::from)
105    } else {
106        let local_var_entity: Option<CiphersIdEventsGetError> =
107            serde_json::from_str(&local_var_content).ok();
108        let local_var_error = ResponseContent {
109            status: local_var_status,
110            content: local_var_content,
111            entity: local_var_entity,
112        };
113        Err(Error::ResponseError(local_var_error))
114    }
115}
116
117pub async fn events_get(
118    configuration: &configuration::Configuration,
119    start: Option<String>,
120    end: Option<String>,
121    continuation_token: Option<&str>,
122) -> Result<models::EventResponseModelListResponseModel, Error<EventsGetError>> {
123    let local_var_configuration = configuration;
124
125    let local_var_client = &local_var_configuration.client;
126
127    let local_var_uri_str = format!("{}/events", local_var_configuration.base_path);
128    let mut local_var_req_builder =
129        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
130
131    if let Some(ref local_var_str) = start {
132        local_var_req_builder =
133            local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
134    }
135    if let Some(ref local_var_str) = end {
136        local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]);
137    }
138    if let Some(ref local_var_str) = continuation_token {
139        local_var_req_builder =
140            local_var_req_builder.query(&[("continuationToken", &local_var_str.to_string())]);
141    }
142    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
143        local_var_req_builder =
144            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
145    }
146    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
147        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
148    };
149
150    let local_var_req = local_var_req_builder.build()?;
151    let local_var_resp = local_var_client.execute(local_var_req).await?;
152
153    let local_var_status = local_var_resp.status();
154    let local_var_content = local_var_resp.text().await?;
155
156    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
157        serde_json::from_str(&local_var_content).map_err(Error::from)
158    } else {
159        let local_var_entity: Option<EventsGetError> =
160            serde_json::from_str(&local_var_content).ok();
161        let local_var_error = ResponseContent {
162            status: local_var_status,
163            content: local_var_content,
164            entity: local_var_entity,
165        };
166        Err(Error::ResponseError(local_var_error))
167    }
168}
169
170pub async fn organizations_id_events_get(
171    configuration: &configuration::Configuration,
172    id: &str,
173    start: Option<String>,
174    end: Option<String>,
175    continuation_token: Option<&str>,
176) -> Result<models::EventResponseModelListResponseModel, Error<OrganizationsIdEventsGetError>> {
177    let local_var_configuration = configuration;
178
179    let local_var_client = &local_var_configuration.client;
180
181    let local_var_uri_str = format!(
182        "{}/organizations/{id}/events",
183        local_var_configuration.base_path,
184        id = crate::apis::urlencode(id)
185    );
186    let mut local_var_req_builder =
187        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
188
189    if let Some(ref local_var_str) = start {
190        local_var_req_builder =
191            local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
192    }
193    if let Some(ref local_var_str) = end {
194        local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]);
195    }
196    if let Some(ref local_var_str) = continuation_token {
197        local_var_req_builder =
198            local_var_req_builder.query(&[("continuationToken", &local_var_str.to_string())]);
199    }
200    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
201        local_var_req_builder =
202            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
203    }
204    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
205        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
206    };
207
208    let local_var_req = local_var_req_builder.build()?;
209    let local_var_resp = local_var_client.execute(local_var_req).await?;
210
211    let local_var_status = local_var_resp.status();
212    let local_var_content = local_var_resp.text().await?;
213
214    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
215        serde_json::from_str(&local_var_content).map_err(Error::from)
216    } else {
217        let local_var_entity: Option<OrganizationsIdEventsGetError> =
218            serde_json::from_str(&local_var_content).ok();
219        let local_var_error = ResponseContent {
220            status: local_var_status,
221            content: local_var_content,
222            entity: local_var_entity,
223        };
224        Err(Error::ResponseError(local_var_error))
225    }
226}
227
228pub async fn organizations_org_id_users_id_events_get(
229    configuration: &configuration::Configuration,
230    org_id: &str,
231    id: &str,
232    start: Option<String>,
233    end: Option<String>,
234    continuation_token: Option<&str>,
235) -> Result<
236    models::EventResponseModelListResponseModel,
237    Error<OrganizationsOrgIdUsersIdEventsGetError>,
238> {
239    let local_var_configuration = configuration;
240
241    let local_var_client = &local_var_configuration.client;
242
243    let local_var_uri_str = format!(
244        "{}/organizations/{orgId}/users/{id}/events",
245        local_var_configuration.base_path,
246        orgId = crate::apis::urlencode(org_id),
247        id = crate::apis::urlencode(id)
248    );
249    let mut local_var_req_builder =
250        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
251
252    if let Some(ref local_var_str) = start {
253        local_var_req_builder =
254            local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
255    }
256    if let Some(ref local_var_str) = end {
257        local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]);
258    }
259    if let Some(ref local_var_str) = continuation_token {
260        local_var_req_builder =
261            local_var_req_builder.query(&[("continuationToken", &local_var_str.to_string())]);
262    }
263    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
264        local_var_req_builder =
265            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
266    }
267    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
268        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
269    };
270
271    let local_var_req = local_var_req_builder.build()?;
272    let local_var_resp = local_var_client.execute(local_var_req).await?;
273
274    let local_var_status = local_var_resp.status();
275    let local_var_content = local_var_resp.text().await?;
276
277    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
278        serde_json::from_str(&local_var_content).map_err(Error::from)
279    } else {
280        let local_var_entity: Option<OrganizationsOrgIdUsersIdEventsGetError> =
281            serde_json::from_str(&local_var_content).ok();
282        let local_var_error = ResponseContent {
283            status: local_var_status,
284            content: local_var_content,
285            entity: local_var_entity,
286        };
287        Err(Error::ResponseError(local_var_error))
288    }
289}
290
291pub async fn providers_provider_id_events_get(
292    configuration: &configuration::Configuration,
293    provider_id: uuid::Uuid,
294    start: Option<String>,
295    end: Option<String>,
296    continuation_token: Option<&str>,
297) -> Result<models::EventResponseModelListResponseModel, Error<ProvidersProviderIdEventsGetError>> {
298    let local_var_configuration = configuration;
299
300    let local_var_client = &local_var_configuration.client;
301
302    let local_var_uri_str = format!(
303        "{}/providers/{providerId}/events",
304        local_var_configuration.base_path,
305        providerId = crate::apis::urlencode(provider_id.to_string())
306    );
307    let mut local_var_req_builder =
308        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
309
310    if let Some(ref local_var_str) = start {
311        local_var_req_builder =
312            local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
313    }
314    if let Some(ref local_var_str) = end {
315        local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]);
316    }
317    if let Some(ref local_var_str) = continuation_token {
318        local_var_req_builder =
319            local_var_req_builder.query(&[("continuationToken", &local_var_str.to_string())]);
320    }
321    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
322        local_var_req_builder =
323            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
324    }
325    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
326        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
327    };
328
329    let local_var_req = local_var_req_builder.build()?;
330    let local_var_resp = local_var_client.execute(local_var_req).await?;
331
332    let local_var_status = local_var_resp.status();
333    let local_var_content = local_var_resp.text().await?;
334
335    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
336        serde_json::from_str(&local_var_content).map_err(Error::from)
337    } else {
338        let local_var_entity: Option<ProvidersProviderIdEventsGetError> =
339            serde_json::from_str(&local_var_content).ok();
340        let local_var_error = ResponseContent {
341            status: local_var_status,
342            content: local_var_content,
343            entity: local_var_entity,
344        };
345        Err(Error::ResponseError(local_var_error))
346    }
347}
348
349pub async fn providers_provider_id_users_id_events_get(
350    configuration: &configuration::Configuration,
351    provider_id: uuid::Uuid,
352    id: uuid::Uuid,
353    start: Option<String>,
354    end: Option<String>,
355    continuation_token: Option<&str>,
356) -> Result<
357    models::EventResponseModelListResponseModel,
358    Error<ProvidersProviderIdUsersIdEventsGetError>,
359> {
360    let local_var_configuration = configuration;
361
362    let local_var_client = &local_var_configuration.client;
363
364    let local_var_uri_str = format!(
365        "{}/providers/{providerId}/users/{id}/events",
366        local_var_configuration.base_path,
367        providerId = crate::apis::urlencode(provider_id.to_string()),
368        id = crate::apis::urlencode(id.to_string())
369    );
370    let mut local_var_req_builder =
371        local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
372
373    if let Some(ref local_var_str) = start {
374        local_var_req_builder =
375            local_var_req_builder.query(&[("start", &local_var_str.to_string())]);
376    }
377    if let Some(ref local_var_str) = end {
378        local_var_req_builder = local_var_req_builder.query(&[("end", &local_var_str.to_string())]);
379    }
380    if let Some(ref local_var_str) = continuation_token {
381        local_var_req_builder =
382            local_var_req_builder.query(&[("continuationToken", &local_var_str.to_string())]);
383    }
384    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
385        local_var_req_builder =
386            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
387    }
388    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
389        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
390    };
391
392    let local_var_req = local_var_req_builder.build()?;
393    let local_var_resp = local_var_client.execute(local_var_req).await?;
394
395    let local_var_status = local_var_resp.status();
396    let local_var_content = local_var_resp.text().await?;
397
398    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
399        serde_json::from_str(&local_var_content).map_err(Error::from)
400    } else {
401        let local_var_entity: Option<ProvidersProviderIdUsersIdEventsGetError> =
402            serde_json::from_str(&local_var_content).ok();
403        let local_var_error = ResponseContent {
404            status: local_var_status,
405            content: local_var_content,
406            entity: local_var_entity,
407        };
408        Err(Error::ResponseError(local_var_error))
409    }
410}