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