Skip to main content

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 std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21    apis::{AuthRequired, ContentType, ResponseContent},
22    models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait OrganizationDomainApi: Send + Sync {
29    /// GET /organizations/{orgId}/domain/{id}
30    async fn get<'a>(
31        &self,
32        org_id: uuid::Uuid,
33        id: uuid::Uuid,
34    ) -> Result<models::OrganizationDomainResponseModel, Error>;
35
36    /// GET /organizations/{orgId}/domain
37    async fn get_all<'a>(
38        &self,
39        org_id: uuid::Uuid,
40    ) -> Result<models::OrganizationDomainResponseModelListResponseModel, Error>;
41
42    /// POST /organizations/domain/sso/verified
43    async fn get_verified_org_domain_sso_details<'a>(
44        &self,
45        organization_domain_sso_details_request_model: Option<
46            models::OrganizationDomainSsoDetailsRequestModel,
47        >,
48    ) -> Result<models::VerifiedOrganizationDomainSsoDetailsResponseModel, Error>;
49
50    /// POST /organizations/{orgId}/domain
51    async fn post<'a>(
52        &self,
53        org_id: uuid::Uuid,
54        organization_domain_request_model: Option<models::OrganizationDomainRequestModel>,
55    ) -> Result<models::OrganizationDomainResponseModel, Error>;
56
57    /// DELETE /organizations/{orgId}/domain/{id}
58    async fn remove_domain<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>;
59
60    /// POST /organizations/{orgId}/domain/{id}/verify
61    async fn verify<'a>(
62        &self,
63        org_id: uuid::Uuid,
64        id: uuid::Uuid,
65    ) -> Result<models::OrganizationDomainResponseModel, Error>;
66}
67
68pub struct OrganizationDomainApiClient {
69    configuration: Arc<configuration::Configuration>,
70}
71
72impl OrganizationDomainApiClient {
73    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
74        Self { configuration }
75    }
76}
77
78#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
79#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
80impl OrganizationDomainApi for OrganizationDomainApiClient {
81    async fn get<'a>(
82        &self,
83        org_id: uuid::Uuid,
84        id: uuid::Uuid,
85    ) -> Result<models::OrganizationDomainResponseModel, Error> {
86        let local_var_configuration = &self.configuration;
87
88        let local_var_client = &local_var_configuration.client;
89
90        let local_var_uri_str = format!(
91            "{}/organizations/{orgId}/domain/{id}",
92            local_var_configuration.base_path,
93            orgId = org_id,
94            id = id
95        );
96        let mut local_var_req_builder =
97            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
98
99        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
100
101        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
102    }
103
104    async fn get_all<'a>(
105        &self,
106        org_id: uuid::Uuid,
107    ) -> Result<models::OrganizationDomainResponseModelListResponseModel, Error> {
108        let local_var_configuration = &self.configuration;
109
110        let local_var_client = &local_var_configuration.client;
111
112        let local_var_uri_str = format!(
113            "{}/organizations/{orgId}/domain",
114            local_var_configuration.base_path,
115            orgId = org_id
116        );
117        let mut local_var_req_builder =
118            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
119
120        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
121
122        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
123    }
124
125    async fn get_verified_org_domain_sso_details<'a>(
126        &self,
127        organization_domain_sso_details_request_model: Option<
128            models::OrganizationDomainSsoDetailsRequestModel,
129        >,
130    ) -> Result<models::VerifiedOrganizationDomainSsoDetailsResponseModel, Error> {
131        let local_var_configuration = &self.configuration;
132
133        let local_var_client = &local_var_configuration.client;
134
135        let local_var_uri_str = format!(
136            "{}/organizations/domain/sso/verified",
137            local_var_configuration.base_path
138        );
139        let mut local_var_req_builder =
140            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
141
142        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
143        local_var_req_builder =
144            local_var_req_builder.json(&organization_domain_sso_details_request_model);
145
146        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
147    }
148
149    async fn post<'a>(
150        &self,
151        org_id: uuid::Uuid,
152        organization_domain_request_model: Option<models::OrganizationDomainRequestModel>,
153    ) -> Result<models::OrganizationDomainResponseModel, Error> {
154        let local_var_configuration = &self.configuration;
155
156        let local_var_client = &local_var_configuration.client;
157
158        let local_var_uri_str = format!(
159            "{}/organizations/{orgId}/domain",
160            local_var_configuration.base_path,
161            orgId = org_id
162        );
163        let mut local_var_req_builder =
164            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
165
166        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
167        local_var_req_builder = local_var_req_builder.json(&organization_domain_request_model);
168
169        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
170    }
171
172    async fn remove_domain<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error> {
173        let local_var_configuration = &self.configuration;
174
175        let local_var_client = &local_var_configuration.client;
176
177        let local_var_uri_str = format!(
178            "{}/organizations/{orgId}/domain/{id}",
179            local_var_configuration.base_path,
180            orgId = org_id,
181            id = id
182        );
183        let mut local_var_req_builder =
184            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
185
186        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
187
188        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
189    }
190
191    async fn verify<'a>(
192        &self,
193        org_id: uuid::Uuid,
194        id: uuid::Uuid,
195    ) -> Result<models::OrganizationDomainResponseModel, Error> {
196        let local_var_configuration = &self.configuration;
197
198        let local_var_client = &local_var_configuration.client;
199
200        let local_var_uri_str = format!(
201            "{}/organizations/{orgId}/domain/{id}/verify",
202            local_var_configuration.base_path,
203            orgId = org_id,
204            id = id
205        );
206        let mut local_var_req_builder =
207            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
208
209        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
210
211        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
212    }
213}