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