Skip to main content

bitwarden_api_api/apis/
self_hosted_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 SelfHostedOrganizationSponsorshipsApi: Send + Sync {
29    /// DELETE /organization/sponsorship/self-hosted/{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/self-hosted/{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/self-hosted/{orgId}/sponsored
46    async fn get_sponsored_organizations<'a>(
47        &self,
48        org_id: uuid::Uuid,
49    ) -> Result<models::OrganizationSponsorshipInvitesResponseModelListResponseModel, Error>;
50
51    /// DELETE /organization/sponsorship/self-hosted/{sponsoringOrgId}
52    async fn revoke_sponsorship<'a>(&self, sponsoring_org_id: uuid::Uuid) -> Result<(), Error>;
53}
54
55pub struct SelfHostedOrganizationSponsorshipsApiClient {
56    configuration: Arc<configuration::Configuration>,
57}
58
59impl SelfHostedOrganizationSponsorshipsApiClient {
60    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
61        Self { configuration }
62    }
63}
64
65#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
66#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
67impl SelfHostedOrganizationSponsorshipsApi for SelfHostedOrganizationSponsorshipsApiClient {
68    async fn admin_initiated_revoke_sponsorship<'a>(
69        &self,
70        organization_id: uuid::Uuid,
71        sponsored_friendly_name: &'a str,
72    ) -> Result<(), Error> {
73        let local_var_configuration = &self.configuration;
74
75        let local_var_client = &local_var_configuration.client;
76
77        let local_var_uri_str = format!(
78            "{}/organization/sponsorship/self-hosted/{organizationId}/{sponsoredFriendlyName}/revoke",
79            local_var_configuration.base_path,
80            organizationId = organization_id,
81            sponsoredFriendlyName = crate::apis::urlencode(sponsored_friendly_name)
82        );
83        let mut local_var_req_builder =
84            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
85
86        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
87
88        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
89    }
90
91    async fn create_sponsorship<'a>(
92        &self,
93        sponsoring_org_id: uuid::Uuid,
94        organization_sponsorship_create_request_model: Option<
95            models::OrganizationSponsorshipCreateRequestModel,
96        >,
97    ) -> Result<(), Error> {
98        let local_var_configuration = &self.configuration;
99
100        let local_var_client = &local_var_configuration.client;
101
102        let local_var_uri_str = format!(
103            "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}/families-for-enterprise",
104            local_var_configuration.base_path,
105            sponsoringOrgId = sponsoring_org_id
106        );
107        let mut local_var_req_builder =
108            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
109
110        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
111        local_var_req_builder =
112            local_var_req_builder.json(&organization_sponsorship_create_request_model);
113
114        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
115    }
116
117    async fn get_sponsored_organizations<'a>(
118        &self,
119        org_id: uuid::Uuid,
120    ) -> Result<models::OrganizationSponsorshipInvitesResponseModelListResponseModel, Error> {
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/self-hosted/{orgId}/sponsored",
127            local_var_configuration.base_path,
128            orgId = org_id
129        );
130        let mut local_var_req_builder =
131            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
132
133        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
134
135        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
136    }
137
138    async fn revoke_sponsorship<'a>(&self, sponsoring_org_id: uuid::Uuid) -> Result<(), Error> {
139        let local_var_configuration = &self.configuration;
140
141        let local_var_client = &local_var_configuration.client;
142
143        let local_var_uri_str = format!(
144            "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}",
145            local_var_configuration.base_path,
146            sponsoringOrgId = sponsoring_org_id
147        );
148        let mut local_var_req_builder =
149            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
150
151        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
152
153        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
154    }
155}