bitwarden_api_api/apis/
organization_connections_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 [`organizations_connections_enabled_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum OrganizationsConnectionsEnabledGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method
25/// [`organizations_connections_organization_connection_id_delete`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum OrganizationsConnectionsOrganizationConnectionIdDeleteError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method
33/// [`organizations_connections_organization_connection_id_delete_post`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum OrganizationsConnectionsOrganizationConnectionIdDeletePostError {
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method [`organizations_connections_organization_connection_id_put`]
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum OrganizationsConnectionsOrganizationConnectionIdPutError {
44    UnknownValue(serde_json::Value),
45}
46
47/// struct for typed errors of method [`organizations_connections_organization_id_type_get`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum OrganizationsConnectionsOrganizationIdTypeGetError {
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`organizations_connections_post`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum OrganizationsConnectionsPostError {
58    UnknownValue(serde_json::Value),
59}
60
61pub async fn organizations_connections_enabled_get(
62    configuration: &configuration::Configuration,
63) -> Result<bool, Error<OrganizationsConnectionsEnabledGetError>> {
64    let uri_str = format!(
65        "{}/organizations/connections/enabled",
66        configuration.base_path
67    );
68    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
69
70    if let Some(ref user_agent) = configuration.user_agent {
71        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
72    }
73    if let Some(ref token) = configuration.oauth_access_token {
74        req_builder = req_builder.bearer_auth(token.to_owned());
75    };
76
77    let req = req_builder.build()?;
78    let resp = configuration.client.execute(req).await?;
79
80    let status = resp.status();
81    let content_type = resp
82        .headers()
83        .get("content-type")
84        .and_then(|v| v.to_str().ok())
85        .unwrap_or("application/octet-stream");
86    let content_type = super::ContentType::from(content_type);
87
88    if !status.is_client_error() && !status.is_server_error() {
89        let content = resp.text().await?;
90        match content_type {
91            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
92            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `bool`"))),
93            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `bool`")))),
94        }
95    } else {
96        let content = resp.text().await?;
97        let entity: Option<OrganizationsConnectionsEnabledGetError> =
98            serde_json::from_str(&content).ok();
99        Err(Error::ResponseError(ResponseContent {
100            status,
101            content,
102            entity,
103        }))
104    }
105}
106
107pub async fn organizations_connections_organization_connection_id_delete(
108    configuration: &configuration::Configuration,
109    organization_connection_id: uuid::Uuid,
110) -> Result<(), Error<OrganizationsConnectionsOrganizationConnectionIdDeleteError>> {
111    // add a prefix to parameters to efficiently prevent name collisions
112    let p_organization_connection_id = organization_connection_id;
113
114    let uri_str = format!(
115        "{}/organizations/connections/{organizationConnectionId}",
116        configuration.base_path,
117        organizationConnectionId = crate::apis::urlencode(p_organization_connection_id.to_string())
118    );
119    let mut req_builder = configuration
120        .client
121        .request(reqwest::Method::DELETE, &uri_str);
122
123    if let Some(ref user_agent) = configuration.user_agent {
124        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
125    }
126    if let Some(ref token) = configuration.oauth_access_token {
127        req_builder = req_builder.bearer_auth(token.to_owned());
128    };
129
130    let req = req_builder.build()?;
131    let resp = configuration.client.execute(req).await?;
132
133    let status = resp.status();
134
135    if !status.is_client_error() && !status.is_server_error() {
136        Ok(())
137    } else {
138        let content = resp.text().await?;
139        let entity: Option<OrganizationsConnectionsOrganizationConnectionIdDeleteError> =
140            serde_json::from_str(&content).ok();
141        Err(Error::ResponseError(ResponseContent {
142            status,
143            content,
144            entity,
145        }))
146    }
147}
148
149pub async fn organizations_connections_organization_connection_id_delete_post(
150    configuration: &configuration::Configuration,
151    organization_connection_id: uuid::Uuid,
152) -> Result<(), Error<OrganizationsConnectionsOrganizationConnectionIdDeletePostError>> {
153    // add a prefix to parameters to efficiently prevent name collisions
154    let p_organization_connection_id = organization_connection_id;
155
156    let uri_str = format!(
157        "{}/organizations/connections/{organizationConnectionId}/delete",
158        configuration.base_path,
159        organizationConnectionId = crate::apis::urlencode(p_organization_connection_id.to_string())
160    );
161    let mut req_builder = configuration
162        .client
163        .request(reqwest::Method::POST, &uri_str);
164
165    if let Some(ref user_agent) = configuration.user_agent {
166        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
167    }
168    if let Some(ref token) = configuration.oauth_access_token {
169        req_builder = req_builder.bearer_auth(token.to_owned());
170    };
171
172    let req = req_builder.build()?;
173    let resp = configuration.client.execute(req).await?;
174
175    let status = resp.status();
176
177    if !status.is_client_error() && !status.is_server_error() {
178        Ok(())
179    } else {
180        let content = resp.text().await?;
181        let entity: Option<OrganizationsConnectionsOrganizationConnectionIdDeletePostError> =
182            serde_json::from_str(&content).ok();
183        Err(Error::ResponseError(ResponseContent {
184            status,
185            content,
186            entity,
187        }))
188    }
189}
190
191pub async fn organizations_connections_organization_connection_id_put(
192    configuration: &configuration::Configuration,
193    organization_connection_id: uuid::Uuid,
194    organization_connection_request_model: Option<models::OrganizationConnectionRequestModel>,
195) -> Result<
196    models::OrganizationConnectionResponseModel,
197    Error<OrganizationsConnectionsOrganizationConnectionIdPutError>,
198> {
199    // add a prefix to parameters to efficiently prevent name collisions
200    let p_organization_connection_id = organization_connection_id;
201    let p_organization_connection_request_model = organization_connection_request_model;
202
203    let uri_str = format!(
204        "{}/organizations/connections/{organizationConnectionId}",
205        configuration.base_path,
206        organizationConnectionId = crate::apis::urlencode(p_organization_connection_id.to_string())
207    );
208    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
209
210    if let Some(ref user_agent) = configuration.user_agent {
211        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
212    }
213    if let Some(ref token) = configuration.oauth_access_token {
214        req_builder = req_builder.bearer_auth(token.to_owned());
215    };
216    req_builder = req_builder.json(&p_organization_connection_request_model);
217
218    let req = req_builder.build()?;
219    let resp = configuration.client.execute(req).await?;
220
221    let status = resp.status();
222    let content_type = resp
223        .headers()
224        .get("content-type")
225        .and_then(|v| v.to_str().ok())
226        .unwrap_or("application/octet-stream");
227    let content_type = super::ContentType::from(content_type);
228
229    if !status.is_client_error() && !status.is_server_error() {
230        let content = resp.text().await?;
231        match content_type {
232            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
233            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`"))),
234            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::OrganizationConnectionResponseModel`")))),
235        }
236    } else {
237        let content = resp.text().await?;
238        let entity: Option<OrganizationsConnectionsOrganizationConnectionIdPutError> =
239            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_connections_organization_id_type_get(
249    configuration: &configuration::Configuration,
250    organization_id: uuid::Uuid,
251    r#type: models::OrganizationConnectionType,
252) -> Result<
253    models::OrganizationConnectionResponseModel,
254    Error<OrganizationsConnectionsOrganizationIdTypeGetError>,
255> {
256    // add a prefix to parameters to efficiently prevent name collisions
257    let p_organization_id = organization_id;
258    let p_type = r#type;
259
260    let uri_str = format!("{}/organizations/connections/{organizationId}/{type}", configuration.base_path, organizationId=crate::apis::urlencode(p_organization_id.to_string()), type=p_type.to_string());
261    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
262
263    if let Some(ref user_agent) = configuration.user_agent {
264        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
265    }
266    if let Some(ref token) = configuration.oauth_access_token {
267        req_builder = req_builder.bearer_auth(token.to_owned());
268    };
269
270    let req = req_builder.build()?;
271    let resp = configuration.client.execute(req).await?;
272
273    let status = resp.status();
274    let content_type = resp
275        .headers()
276        .get("content-type")
277        .and_then(|v| v.to_str().ok())
278        .unwrap_or("application/octet-stream");
279    let content_type = super::ContentType::from(content_type);
280
281    if !status.is_client_error() && !status.is_server_error() {
282        let content = resp.text().await?;
283        match content_type {
284            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
285            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`"))),
286            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::OrganizationConnectionResponseModel`")))),
287        }
288    } else {
289        let content = resp.text().await?;
290        let entity: Option<OrganizationsConnectionsOrganizationIdTypeGetError> =
291            serde_json::from_str(&content).ok();
292        Err(Error::ResponseError(ResponseContent {
293            status,
294            content,
295            entity,
296        }))
297    }
298}
299
300pub async fn organizations_connections_post(
301    configuration: &configuration::Configuration,
302    organization_connection_request_model: Option<models::OrganizationConnectionRequestModel>,
303) -> Result<models::OrganizationConnectionResponseModel, Error<OrganizationsConnectionsPostError>> {
304    // add a prefix to parameters to efficiently prevent name collisions
305    let p_organization_connection_request_model = organization_connection_request_model;
306
307    let uri_str = format!("{}/organizations/connections", configuration.base_path);
308    let mut req_builder = configuration
309        .client
310        .request(reqwest::Method::POST, &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 token) = configuration.oauth_access_token {
316        req_builder = req_builder.bearer_auth(token.to_owned());
317    };
318    req_builder = req_builder.json(&p_organization_connection_request_model);
319
320    let req = req_builder.build()?;
321    let resp = configuration.client.execute(req).await?;
322
323    let status = resp.status();
324    let content_type = resp
325        .headers()
326        .get("content-type")
327        .and_then(|v| v.to_str().ok())
328        .unwrap_or("application/octet-stream");
329    let content_type = super::ContentType::from(content_type);
330
331    if !status.is_client_error() && !status.is_server_error() {
332        let content = resp.text().await?;
333        match content_type {
334            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
335            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationConnectionResponseModel`"))),
336            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::OrganizationConnectionResponseModel`")))),
337        }
338    } else {
339        let content = resp.text().await?;
340        let entity: Option<OrganizationsConnectionsPostError> = serde_json::from_str(&content).ok();
341        Err(Error::ResponseError(ResponseContent {
342            status,
343            content,
344            entity,
345        }))
346    }
347}