bitwarden_api_api/apis/
reports_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::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`reports_member_access_org_id_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum ReportsMemberAccessOrgIdGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`reports_member_cipher_details_org_id_get`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum ReportsMemberCipherDetailsOrgIdGetError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`reports_password_health_report_application_delete`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum ReportsPasswordHealthReportApplicationDeleteError {
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`reports_password_health_report_application_post`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum ReportsPasswordHealthReportApplicationPostError {
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`reports_password_health_report_applications_org_id_get`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum ReportsPasswordHealthReportApplicationsOrgIdGetError {
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`reports_password_health_report_applications_post`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum ReportsPasswordHealthReportApplicationsPostError {
56    UnknownValue(serde_json::Value),
57}
58
59pub async fn reports_member_access_org_id_get(
60    configuration: &configuration::Configuration,
61    org_id: uuid::Uuid,
62) -> Result<Vec<models::MemberAccessReportResponseModel>, Error<ReportsMemberAccessOrgIdGetError>> {
63    // add a prefix to parameters to efficiently prevent name collisions
64    let p_org_id = org_id;
65
66    let uri_str = format!(
67        "{}/reports/member-access/{orgId}",
68        configuration.base_path,
69        orgId = crate::apis::urlencode(p_org_id.to_string())
70    );
71    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
72
73    if let Some(ref user_agent) = configuration.user_agent {
74        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
75    }
76    if let Some(ref token) = configuration.oauth_access_token {
77        req_builder = req_builder.bearer_auth(token.to_owned());
78    };
79
80    let req = req_builder.build()?;
81    let resp = configuration.client.execute(req).await?;
82
83    let status = resp.status();
84    let content_type = resp
85        .headers()
86        .get("content-type")
87        .and_then(|v| v.to_str().ok())
88        .unwrap_or("application/octet-stream");
89    let content_type = super::ContentType::from(content_type);
90
91    if !status.is_client_error() && !status.is_server_error() {
92        let content = resp.text().await?;
93        match content_type {
94            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
95            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MemberAccessReportResponseModel&gt;`"))),
96            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&lt;models::MemberAccessReportResponseModel&gt;`")))),
97        }
98    } else {
99        let content = resp.text().await?;
100        let entity: Option<ReportsMemberAccessOrgIdGetError> = serde_json::from_str(&content).ok();
101        Err(Error::ResponseError(ResponseContent {
102            status,
103            content,
104            entity,
105        }))
106    }
107}
108
109pub async fn reports_member_cipher_details_org_id_get(
110    configuration: &configuration::Configuration,
111    org_id: uuid::Uuid,
112) -> Result<
113    Vec<models::MemberCipherDetailsResponseModel>,
114    Error<ReportsMemberCipherDetailsOrgIdGetError>,
115> {
116    // add a prefix to parameters to efficiently prevent name collisions
117    let p_org_id = org_id;
118
119    let uri_str = format!(
120        "{}/reports/member-cipher-details/{orgId}",
121        configuration.base_path,
122        orgId = crate::apis::urlencode(p_org_id.to_string())
123    );
124    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
125
126    if let Some(ref user_agent) = configuration.user_agent {
127        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
128    }
129    if let Some(ref token) = configuration.oauth_access_token {
130        req_builder = req_builder.bearer_auth(token.to_owned());
131    };
132
133    let req = req_builder.build()?;
134    let resp = configuration.client.execute(req).await?;
135
136    let status = resp.status();
137    let content_type = resp
138        .headers()
139        .get("content-type")
140        .and_then(|v| v.to_str().ok())
141        .unwrap_or("application/octet-stream");
142    let content_type = super::ContentType::from(content_type);
143
144    if !status.is_client_error() && !status.is_server_error() {
145        let content = resp.text().await?;
146        match content_type {
147            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
148            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MemberCipherDetailsResponseModel&gt;`"))),
149            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&lt;models::MemberCipherDetailsResponseModel&gt;`")))),
150        }
151    } else {
152        let content = resp.text().await?;
153        let entity: Option<ReportsMemberCipherDetailsOrgIdGetError> =
154            serde_json::from_str(&content).ok();
155        Err(Error::ResponseError(ResponseContent {
156            status,
157            content,
158            entity,
159        }))
160    }
161}
162
163pub async fn reports_password_health_report_application_delete(
164    configuration: &configuration::Configuration,
165    drop_password_health_report_application_request: Option<
166        models::DropPasswordHealthReportApplicationRequest,
167    >,
168) -> Result<(), Error<ReportsPasswordHealthReportApplicationDeleteError>> {
169    // add a prefix to parameters to efficiently prevent name collisions
170    let p_drop_password_health_report_application_request =
171        drop_password_health_report_application_request;
172
173    let uri_str = format!(
174        "{}/reports/password-health-report-application",
175        configuration.base_path
176    );
177    let mut req_builder = configuration
178        .client
179        .request(reqwest::Method::DELETE, &uri_str);
180
181    if let Some(ref user_agent) = configuration.user_agent {
182        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
183    }
184    if let Some(ref token) = configuration.oauth_access_token {
185        req_builder = req_builder.bearer_auth(token.to_owned());
186    };
187    req_builder = req_builder.json(&p_drop_password_health_report_application_request);
188
189    let req = req_builder.build()?;
190    let resp = configuration.client.execute(req).await?;
191
192    let status = resp.status();
193
194    if !status.is_client_error() && !status.is_server_error() {
195        Ok(())
196    } else {
197        let content = resp.text().await?;
198        let entity: Option<ReportsPasswordHealthReportApplicationDeleteError> =
199            serde_json::from_str(&content).ok();
200        Err(Error::ResponseError(ResponseContent {
201            status,
202            content,
203            entity,
204        }))
205    }
206}
207
208pub async fn reports_password_health_report_application_post(
209    configuration: &configuration::Configuration,
210    password_health_report_application_model: Option<models::PasswordHealthReportApplicationModel>,
211) -> Result<
212    models::PasswordHealthReportApplication,
213    Error<ReportsPasswordHealthReportApplicationPostError>,
214> {
215    // add a prefix to parameters to efficiently prevent name collisions
216    let p_password_health_report_application_model = password_health_report_application_model;
217
218    let uri_str = format!(
219        "{}/reports/password-health-report-application",
220        configuration.base_path
221    );
222    let mut req_builder = configuration
223        .client
224        .request(reqwest::Method::POST, &uri_str);
225
226    if let Some(ref user_agent) = configuration.user_agent {
227        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
228    }
229    if let Some(ref token) = configuration.oauth_access_token {
230        req_builder = req_builder.bearer_auth(token.to_owned());
231    };
232    req_builder = req_builder.json(&p_password_health_report_application_model);
233
234    let req = req_builder.build()?;
235    let resp = configuration.client.execute(req).await?;
236
237    let status = resp.status();
238    let content_type = resp
239        .headers()
240        .get("content-type")
241        .and_then(|v| v.to_str().ok())
242        .unwrap_or("application/octet-stream");
243    let content_type = super::ContentType::from(content_type);
244
245    if !status.is_client_error() && !status.is_server_error() {
246        let content = resp.text().await?;
247        match content_type {
248            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
249            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PasswordHealthReportApplication`"))),
250            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::PasswordHealthReportApplication`")))),
251        }
252    } else {
253        let content = resp.text().await?;
254        let entity: Option<ReportsPasswordHealthReportApplicationPostError> =
255            serde_json::from_str(&content).ok();
256        Err(Error::ResponseError(ResponseContent {
257            status,
258            content,
259            entity,
260        }))
261    }
262}
263
264pub async fn reports_password_health_report_applications_org_id_get(
265    configuration: &configuration::Configuration,
266    org_id: uuid::Uuid,
267) -> Result<
268    Vec<models::PasswordHealthReportApplication>,
269    Error<ReportsPasswordHealthReportApplicationsOrgIdGetError>,
270> {
271    // add a prefix to parameters to efficiently prevent name collisions
272    let p_org_id = org_id;
273
274    let uri_str = format!(
275        "{}/reports/password-health-report-applications/{orgId}",
276        configuration.base_path,
277        orgId = crate::apis::urlencode(p_org_id.to_string())
278    );
279    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
280
281    if let Some(ref user_agent) = configuration.user_agent {
282        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
283    }
284    if let Some(ref token) = configuration.oauth_access_token {
285        req_builder = req_builder.bearer_auth(token.to_owned());
286    };
287
288    let req = req_builder.build()?;
289    let resp = configuration.client.execute(req).await?;
290
291    let status = resp.status();
292    let content_type = resp
293        .headers()
294        .get("content-type")
295        .and_then(|v| v.to_str().ok())
296        .unwrap_or("application/octet-stream");
297    let content_type = super::ContentType::from(content_type);
298
299    if !status.is_client_error() && !status.is_server_error() {
300        let content = resp.text().await?;
301        match content_type {
302            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
303            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::PasswordHealthReportApplication&gt;`"))),
304            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&lt;models::PasswordHealthReportApplication&gt;`")))),
305        }
306    } else {
307        let content = resp.text().await?;
308        let entity: Option<ReportsPasswordHealthReportApplicationsOrgIdGetError> =
309            serde_json::from_str(&content).ok();
310        Err(Error::ResponseError(ResponseContent {
311            status,
312            content,
313            entity,
314        }))
315    }
316}
317
318pub async fn reports_password_health_report_applications_post(
319    configuration: &configuration::Configuration,
320    password_health_report_application_model: Option<
321        Vec<models::PasswordHealthReportApplicationModel>,
322    >,
323) -> Result<
324    Vec<models::PasswordHealthReportApplication>,
325    Error<ReportsPasswordHealthReportApplicationsPostError>,
326> {
327    // add a prefix to parameters to efficiently prevent name collisions
328    let p_password_health_report_application_model = password_health_report_application_model;
329
330    let uri_str = format!(
331        "{}/reports/password-health-report-applications",
332        configuration.base_path
333    );
334    let mut req_builder = configuration
335        .client
336        .request(reqwest::Method::POST, &uri_str);
337
338    if let Some(ref user_agent) = configuration.user_agent {
339        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
340    }
341    if let Some(ref token) = configuration.oauth_access_token {
342        req_builder = req_builder.bearer_auth(token.to_owned());
343    };
344    req_builder = req_builder.json(&p_password_health_report_application_model);
345
346    let req = req_builder.build()?;
347    let resp = configuration.client.execute(req).await?;
348
349    let status = resp.status();
350    let content_type = resp
351        .headers()
352        .get("content-type")
353        .and_then(|v| v.to_str().ok())
354        .unwrap_or("application/octet-stream");
355    let content_type = super::ContentType::from(content_type);
356
357    if !status.is_client_error() && !status.is_server_error() {
358        let content = resp.text().await?;
359        match content_type {
360            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
361            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::PasswordHealthReportApplication&gt;`"))),
362            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&lt;models::PasswordHealthReportApplication&gt;`")))),
363        }
364    } else {
365        let content = resp.text().await?;
366        let entity: Option<ReportsPasswordHealthReportApplicationsPostError> =
367            serde_json::from_str(&content).ok();
368        Err(Error::ResponseError(ResponseContent {
369            status,
370            content,
371            entity,
372        }))
373    }
374}