Skip to main content

bitwarden_api_api/apis/
organization_sponsorships_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 OrganizationSponsorshipsApi: Send + Sync {
29    /// DELETE /organization/sponsorship/{organizationId}/{sponsoredFriendlyName}/revoke
30    async fn admin_initiated_revoke_sponsorship<'a>(
31        &self,
32        organization_id: uuid::Uuid,
33        sponsored_friendly_name: &'a str,
34    ) -> Result<(), Error>;
35
36    /// POST /organization/sponsorship/{sponsoringOrgId}/families-for-enterprise
37    async fn create_sponsorship<'a>(
38        &self,
39        sponsoring_org_id: uuid::Uuid,
40        organization_sponsorship_create_request_model: Option<
41            models::OrganizationSponsorshipCreateRequestModel,
42        >,
43    ) -> Result<(), Error>;
44
45    /// GET /organization/sponsorship/{sponsoringOrgId}/sponsored
46    async fn get_sponsored_organizations<'a>(
47        &self,
48        sponsoring_org_id: uuid::Uuid,
49    ) -> Result<models::OrganizationSponsorshipInvitesResponseModelListResponseModel, Error>;
50
51    /// GET /organization/sponsorship/{sponsoringOrgId}/sync-status
52    async fn get_sync_status<'a>(&self, sponsoring_org_id: uuid::Uuid) -> Result<(), Error>;
53
54    /// POST /organization/sponsorship/validate-token
55    async fn pre_validate_sponsorship_token<'a>(
56        &self,
57        sponsorship_token: Option<&'a str>,
58    ) -> Result<models::PreValidateSponsorshipResponseModel, Error>;
59
60    /// POST /organization/sponsorship/redeem
61    async fn redeem_sponsorship<'a>(
62        &self,
63        sponsorship_token: Option<&'a str>,
64        organization_sponsorship_redeem_request_model: Option<
65            models::OrganizationSponsorshipRedeemRequestModel,
66        >,
67    ) -> Result<(), Error>;
68
69    /// DELETE /organization/sponsorship/sponsored/{sponsoredOrgId}
70    async fn remove_sponsorship<'a>(&self, sponsored_org_id: uuid::Uuid) -> Result<(), Error>;
71
72    /// POST /organization/sponsorship/{organizationId}/families-for-enterprise/resend-self
73    async fn resend_own_sponsorship_offer<'a>(
74        &self,
75        organization_id: uuid::Uuid,
76    ) -> Result<(), Error>;
77
78    /// POST /organization/sponsorship/{organizationId}/families-for-enterprise/resend
79    async fn resend_sponsorship_offer<'a>(
80        &self,
81        organization_id: uuid::Uuid,
82        sponsored_friendly_name: Option<&'a str>,
83    ) -> Result<(), Error>;
84
85    /// DELETE /organization/sponsorship/{organizationId}
86    async fn revoke_sponsorship<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error>;
87
88    /// POST /organization/sponsorship/sync
89    async fn sync<'a>(
90        &self,
91        organization_sponsorship_sync_request_model: Option<
92            models::OrganizationSponsorshipSyncRequestModel,
93        >,
94    ) -> Result<models::OrganizationSponsorshipSyncResponseModel, Error>;
95}
96
97pub struct OrganizationSponsorshipsApiClient {
98    configuration: Arc<configuration::Configuration>,
99}
100
101impl OrganizationSponsorshipsApiClient {
102    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
103        Self { configuration }
104    }
105}
106
107#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
108#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
109impl OrganizationSponsorshipsApi for OrganizationSponsorshipsApiClient {
110    async fn admin_initiated_revoke_sponsorship<'a>(
111        &self,
112        organization_id: uuid::Uuid,
113        sponsored_friendly_name: &'a str,
114    ) -> Result<(), Error> {
115        let local_var_configuration = &self.configuration;
116
117        let local_var_client = &local_var_configuration.client;
118
119        let local_var_uri_str = format!(
120            "{}/organization/sponsorship/{organizationId}/{sponsoredFriendlyName}/revoke",
121            local_var_configuration.base_path,
122            organizationId = organization_id,
123            sponsoredFriendlyName = crate::apis::urlencode(sponsored_friendly_name)
124        );
125        let mut local_var_req_builder =
126            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
127
128        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
129
130        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
131    }
132
133    async fn create_sponsorship<'a>(
134        &self,
135        sponsoring_org_id: uuid::Uuid,
136        organization_sponsorship_create_request_model: Option<
137            models::OrganizationSponsorshipCreateRequestModel,
138        >,
139    ) -> Result<(), Error> {
140        let local_var_configuration = &self.configuration;
141
142        let local_var_client = &local_var_configuration.client;
143
144        let local_var_uri_str = format!(
145            "{}/organization/sponsorship/{sponsoringOrgId}/families-for-enterprise",
146            local_var_configuration.base_path,
147            sponsoringOrgId = sponsoring_org_id
148        );
149        let mut local_var_req_builder =
150            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
151
152        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
153        local_var_req_builder =
154            local_var_req_builder.json(&organization_sponsorship_create_request_model);
155
156        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
157    }
158
159    async fn get_sponsored_organizations<'a>(
160        &self,
161        sponsoring_org_id: uuid::Uuid,
162    ) -> Result<models::OrganizationSponsorshipInvitesResponseModelListResponseModel, Error> {
163        let local_var_configuration = &self.configuration;
164
165        let local_var_client = &local_var_configuration.client;
166
167        let local_var_uri_str = format!(
168            "{}/organization/sponsorship/{sponsoringOrgId}/sponsored",
169            local_var_configuration.base_path,
170            sponsoringOrgId = sponsoring_org_id
171        );
172        let mut local_var_req_builder =
173            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
174
175        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
176
177        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
178    }
179
180    async fn get_sync_status<'a>(&self, sponsoring_org_id: uuid::Uuid) -> Result<(), Error> {
181        let local_var_configuration = &self.configuration;
182
183        let local_var_client = &local_var_configuration.client;
184
185        let local_var_uri_str = format!(
186            "{}/organization/sponsorship/{sponsoringOrgId}/sync-status",
187            local_var_configuration.base_path,
188            sponsoringOrgId = sponsoring_org_id
189        );
190        let mut local_var_req_builder =
191            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
192
193        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
194
195        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
196    }
197
198    async fn pre_validate_sponsorship_token<'a>(
199        &self,
200        sponsorship_token: Option<&'a str>,
201    ) -> Result<models::PreValidateSponsorshipResponseModel, Error> {
202        let local_var_configuration = &self.configuration;
203
204        let local_var_client = &local_var_configuration.client;
205
206        let local_var_uri_str = format!(
207            "{}/organization/sponsorship/validate-token",
208            local_var_configuration.base_path
209        );
210        let mut local_var_req_builder =
211            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
212
213        if let Some(ref param_value) = sponsorship_token {
214            local_var_req_builder =
215                local_var_req_builder.query(&[("sponsorshipToken", &param_value.to_string())]);
216        }
217        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
218
219        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
220    }
221
222    async fn redeem_sponsorship<'a>(
223        &self,
224        sponsorship_token: Option<&'a str>,
225        organization_sponsorship_redeem_request_model: Option<
226            models::OrganizationSponsorshipRedeemRequestModel,
227        >,
228    ) -> Result<(), Error> {
229        let local_var_configuration = &self.configuration;
230
231        let local_var_client = &local_var_configuration.client;
232
233        let local_var_uri_str = format!(
234            "{}/organization/sponsorship/redeem",
235            local_var_configuration.base_path
236        );
237        let mut local_var_req_builder =
238            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
239
240        if let Some(ref param_value) = sponsorship_token {
241            local_var_req_builder =
242                local_var_req_builder.query(&[("sponsorshipToken", &param_value.to_string())]);
243        }
244        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
245        local_var_req_builder =
246            local_var_req_builder.json(&organization_sponsorship_redeem_request_model);
247
248        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
249    }
250
251    async fn remove_sponsorship<'a>(&self, sponsored_org_id: uuid::Uuid) -> Result<(), Error> {
252        let local_var_configuration = &self.configuration;
253
254        let local_var_client = &local_var_configuration.client;
255
256        let local_var_uri_str = format!(
257            "{}/organization/sponsorship/sponsored/{sponsoredOrgId}",
258            local_var_configuration.base_path,
259            sponsoredOrgId = sponsored_org_id
260        );
261        let mut local_var_req_builder =
262            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
263
264        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
265
266        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
267    }
268
269    async fn resend_own_sponsorship_offer<'a>(
270        &self,
271        organization_id: uuid::Uuid,
272    ) -> Result<(), Error> {
273        let local_var_configuration = &self.configuration;
274
275        let local_var_client = &local_var_configuration.client;
276
277        let local_var_uri_str = format!(
278            "{}/organization/sponsorship/{organizationId}/families-for-enterprise/resend-self",
279            local_var_configuration.base_path,
280            organizationId = organization_id
281        );
282        let mut local_var_req_builder =
283            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
284
285        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
286
287        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
288    }
289
290    async fn resend_sponsorship_offer<'a>(
291        &self,
292        organization_id: uuid::Uuid,
293        sponsored_friendly_name: Option<&'a str>,
294    ) -> Result<(), Error> {
295        let local_var_configuration = &self.configuration;
296
297        let local_var_client = &local_var_configuration.client;
298
299        let local_var_uri_str = format!(
300            "{}/organization/sponsorship/{organizationId}/families-for-enterprise/resend",
301            local_var_configuration.base_path,
302            organizationId = organization_id
303        );
304        let mut local_var_req_builder =
305            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
306
307        if let Some(ref param_value) = sponsored_friendly_name {
308            local_var_req_builder =
309                local_var_req_builder.query(&[("sponsoredFriendlyName", &param_value.to_string())]);
310        }
311        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
312
313        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
314    }
315
316    async fn revoke_sponsorship<'a>(&self, organization_id: uuid::Uuid) -> Result<(), Error> {
317        let local_var_configuration = &self.configuration;
318
319        let local_var_client = &local_var_configuration.client;
320
321        let local_var_uri_str = format!(
322            "{}/organization/sponsorship/{organizationId}",
323            local_var_configuration.base_path,
324            organizationId = organization_id
325        );
326        let mut local_var_req_builder =
327            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
328
329        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
330
331        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
332    }
333
334    async fn sync<'a>(
335        &self,
336        organization_sponsorship_sync_request_model: Option<
337            models::OrganizationSponsorshipSyncRequestModel,
338        >,
339    ) -> Result<models::OrganizationSponsorshipSyncResponseModel, Error> {
340        let local_var_configuration = &self.configuration;
341
342        let local_var_client = &local_var_configuration.client;
343
344        let local_var_uri_str = format!(
345            "{}/organization/sponsorship/sync",
346            local_var_configuration.base_path
347        );
348        let mut local_var_req_builder =
349            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
350
351        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
352        local_var_req_builder =
353            local_var_req_builder.json(&organization_sponsorship_sync_request_model);
354
355        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
356    }
357}