Skip to main content

bitwarden_api_api/apis/
pam_access_connectors_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 PamAccessConnectorsApi: Send + Sync {
29    /// POST /organizations/{orgId}/access-connectors/{id}/assignments
30    async fn assign_target<'a>(
31        &self,
32        org_id: uuid::Uuid,
33        id: uuid::Uuid,
34        assign_access_connector_target_request_model: models::AssignAccessConnectorTargetRequestModel,
35    ) -> Result<(), Error>;
36
37    /// DELETE /organizations/{orgId}/access-connectors/{id}
38    /// Permanently deletes an access connector and invalidates its credential. The access connector
39    /// held the plaintext organization key -- rotating the organization key is the remediation for
40    /// a suspected compromise.
41    async fn delete<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>;
42
43    /// POST /organizations/{orgId}/access-connectors/{id}/disable
44    /// Disables an access connector (reversible): it stops claiming new jobs and its running jobs
45    /// are released, but its credential is retained so it can be re-enabled later.
46    async fn disable<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>;
47
48    /// POST /organizations/{orgId}/access-connectors/{id}/enable
49    /// Re-enables a disabled access connector so it can authenticate and claim jobs again.
50    async fn enable<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>;
51
52    /// GET /organizations/{orgId}/access-connectors/{id}
53    /// Returns one access connector with its recent rotation activity -- the jobs it has worked and
54    /// the attempts it recorded against them, newest first.
55    async fn get<'a>(
56        &self,
57        org_id: uuid::Uuid,
58        id: uuid::Uuid,
59    ) -> Result<models::PamAccessConnectorDetailResponseModel, Error>;
60
61    /// GET /organizations/{orgId}/access-connectors
62    async fn get_all<'a>(
63        &self,
64        org_id: uuid::Uuid,
65    ) -> Result<models::PamAccessConnectorResponseModelListResponseModel, Error>;
66
67    /// POST /organizations/{orgId}/access-connectors
68    /// Registers an access connector and returns its client secret. The secret is shown exactly
69    /// once here -- the server hashes it for storage and cannot return it again.
70    async fn post<'a>(
71        &self,
72        org_id: uuid::Uuid,
73        register_access_connector_request_model: models::RegisterAccessConnectorRequestModel,
74    ) -> Result<models::RegisterAccessConnectorResponseModel, Error>;
75
76    /// DELETE /organizations/{orgId}/access-connectors/{id}/assignments/{targetSystemId}
77    async fn unassign_target<'a>(
78        &self,
79        org_id: uuid::Uuid,
80        id: uuid::Uuid,
81        target_system_id: uuid::Uuid,
82    ) -> Result<(), Error>;
83}
84
85pub struct PamAccessConnectorsApiClient {
86    configuration: Arc<configuration::Configuration>,
87}
88
89impl PamAccessConnectorsApiClient {
90    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
91        Self { configuration }
92    }
93}
94
95#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
96#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
97impl PamAccessConnectorsApi for PamAccessConnectorsApiClient {
98    async fn assign_target<'a>(
99        &self,
100        org_id: uuid::Uuid,
101        id: uuid::Uuid,
102        assign_access_connector_target_request_model: models::AssignAccessConnectorTargetRequestModel,
103    ) -> Result<(), Error> {
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            "{}/organizations/{orgId}/access-connectors/{id}/assignments",
110            local_var_configuration.base_path,
111            orgId = org_id,
112            id = id
113        );
114        let mut local_var_req_builder =
115            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
116
117        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
118        local_var_req_builder =
119            local_var_req_builder.json(&assign_access_connector_target_request_model);
120
121        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
122    }
123
124    /// Permanently deletes an access connector and invalidates its credential. The access connector
125    /// held the plaintext organization key -- rotating the organization key is the remediation for
126    /// a suspected compromise.
127    async fn delete<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error> {
128        let local_var_configuration = &self.configuration;
129
130        let local_var_client = &local_var_configuration.client;
131
132        let local_var_uri_str = format!(
133            "{}/organizations/{orgId}/access-connectors/{id}",
134            local_var_configuration.base_path,
135            orgId = org_id,
136            id = id
137        );
138        let mut local_var_req_builder =
139            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
140
141        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
142
143        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
144    }
145
146    /// Disables an access connector (reversible): it stops claiming new jobs and its running jobs
147    /// are released, but its credential is retained so it can be re-enabled later.
148    async fn disable<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error> {
149        let local_var_configuration = &self.configuration;
150
151        let local_var_client = &local_var_configuration.client;
152
153        let local_var_uri_str = format!(
154            "{}/organizations/{orgId}/access-connectors/{id}/disable",
155            local_var_configuration.base_path,
156            orgId = org_id,
157            id = id
158        );
159        let mut local_var_req_builder =
160            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
161
162        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
163
164        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
165    }
166
167    /// Re-enables a disabled access connector so it can authenticate and claim jobs again.
168    async fn enable<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error> {
169        let local_var_configuration = &self.configuration;
170
171        let local_var_client = &local_var_configuration.client;
172
173        let local_var_uri_str = format!(
174            "{}/organizations/{orgId}/access-connectors/{id}/enable",
175            local_var_configuration.base_path,
176            orgId = org_id,
177            id = id
178        );
179        let mut local_var_req_builder =
180            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
181
182        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
183
184        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
185    }
186
187    /// Returns one access connector with its recent rotation activity -- the jobs it has worked and
188    /// the attempts it recorded against them, newest first.
189    async fn get<'a>(
190        &self,
191        org_id: uuid::Uuid,
192        id: uuid::Uuid,
193    ) -> Result<models::PamAccessConnectorDetailResponseModel, Error> {
194        let local_var_configuration = &self.configuration;
195
196        let local_var_client = &local_var_configuration.client;
197
198        let local_var_uri_str = format!(
199            "{}/organizations/{orgId}/access-connectors/{id}",
200            local_var_configuration.base_path,
201            orgId = org_id,
202            id = id
203        );
204        let mut local_var_req_builder =
205            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
206
207        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
208
209        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
210    }
211
212    async fn get_all<'a>(
213        &self,
214        org_id: uuid::Uuid,
215    ) -> Result<models::PamAccessConnectorResponseModelListResponseModel, Error> {
216        let local_var_configuration = &self.configuration;
217
218        let local_var_client = &local_var_configuration.client;
219
220        let local_var_uri_str = format!(
221            "{}/organizations/{orgId}/access-connectors",
222            local_var_configuration.base_path,
223            orgId = org_id
224        );
225        let mut local_var_req_builder =
226            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
227
228        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
229
230        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
231    }
232
233    /// Registers an access connector and returns its client secret. The secret is shown exactly
234    /// once here -- the server hashes it for storage and cannot return it again.
235    async fn post<'a>(
236        &self,
237        org_id: uuid::Uuid,
238        register_access_connector_request_model: models::RegisterAccessConnectorRequestModel,
239    ) -> Result<models::RegisterAccessConnectorResponseModel, Error> {
240        let local_var_configuration = &self.configuration;
241
242        let local_var_client = &local_var_configuration.client;
243
244        let local_var_uri_str = format!(
245            "{}/organizations/{orgId}/access-connectors",
246            local_var_configuration.base_path,
247            orgId = org_id
248        );
249        let mut local_var_req_builder =
250            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
251
252        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
253        local_var_req_builder =
254            local_var_req_builder.json(&register_access_connector_request_model);
255
256        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
257    }
258
259    async fn unassign_target<'a>(
260        &self,
261        org_id: uuid::Uuid,
262        id: uuid::Uuid,
263        target_system_id: uuid::Uuid,
264    ) -> Result<(), Error> {
265        let local_var_configuration = &self.configuration;
266
267        let local_var_client = &local_var_configuration.client;
268
269        let local_var_uri_str = format!(
270            "{}/organizations/{orgId}/access-connectors/{id}/assignments/{targetSystemId}",
271            local_var_configuration.base_path,
272            orgId = org_id,
273            id = id,
274            targetSystemId = target_system_id
275        );
276        let mut local_var_req_builder =
277            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
278
279        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
280
281        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
282    }
283}