bitwarden_api_api/apis/
organization_integration_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_organization_id_integrations_get`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum OrganizationsOrganizationIdIntegrationsGetError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method
25/// [`organizations_organization_id_integrations_integration_id_delete`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdDeleteError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method
33/// [`organizations_organization_id_integrations_integration_id_delete_post`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdDeletePostError {
37    UnknownValue(serde_json::Value),
38}
39
40/// struct for typed errors of method
41/// [`organizations_organization_id_integrations_integration_id_put`]
42#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum OrganizationsOrganizationIdIntegrationsIntegrationIdPutError {
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`organizations_organization_id_integrations_post`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum OrganizationsOrganizationIdIntegrationsPostError {
52    UnknownValue(serde_json::Value),
53}
54
55pub async fn organizations_organization_id_integrations_get(
56    configuration: &configuration::Configuration,
57    organization_id: uuid::Uuid,
58) -> Result<
59    Vec<models::OrganizationIntegrationResponseModel>,
60    Error<OrganizationsOrganizationIdIntegrationsGetError>,
61> {
62    // add a prefix to parameters to efficiently prevent name collisions
63    let p_organization_id = organization_id;
64
65    let uri_str = format!(
66        "{}/organizations/{organizationId}/integrations",
67        configuration.base_path,
68        organizationId = crate::apis::urlencode(p_organization_id.to_string())
69    );
70    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
71
72    if let Some(ref user_agent) = configuration.user_agent {
73        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
74    }
75    if let Some(ref token) = configuration.oauth_access_token {
76        req_builder = req_builder.bearer_auth(token.to_owned());
77    };
78
79    let req = req_builder.build()?;
80    let resp = configuration.client.execute(req).await?;
81
82    let status = resp.status();
83    let content_type = resp
84        .headers()
85        .get("content-type")
86        .and_then(|v| v.to_str().ok())
87        .unwrap_or("application/octet-stream");
88    let content_type = super::ContentType::from(content_type);
89
90    if !status.is_client_error() && !status.is_server_error() {
91        let content = resp.text().await?;
92        match content_type {
93            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
94            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::OrganizationIntegrationResponseModel&gt;`"))),
95            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::OrganizationIntegrationResponseModel&gt;`")))),
96        }
97    } else {
98        let content = resp.text().await?;
99        let entity: Option<OrganizationsOrganizationIdIntegrationsGetError> =
100            serde_json::from_str(&content).ok();
101        Err(Error::ResponseError(ResponseContent {
102            status,
103            content,
104            entity,
105        }))
106    }
107}
108
109pub async fn organizations_organization_id_integrations_integration_id_delete(
110    configuration: &configuration::Configuration,
111    organization_id: uuid::Uuid,
112    integration_id: uuid::Uuid,
113) -> Result<(), Error<OrganizationsOrganizationIdIntegrationsIntegrationIdDeleteError>> {
114    // add a prefix to parameters to efficiently prevent name collisions
115    let p_organization_id = organization_id;
116    let p_integration_id = integration_id;
117
118    let uri_str = format!(
119        "{}/organizations/{organizationId}/integrations/{integrationId}",
120        configuration.base_path,
121        organizationId = crate::apis::urlencode(p_organization_id.to_string()),
122        integrationId = crate::apis::urlencode(p_integration_id.to_string())
123    );
124    let mut req_builder = configuration
125        .client
126        .request(reqwest::Method::DELETE, &uri_str);
127
128    if let Some(ref user_agent) = configuration.user_agent {
129        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
130    }
131    if let Some(ref token) = configuration.oauth_access_token {
132        req_builder = req_builder.bearer_auth(token.to_owned());
133    };
134
135    let req = req_builder.build()?;
136    let resp = configuration.client.execute(req).await?;
137
138    let status = resp.status();
139
140    if !status.is_client_error() && !status.is_server_error() {
141        Ok(())
142    } else {
143        let content = resp.text().await?;
144        let entity: Option<OrganizationsOrganizationIdIntegrationsIntegrationIdDeleteError> =
145            serde_json::from_str(&content).ok();
146        Err(Error::ResponseError(ResponseContent {
147            status,
148            content,
149            entity,
150        }))
151    }
152}
153
154pub async fn organizations_organization_id_integrations_integration_id_delete_post(
155    configuration: &configuration::Configuration,
156    organization_id: uuid::Uuid,
157    integration_id: uuid::Uuid,
158) -> Result<(), Error<OrganizationsOrganizationIdIntegrationsIntegrationIdDeletePostError>> {
159    // add a prefix to parameters to efficiently prevent name collisions
160    let p_organization_id = organization_id;
161    let p_integration_id = integration_id;
162
163    let uri_str = format!(
164        "{}/organizations/{organizationId}/integrations/{integrationId}/delete",
165        configuration.base_path,
166        organizationId = crate::apis::urlencode(p_organization_id.to_string()),
167        integrationId = crate::apis::urlencode(p_integration_id.to_string())
168    );
169    let mut req_builder = configuration
170        .client
171        .request(reqwest::Method::POST, &uri_str);
172
173    if let Some(ref user_agent) = configuration.user_agent {
174        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
175    }
176    if let Some(ref token) = configuration.oauth_access_token {
177        req_builder = req_builder.bearer_auth(token.to_owned());
178    };
179
180    let req = req_builder.build()?;
181    let resp = configuration.client.execute(req).await?;
182
183    let status = resp.status();
184
185    if !status.is_client_error() && !status.is_server_error() {
186        Ok(())
187    } else {
188        let content = resp.text().await?;
189        let entity: Option<OrganizationsOrganizationIdIntegrationsIntegrationIdDeletePostError> =
190            serde_json::from_str(&content).ok();
191        Err(Error::ResponseError(ResponseContent {
192            status,
193            content,
194            entity,
195        }))
196    }
197}
198
199pub async fn organizations_organization_id_integrations_integration_id_put(
200    configuration: &configuration::Configuration,
201    organization_id: uuid::Uuid,
202    integration_id: uuid::Uuid,
203    organization_integration_request_model: Option<models::OrganizationIntegrationRequestModel>,
204) -> Result<
205    models::OrganizationIntegrationResponseModel,
206    Error<OrganizationsOrganizationIdIntegrationsIntegrationIdPutError>,
207> {
208    // add a prefix to parameters to efficiently prevent name collisions
209    let p_organization_id = organization_id;
210    let p_integration_id = integration_id;
211    let p_organization_integration_request_model = organization_integration_request_model;
212
213    let uri_str = format!(
214        "{}/organizations/{organizationId}/integrations/{integrationId}",
215        configuration.base_path,
216        organizationId = crate::apis::urlencode(p_organization_id.to_string()),
217        integrationId = crate::apis::urlencode(p_integration_id.to_string())
218    );
219    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
220
221    if let Some(ref user_agent) = configuration.user_agent {
222        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
223    }
224    if let Some(ref token) = configuration.oauth_access_token {
225        req_builder = req_builder.bearer_auth(token.to_owned());
226    };
227    req_builder = req_builder.json(&p_organization_integration_request_model);
228
229    let req = req_builder.build()?;
230    let resp = configuration.client.execute(req).await?;
231
232    let status = resp.status();
233    let content_type = resp
234        .headers()
235        .get("content-type")
236        .and_then(|v| v.to_str().ok())
237        .unwrap_or("application/octet-stream");
238    let content_type = super::ContentType::from(content_type);
239
240    if !status.is_client_error() && !status.is_server_error() {
241        let content = resp.text().await?;
242        match content_type {
243            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
244            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationIntegrationResponseModel`"))),
245            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::OrganizationIntegrationResponseModel`")))),
246        }
247    } else {
248        let content = resp.text().await?;
249        let entity: Option<OrganizationsOrganizationIdIntegrationsIntegrationIdPutError> =
250            serde_json::from_str(&content).ok();
251        Err(Error::ResponseError(ResponseContent {
252            status,
253            content,
254            entity,
255        }))
256    }
257}
258
259pub async fn organizations_organization_id_integrations_post(
260    configuration: &configuration::Configuration,
261    organization_id: uuid::Uuid,
262    organization_integration_request_model: Option<models::OrganizationIntegrationRequestModel>,
263) -> Result<
264    models::OrganizationIntegrationResponseModel,
265    Error<OrganizationsOrganizationIdIntegrationsPostError>,
266> {
267    // add a prefix to parameters to efficiently prevent name collisions
268    let p_organization_id = organization_id;
269    let p_organization_integration_request_model = organization_integration_request_model;
270
271    let uri_str = format!(
272        "{}/organizations/{organizationId}/integrations",
273        configuration.base_path,
274        organizationId = crate::apis::urlencode(p_organization_id.to_string())
275    );
276    let mut req_builder = configuration
277        .client
278        .request(reqwest::Method::POST, &uri_str);
279
280    if let Some(ref user_agent) = configuration.user_agent {
281        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
282    }
283    if let Some(ref token) = configuration.oauth_access_token {
284        req_builder = req_builder.bearer_auth(token.to_owned());
285    };
286    req_builder = req_builder.json(&p_organization_integration_request_model);
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 `models::OrganizationIntegrationResponseModel`"))),
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 `models::OrganizationIntegrationResponseModel`")))),
305        }
306    } else {
307        let content = resp.text().await?;
308        let entity: Option<OrganizationsOrganizationIdIntegrationsPostError> =
309            serde_json::from_str(&content).ok();
310        Err(Error::ResponseError(ResponseContent {
311            status,
312            content,
313            entity,
314        }))
315    }
316}