Skip to main content

bitwarden_api_api/apis/
pam_access_connector_rotation_configs_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 PamAccessConnectorRotationConfigsApi: Send + Sync {
29    /// DELETE /organizations/{orgId}/access-connectors/rotation/configs/{id}
30    async fn delete<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>;
31
32    /// GET /organizations/{orgId}/access-connectors/rotation/configs/{id}
33    async fn get<'a>(
34        &self,
35        org_id: uuid::Uuid,
36        id: uuid::Uuid,
37    ) -> Result<models::PamRotationConfigDetailResponseModel, Error>;
38
39    /// GET /organizations/{orgId}/access-connectors/rotation/configs
40    async fn get_all<'a>(
41        &self,
42        org_id: uuid::Uuid,
43    ) -> Result<models::PamRotationConfigResponseModelListResponseModel, Error>;
44
45    /// POST /organizations/{orgId}/access-connectors/rotation/configs/{id}/pause
46    async fn pause<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>;
47
48    /// POST /organizations/{orgId}/access-connectors/rotation/configs
49    async fn post<'a>(
50        &self,
51        org_id: uuid::Uuid,
52        create_rotation_config_request_model: models::CreateRotationConfigRequestModel,
53    ) -> Result<models::PamRotationConfigDetailResponseModel, Error>;
54
55    /// PUT /organizations/{orgId}/access-connectors/rotation/configs/{id}
56    async fn put<'a>(
57        &self,
58        org_id: uuid::Uuid,
59        id: uuid::Uuid,
60        update_rotation_config_request_model: models::UpdateRotationConfigRequestModel,
61    ) -> Result<models::PamRotationConfigDetailResponseModel, Error>;
62
63    /// POST /organizations/{orgId}/access-connectors/rotation/configs/{id}/record-manual
64    /// Records that an operator rotated a manual-target config's credential out of band, clearing
65    /// its due obligation.
66    async fn record_manual<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>;
67
68    /// POST /organizations/{orgId}/access-connectors/rotation/configs/{id}/resume
69    async fn resume<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>;
70
71    /// POST /organizations/{orgId}/access-connectors/rotation/configs/{id}/rotate
72    /// Triggers an on-demand rotation now (spec TriggerRotationNow), subject to the per-config
73    /// on-demand cooldown.
74    async fn rotate<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error>;
75}
76
77pub struct PamAccessConnectorRotationConfigsApiClient {
78    configuration: Arc<configuration::Configuration>,
79}
80
81impl PamAccessConnectorRotationConfigsApiClient {
82    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
83        Self { configuration }
84    }
85}
86
87#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
88#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
89impl PamAccessConnectorRotationConfigsApi for PamAccessConnectorRotationConfigsApiClient {
90    async fn delete<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error> {
91        let local_var_configuration = &self.configuration;
92
93        let local_var_client = &local_var_configuration.client;
94
95        let local_var_uri_str = format!(
96            "{}/organizations/{orgId}/access-connectors/rotation/configs/{id}",
97            local_var_configuration.base_path,
98            orgId = org_id,
99            id = id
100        );
101        let mut local_var_req_builder =
102            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
103
104        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
105
106        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
107    }
108
109    async fn get<'a>(
110        &self,
111        org_id: uuid::Uuid,
112        id: uuid::Uuid,
113    ) -> Result<models::PamRotationConfigDetailResponseModel, Error> {
114        let local_var_configuration = &self.configuration;
115
116        let local_var_client = &local_var_configuration.client;
117
118        let local_var_uri_str = format!(
119            "{}/organizations/{orgId}/access-connectors/rotation/configs/{id}",
120            local_var_configuration.base_path,
121            orgId = org_id,
122            id = id
123        );
124        let mut local_var_req_builder =
125            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
126
127        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
128
129        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
130    }
131
132    async fn get_all<'a>(
133        &self,
134        org_id: uuid::Uuid,
135    ) -> Result<models::PamRotationConfigResponseModelListResponseModel, Error> {
136        let local_var_configuration = &self.configuration;
137
138        let local_var_client = &local_var_configuration.client;
139
140        let local_var_uri_str = format!(
141            "{}/organizations/{orgId}/access-connectors/rotation/configs",
142            local_var_configuration.base_path,
143            orgId = org_id
144        );
145        let mut local_var_req_builder =
146            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
147
148        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
149
150        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
151    }
152
153    async fn pause<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error> {
154        let local_var_configuration = &self.configuration;
155
156        let local_var_client = &local_var_configuration.client;
157
158        let local_var_uri_str = format!(
159            "{}/organizations/{orgId}/access-connectors/rotation/configs/{id}/pause",
160            local_var_configuration.base_path,
161            orgId = org_id,
162            id = id
163        );
164        let mut local_var_req_builder =
165            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
166
167        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
168
169        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
170    }
171
172    async fn post<'a>(
173        &self,
174        org_id: uuid::Uuid,
175        create_rotation_config_request_model: models::CreateRotationConfigRequestModel,
176    ) -> Result<models::PamRotationConfigDetailResponseModel, Error> {
177        let local_var_configuration = &self.configuration;
178
179        let local_var_client = &local_var_configuration.client;
180
181        let local_var_uri_str = format!(
182            "{}/organizations/{orgId}/access-connectors/rotation/configs",
183            local_var_configuration.base_path,
184            orgId = org_id
185        );
186        let mut local_var_req_builder =
187            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
188
189        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
190        local_var_req_builder = local_var_req_builder.json(&create_rotation_config_request_model);
191
192        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
193    }
194
195    async fn put<'a>(
196        &self,
197        org_id: uuid::Uuid,
198        id: uuid::Uuid,
199        update_rotation_config_request_model: models::UpdateRotationConfigRequestModel,
200    ) -> Result<models::PamRotationConfigDetailResponseModel, Error> {
201        let local_var_configuration = &self.configuration;
202
203        let local_var_client = &local_var_configuration.client;
204
205        let local_var_uri_str = format!(
206            "{}/organizations/{orgId}/access-connectors/rotation/configs/{id}",
207            local_var_configuration.base_path,
208            orgId = org_id,
209            id = id
210        );
211        let mut local_var_req_builder =
212            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
213
214        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
215        local_var_req_builder = local_var_req_builder.json(&update_rotation_config_request_model);
216
217        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
218    }
219
220    /// Records that an operator rotated a manual-target config's credential out of band, clearing
221    /// its due obligation.
222    async fn record_manual<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error> {
223        let local_var_configuration = &self.configuration;
224
225        let local_var_client = &local_var_configuration.client;
226
227        let local_var_uri_str = format!(
228            "{}/organizations/{orgId}/access-connectors/rotation/configs/{id}/record-manual",
229            local_var_configuration.base_path,
230            orgId = org_id,
231            id = id
232        );
233        let mut local_var_req_builder =
234            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
235
236        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
237
238        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
239    }
240
241    async fn resume<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error> {
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            "{}/organizations/{orgId}/access-connectors/rotation/configs/{id}/resume",
248            local_var_configuration.base_path,
249            orgId = org_id,
250            id = id
251        );
252        let mut local_var_req_builder =
253            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
254
255        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
256
257        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
258    }
259
260    /// Triggers an on-demand rotation now (spec TriggerRotationNow), subject to the per-config
261    /// on-demand cooldown.
262    async fn rotate<'a>(&self, org_id: uuid::Uuid, id: uuid::Uuid) -> Result<(), Error> {
263        let local_var_configuration = &self.configuration;
264
265        let local_var_client = &local_var_configuration.client;
266
267        let local_var_uri_str = format!(
268            "{}/organizations/{orgId}/access-connectors/rotation/configs/{id}/rotate",
269            local_var_configuration.base_path,
270            orgId = org_id,
271            id = id
272        );
273        let mut local_var_req_builder =
274            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
275
276        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
277
278        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
279    }
280}