Skip to main content

bitwarden_api_api/apis/
provider_clients_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 ProviderClientsApi: Send + Sync {
29    /// POST /providers/{providerId}/clients/existing
30    async fn add_existing_organization<'a>(
31        &self,
32        provider_id: uuid::Uuid,
33        add_existing_organization_request_body: Option<models::AddExistingOrganizationRequestBody>,
34    ) -> Result<(), Error>;
35
36    /// POST /providers/{providerId}/clients
37    async fn create<'a>(
38        &self,
39        provider_id: uuid::Uuid,
40        create_client_organization_request_body: Option<
41            models::CreateClientOrganizationRequestBody,
42        >,
43    ) -> Result<(), Error>;
44
45    /// GET /providers/{providerId}/clients/addable
46    async fn get_addable_organizations<'a>(&self, provider_id: uuid::Uuid) -> Result<(), Error>;
47
48    /// PUT /providers/{providerId}/clients/{providerOrganizationId}
49    async fn update<'a>(
50        &self,
51        provider_id: uuid::Uuid,
52        provider_organization_id: uuid::Uuid,
53        update_client_organization_request_body: Option<
54            models::UpdateClientOrganizationRequestBody,
55        >,
56    ) -> Result<(), Error>;
57}
58
59pub struct ProviderClientsApiClient {
60    configuration: Arc<configuration::Configuration>,
61}
62
63impl ProviderClientsApiClient {
64    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
65        Self { configuration }
66    }
67}
68
69#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
70#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
71impl ProviderClientsApi for ProviderClientsApiClient {
72    async fn add_existing_organization<'a>(
73        &self,
74        provider_id: uuid::Uuid,
75        add_existing_organization_request_body: Option<models::AddExistingOrganizationRequestBody>,
76    ) -> Result<(), Error> {
77        let local_var_configuration = &self.configuration;
78
79        let local_var_client = &local_var_configuration.client;
80
81        let local_var_uri_str = format!(
82            "{}/providers/{providerId}/clients/existing",
83            local_var_configuration.base_path,
84            providerId = provider_id
85        );
86        let mut local_var_req_builder =
87            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
88
89        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
90        local_var_req_builder = local_var_req_builder.json(&add_existing_organization_request_body);
91
92        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
93    }
94
95    async fn create<'a>(
96        &self,
97        provider_id: uuid::Uuid,
98        create_client_organization_request_body: Option<
99            models::CreateClientOrganizationRequestBody,
100        >,
101    ) -> Result<(), Error> {
102        let local_var_configuration = &self.configuration;
103
104        let local_var_client = &local_var_configuration.client;
105
106        let local_var_uri_str = format!(
107            "{}/providers/{providerId}/clients",
108            local_var_configuration.base_path,
109            providerId = provider_id
110        );
111        let mut local_var_req_builder =
112            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
113
114        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
115        local_var_req_builder =
116            local_var_req_builder.json(&create_client_organization_request_body);
117
118        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
119    }
120
121    async fn get_addable_organizations<'a>(&self, provider_id: uuid::Uuid) -> Result<(), Error> {
122        let local_var_configuration = &self.configuration;
123
124        let local_var_client = &local_var_configuration.client;
125
126        let local_var_uri_str = format!(
127            "{}/providers/{providerId}/clients/addable",
128            local_var_configuration.base_path,
129            providerId = provider_id
130        );
131        let mut local_var_req_builder =
132            local_var_client.request(reqwest::Method::GET, 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 update<'a>(
140        &self,
141        provider_id: uuid::Uuid,
142        provider_organization_id: uuid::Uuid,
143        update_client_organization_request_body: Option<
144            models::UpdateClientOrganizationRequestBody,
145        >,
146    ) -> Result<(), Error> {
147        let local_var_configuration = &self.configuration;
148
149        let local_var_client = &local_var_configuration.client;
150
151        let local_var_uri_str = format!(
152            "{}/providers/{providerId}/clients/{providerOrganizationId}",
153            local_var_configuration.base_path,
154            providerId = provider_id,
155            providerOrganizationId = provider_organization_id
156        );
157        let mut local_var_req_builder =
158            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
159
160        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
161        local_var_req_builder =
162            local_var_req_builder.json(&update_client_organization_request_body);
163
164        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
165    }
166}