bitwarden_api_api/apis/
organization_domain_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_domain_sso_details_post`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum OrganizationsDomainSsoDetailsPostError {
21    UnknownValue(serde_json::Value),
22}
23
24/// struct for typed errors of method [`organizations_domain_sso_verified_post`]
25#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum OrganizationsDomainSsoVerifiedPostError {
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`organizations_org_id_domain_get`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum OrganizationsOrgIdDomainGetError {
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`organizations_org_id_domain_id_delete`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum OrganizationsOrgIdDomainIdDeleteError {
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`organizations_org_id_domain_id_get`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum OrganizationsOrgIdDomainIdGetError {
49    UnknownValue(serde_json::Value),
50}
51
52/// struct for typed errors of method [`organizations_org_id_domain_id_remove_post`]
53#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum OrganizationsOrgIdDomainIdRemovePostError {
56    UnknownValue(serde_json::Value),
57}
58
59/// struct for typed errors of method [`organizations_org_id_domain_id_verify_post`]
60#[derive(Debug, Clone, Serialize, Deserialize)]
61#[serde(untagged)]
62pub enum OrganizationsOrgIdDomainIdVerifyPostError {
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`organizations_org_id_domain_post`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum OrganizationsOrgIdDomainPostError {
70    UnknownValue(serde_json::Value),
71}
72
73pub async fn organizations_domain_sso_details_post(
74    configuration: &configuration::Configuration,
75    organization_domain_sso_details_request_model: Option<
76        models::OrganizationDomainSsoDetailsRequestModel,
77    >,
78) -> Result<
79    models::OrganizationDomainSsoDetailsResponseModel,
80    Error<OrganizationsDomainSsoDetailsPostError>,
81> {
82    // add a prefix to parameters to efficiently prevent name collisions
83    let p_organization_domain_sso_details_request_model =
84        organization_domain_sso_details_request_model;
85
86    let uri_str = format!(
87        "{}/organizations/domain/sso/details",
88        configuration.base_path
89    );
90    let mut req_builder = configuration
91        .client
92        .request(reqwest::Method::POST, &uri_str);
93
94    if let Some(ref user_agent) = configuration.user_agent {
95        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
96    }
97    if let Some(ref token) = configuration.oauth_access_token {
98        req_builder = req_builder.bearer_auth(token.to_owned());
99    };
100    req_builder = req_builder.json(&p_organization_domain_sso_details_request_model);
101
102    let req = req_builder.build()?;
103    let resp = configuration.client.execute(req).await?;
104
105    let status = resp.status();
106    let content_type = resp
107        .headers()
108        .get("content-type")
109        .and_then(|v| v.to_str().ok())
110        .unwrap_or("application/octet-stream");
111    let content_type = super::ContentType::from(content_type);
112
113    if !status.is_client_error() && !status.is_server_error() {
114        let content = resp.text().await?;
115        match content_type {
116            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
117            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainSsoDetailsResponseModel`"))),
118            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::OrganizationDomainSsoDetailsResponseModel`")))),
119        }
120    } else {
121        let content = resp.text().await?;
122        let entity: Option<OrganizationsDomainSsoDetailsPostError> =
123            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_domain_sso_verified_post(
133    configuration: &configuration::Configuration,
134    organization_domain_sso_details_request_model: Option<
135        models::OrganizationDomainSsoDetailsRequestModel,
136    >,
137) -> Result<
138    models::VerifiedOrganizationDomainSsoDetailsResponseModel,
139    Error<OrganizationsDomainSsoVerifiedPostError>,
140> {
141    // add a prefix to parameters to efficiently prevent name collisions
142    let p_organization_domain_sso_details_request_model =
143        organization_domain_sso_details_request_model;
144
145    let uri_str = format!(
146        "{}/organizations/domain/sso/verified",
147        configuration.base_path
148    );
149    let mut req_builder = configuration
150        .client
151        .request(reqwest::Method::POST, &uri_str);
152
153    if let Some(ref user_agent) = configuration.user_agent {
154        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
155    }
156    if let Some(ref token) = configuration.oauth_access_token {
157        req_builder = req_builder.bearer_auth(token.to_owned());
158    };
159    req_builder = req_builder.json(&p_organization_domain_sso_details_request_model);
160
161    let req = req_builder.build()?;
162    let resp = configuration.client.execute(req).await?;
163
164    let status = resp.status();
165    let content_type = resp
166        .headers()
167        .get("content-type")
168        .and_then(|v| v.to_str().ok())
169        .unwrap_or("application/octet-stream");
170    let content_type = super::ContentType::from(content_type);
171
172    if !status.is_client_error() && !status.is_server_error() {
173        let content = resp.text().await?;
174        match content_type {
175            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
176            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerifiedOrganizationDomainSsoDetailsResponseModel`"))),
177            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::VerifiedOrganizationDomainSsoDetailsResponseModel`")))),
178        }
179    } else {
180        let content = resp.text().await?;
181        let entity: Option<OrganizationsDomainSsoVerifiedPostError> =
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_org_id_domain_get(
192    configuration: &configuration::Configuration,
193    org_id: uuid::Uuid,
194) -> Result<
195    models::OrganizationDomainResponseModelListResponseModel,
196    Error<OrganizationsOrgIdDomainGetError>,
197> {
198    // add a prefix to parameters to efficiently prevent name collisions
199    let p_org_id = org_id;
200
201    let uri_str = format!(
202        "{}/organizations/{orgId}/domain",
203        configuration.base_path,
204        orgId = crate::apis::urlencode(p_org_id.to_string())
205    );
206    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
207
208    if let Some(ref user_agent) = configuration.user_agent {
209        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
210    }
211    if let Some(ref token) = configuration.oauth_access_token {
212        req_builder = req_builder.bearer_auth(token.to_owned());
213    };
214
215    let req = req_builder.build()?;
216    let resp = configuration.client.execute(req).await?;
217
218    let status = resp.status();
219    let content_type = resp
220        .headers()
221        .get("content-type")
222        .and_then(|v| v.to_str().ok())
223        .unwrap_or("application/octet-stream");
224    let content_type = super::ContentType::from(content_type);
225
226    if !status.is_client_error() && !status.is_server_error() {
227        let content = resp.text().await?;
228        match content_type {
229            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
230            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModelListResponseModel`"))),
231            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::OrganizationDomainResponseModelListResponseModel`")))),
232        }
233    } else {
234        let content = resp.text().await?;
235        let entity: Option<OrganizationsOrgIdDomainGetError> = serde_json::from_str(&content).ok();
236        Err(Error::ResponseError(ResponseContent {
237            status,
238            content,
239            entity,
240        }))
241    }
242}
243
244pub async fn organizations_org_id_domain_id_delete(
245    configuration: &configuration::Configuration,
246    org_id: uuid::Uuid,
247    id: uuid::Uuid,
248) -> Result<(), Error<OrganizationsOrgIdDomainIdDeleteError>> {
249    // add a prefix to parameters to efficiently prevent name collisions
250    let p_org_id = org_id;
251    let p_id = id;
252
253    let uri_str = format!(
254        "{}/organizations/{orgId}/domain/{id}",
255        configuration.base_path,
256        orgId = crate::apis::urlencode(p_org_id.to_string()),
257        id = crate::apis::urlencode(p_id.to_string())
258    );
259    let mut req_builder = configuration
260        .client
261        .request(reqwest::Method::DELETE, &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
275    if !status.is_client_error() && !status.is_server_error() {
276        Ok(())
277    } else {
278        let content = resp.text().await?;
279        let entity: Option<OrganizationsOrgIdDomainIdDeleteError> =
280            serde_json::from_str(&content).ok();
281        Err(Error::ResponseError(ResponseContent {
282            status,
283            content,
284            entity,
285        }))
286    }
287}
288
289pub async fn organizations_org_id_domain_id_get(
290    configuration: &configuration::Configuration,
291    org_id: uuid::Uuid,
292    id: uuid::Uuid,
293) -> Result<models::OrganizationDomainResponseModel, Error<OrganizationsOrgIdDomainIdGetError>> {
294    // add a prefix to parameters to efficiently prevent name collisions
295    let p_org_id = org_id;
296    let p_id = id;
297
298    let uri_str = format!(
299        "{}/organizations/{orgId}/domain/{id}",
300        configuration.base_path,
301        orgId = crate::apis::urlencode(p_org_id.to_string()),
302        id = crate::apis::urlencode(p_id.to_string())
303    );
304    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
305
306    if let Some(ref user_agent) = configuration.user_agent {
307        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
308    }
309    if let Some(ref token) = configuration.oauth_access_token {
310        req_builder = req_builder.bearer_auth(token.to_owned());
311    };
312
313    let req = req_builder.build()?;
314    let resp = configuration.client.execute(req).await?;
315
316    let status = resp.status();
317    let content_type = resp
318        .headers()
319        .get("content-type")
320        .and_then(|v| v.to_str().ok())
321        .unwrap_or("application/octet-stream");
322    let content_type = super::ContentType::from(content_type);
323
324    if !status.is_client_error() && !status.is_server_error() {
325        let content = resp.text().await?;
326        match content_type {
327            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
328            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"))),
329            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::OrganizationDomainResponseModel`")))),
330        }
331    } else {
332        let content = resp.text().await?;
333        let entity: Option<OrganizationsOrgIdDomainIdGetError> =
334            serde_json::from_str(&content).ok();
335        Err(Error::ResponseError(ResponseContent {
336            status,
337            content,
338            entity,
339        }))
340    }
341}
342
343pub async fn organizations_org_id_domain_id_remove_post(
344    configuration: &configuration::Configuration,
345    org_id: uuid::Uuid,
346    id: uuid::Uuid,
347) -> Result<(), Error<OrganizationsOrgIdDomainIdRemovePostError>> {
348    // add a prefix to parameters to efficiently prevent name collisions
349    let p_org_id = org_id;
350    let p_id = id;
351
352    let uri_str = format!(
353        "{}/organizations/{orgId}/domain/{id}/remove",
354        configuration.base_path,
355        orgId = crate::apis::urlencode(p_org_id.to_string()),
356        id = crate::apis::urlencode(p_id.to_string())
357    );
358    let mut req_builder = configuration
359        .client
360        .request(reqwest::Method::POST, &uri_str);
361
362    if let Some(ref user_agent) = configuration.user_agent {
363        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
364    }
365    if let Some(ref token) = configuration.oauth_access_token {
366        req_builder = req_builder.bearer_auth(token.to_owned());
367    };
368
369    let req = req_builder.build()?;
370    let resp = configuration.client.execute(req).await?;
371
372    let status = resp.status();
373
374    if !status.is_client_error() && !status.is_server_error() {
375        Ok(())
376    } else {
377        let content = resp.text().await?;
378        let entity: Option<OrganizationsOrgIdDomainIdRemovePostError> =
379            serde_json::from_str(&content).ok();
380        Err(Error::ResponseError(ResponseContent {
381            status,
382            content,
383            entity,
384        }))
385    }
386}
387
388pub async fn organizations_org_id_domain_id_verify_post(
389    configuration: &configuration::Configuration,
390    org_id: uuid::Uuid,
391    id: uuid::Uuid,
392) -> Result<models::OrganizationDomainResponseModel, Error<OrganizationsOrgIdDomainIdVerifyPostError>>
393{
394    // add a prefix to parameters to efficiently prevent name collisions
395    let p_org_id = org_id;
396    let p_id = id;
397
398    let uri_str = format!(
399        "{}/organizations/{orgId}/domain/{id}/verify",
400        configuration.base_path,
401        orgId = crate::apis::urlencode(p_org_id.to_string()),
402        id = crate::apis::urlencode(p_id.to_string())
403    );
404    let mut req_builder = configuration
405        .client
406        .request(reqwest::Method::POST, &uri_str);
407
408    if let Some(ref user_agent) = configuration.user_agent {
409        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
410    }
411    if let Some(ref token) = configuration.oauth_access_token {
412        req_builder = req_builder.bearer_auth(token.to_owned());
413    };
414
415    let req = req_builder.build()?;
416    let resp = configuration.client.execute(req).await?;
417
418    let status = resp.status();
419    let content_type = resp
420        .headers()
421        .get("content-type")
422        .and_then(|v| v.to_str().ok())
423        .unwrap_or("application/octet-stream");
424    let content_type = super::ContentType::from(content_type);
425
426    if !status.is_client_error() && !status.is_server_error() {
427        let content = resp.text().await?;
428        match content_type {
429            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
430            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"))),
431            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::OrganizationDomainResponseModel`")))),
432        }
433    } else {
434        let content = resp.text().await?;
435        let entity: Option<OrganizationsOrgIdDomainIdVerifyPostError> =
436            serde_json::from_str(&content).ok();
437        Err(Error::ResponseError(ResponseContent {
438            status,
439            content,
440            entity,
441        }))
442    }
443}
444
445pub async fn organizations_org_id_domain_post(
446    configuration: &configuration::Configuration,
447    org_id: uuid::Uuid,
448    organization_domain_request_model: Option<models::OrganizationDomainRequestModel>,
449) -> Result<models::OrganizationDomainResponseModel, Error<OrganizationsOrgIdDomainPostError>> {
450    // add a prefix to parameters to efficiently prevent name collisions
451    let p_org_id = org_id;
452    let p_organization_domain_request_model = organization_domain_request_model;
453
454    let uri_str = format!(
455        "{}/organizations/{orgId}/domain",
456        configuration.base_path,
457        orgId = crate::apis::urlencode(p_org_id.to_string())
458    );
459    let mut req_builder = configuration
460        .client
461        .request(reqwest::Method::POST, &uri_str);
462
463    if let Some(ref user_agent) = configuration.user_agent {
464        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
465    }
466    if let Some(ref token) = configuration.oauth_access_token {
467        req_builder = req_builder.bearer_auth(token.to_owned());
468    };
469    req_builder = req_builder.json(&p_organization_domain_request_model);
470
471    let req = req_builder.build()?;
472    let resp = configuration.client.execute(req).await?;
473
474    let status = resp.status();
475    let content_type = resp
476        .headers()
477        .get("content-type")
478        .and_then(|v| v.to_str().ok())
479        .unwrap_or("application/octet-stream");
480    let content_type = super::ContentType::from(content_type);
481
482    if !status.is_client_error() && !status.is_server_error() {
483        let content = resp.text().await?;
484        match content_type {
485            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
486            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::OrganizationDomainResponseModel`"))),
487            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::OrganizationDomainResponseModel`")))),
488        }
489    } else {
490        let content = resp.text().await?;
491        let entity: Option<OrganizationsOrgIdDomainPostError> = serde_json::from_str(&content).ok();
492        Err(Error::ResponseError(ResponseContent {
493            status,
494            content,
495            entity,
496        }))
497    }
498}