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<AdminInitiatedRevokeSponsorshipError>>;
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<CreateSponsorshipError>>;
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<
50        models::OrganizationSponsorshipInvitesResponseModelListResponseModel,
51        Error<GetSponsoredOrganizationsError>,
52    >;
53
54    /// DELETE /organization/sponsorship/self-hosted/{sponsoringOrgId}
55    async fn revoke_sponsorship<'a>(
56        &self,
57        sponsoring_org_id: uuid::Uuid,
58    ) -> Result<(), Error<RevokeSponsorshipError>>;
59}
60
61pub struct SelfHostedOrganizationSponsorshipsApiClient {
62    configuration: Arc<configuration::Configuration>,
63}
64
65impl SelfHostedOrganizationSponsorshipsApiClient {
66    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
67        Self { configuration }
68    }
69}
70
71#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
72#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
73impl SelfHostedOrganizationSponsorshipsApi for SelfHostedOrganizationSponsorshipsApiClient {
74    async fn admin_initiated_revoke_sponsorship<'a>(
75        &self,
76        organization_id: uuid::Uuid,
77        sponsored_friendly_name: &'a str,
78    ) -> Result<(), Error<AdminInitiatedRevokeSponsorshipError>> {
79        let local_var_configuration = &self.configuration;
80
81        let local_var_client = &local_var_configuration.client;
82
83        let local_var_uri_str = format!(
84            "{}/organization/sponsorship/self-hosted/{organizationId}/{sponsoredFriendlyName}/revoke",
85            local_var_configuration.base_path,
86            organizationId = organization_id,
87            sponsoredFriendlyName = crate::apis::urlencode(sponsored_friendly_name)
88        );
89        let mut local_var_req_builder =
90            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
91
92        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
93
94        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
95    }
96
97    async fn create_sponsorship<'a>(
98        &self,
99        sponsoring_org_id: uuid::Uuid,
100        organization_sponsorship_create_request_model: Option<
101            models::OrganizationSponsorshipCreateRequestModel,
102        >,
103    ) -> Result<(), Error<CreateSponsorshipError>> {
104        let local_var_configuration = &self.configuration;
105
106        let local_var_client = &local_var_configuration.client;
107
108        let local_var_uri_str = format!(
109            "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}/families-for-enterprise",
110            local_var_configuration.base_path,
111            sponsoringOrgId = sponsoring_org_id
112        );
113        let mut local_var_req_builder =
114            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
115
116        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
117        local_var_req_builder =
118            local_var_req_builder.json(&organization_sponsorship_create_request_model);
119
120        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
121    }
122
123    async fn get_sponsored_organizations<'a>(
124        &self,
125        org_id: uuid::Uuid,
126    ) -> Result<
127        models::OrganizationSponsorshipInvitesResponseModelListResponseModel,
128        Error<GetSponsoredOrganizationsError>,
129    > {
130        let local_var_configuration = &self.configuration;
131
132        let local_var_client = &local_var_configuration.client;
133
134        let local_var_uri_str = format!(
135            "{}/organization/sponsorship/self-hosted/{orgId}/sponsored",
136            local_var_configuration.base_path,
137            orgId = org_id
138        );
139        let mut local_var_req_builder =
140            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
141
142        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
143
144        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
145    }
146
147    async fn revoke_sponsorship<'a>(
148        &self,
149        sponsoring_org_id: uuid::Uuid,
150    ) -> Result<(), Error<RevokeSponsorshipError>> {
151        let local_var_configuration = &self.configuration;
152
153        let local_var_client = &local_var_configuration.client;
154
155        let local_var_uri_str = format!(
156            "{}/organization/sponsorship/self-hosted/{sponsoringOrgId}",
157            local_var_configuration.base_path,
158            sponsoringOrgId = sponsoring_org_id
159        );
160        let mut local_var_req_builder =
161            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
162
163        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
164
165        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
166    }
167}
168
169/// struct for typed errors of method
170/// [`SelfHostedOrganizationSponsorshipsApi::admin_initiated_revoke_sponsorship`]
171#[derive(Debug, Clone, Serialize, Deserialize)]
172#[serde(untagged)]
173pub enum AdminInitiatedRevokeSponsorshipError {
174    UnknownValue(serde_json::Value),
175}
176/// struct for typed errors of method [`SelfHostedOrganizationSponsorshipsApi::create_sponsorship`]
177#[derive(Debug, Clone, Serialize, Deserialize)]
178#[serde(untagged)]
179pub enum CreateSponsorshipError {
180    UnknownValue(serde_json::Value),
181}
182/// struct for typed errors of method
183/// [`SelfHostedOrganizationSponsorshipsApi::get_sponsored_organizations`]
184#[derive(Debug, Clone, Serialize, Deserialize)]
185#[serde(untagged)]
186pub enum GetSponsoredOrganizationsError {
187    UnknownValue(serde_json::Value),
188}
189/// struct for typed errors of method [`SelfHostedOrganizationSponsorshipsApi::revoke_sponsorship`]
190#[derive(Debug, Clone, Serialize, Deserialize)]
191#[serde(untagged)]
192pub enum RevokeSponsorshipError {
193    UnknownValue(serde_json::Value),
194}