Skip to main content

bitwarden_api_api/apis/
pam_access_connector_rotation_attempts_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 PamAccessConnectorRotationAttemptsApi: Send + Sync {
29    /// POST /access-connectors/rotation/attempts/{id}/failure
30    /// Reports a failed rotation attempt (spec RecordRotationFailed). Never forward raw
31    /// target-system error output as ErrorCode/Detail -- it can echo credentials. Send a bounded
32    /// error code plus an optional short detail instead. Either field exceeding its documented
33    /// length is rejected as a 400, so cap them before sending -- a rejected report leaves the
34    /// failure unrecorded until the job times out. The single reason the two combine into is
35    /// truncated rather than rejected.
36    async fn failure<'a>(
37        &self,
38        id: uuid::Uuid,
39        report_rotation_failed_request_model: models::ReportRotationFailedRequestModel,
40    ) -> Result<(), Error>;
41
42    /// GET /access-connectors/rotation/attempts/{id}/cipher
43    /// Returns the cipher for this access connector's claimed, executing attempt only -- never a
44    /// general cipher read. Data is returned exactly as stored: opaque ciphertext the server never
45    /// decrypts.
46    async fn get_cipher<'a>(
47        &self,
48        id: uuid::Uuid,
49    ) -> Result<models::RotationCipherResponseModel, Error>;
50
51    /// PUT /access-connectors/rotation/attempts/{id}/cipher
52    /// Writes the rotated secret back to the cipher (spec AcceptCipherUpdate) via an atomic
53    /// capability check. 409 means the claim/attempt no longer holds, or LastKnownRevisionDate no
54    /// longer matches the cipher's current revision (a concurrent user edit won) -- audited as
55    /// write_rejected. 404 means the attempt id is unknown (no audit).
56    async fn put_cipher<'a>(
57        &self,
58        id: uuid::Uuid,
59        submit_cipher_update_request_model: models::SubmitCipherUpdateRequestModel,
60    ) -> Result<(), Error>;
61
62    /// POST /access-connectors/rotation/attempts/{id}/success
63    /// Reports a successful rotation (spec RecordRotationSucceeded). Requires the attempt to
64    /// already have a written cipher (the VerifiedBeforeSuccess backstop); otherwise the report is
65    /// treated as stale (409, audited as report_rejected).
66    async fn success<'a>(
67        &self,
68        id: uuid::Uuid,
69        report_rotation_succeeded_request_model: models::ReportRotationSucceededRequestModel,
70    ) -> Result<(), Error>;
71}
72
73pub struct PamAccessConnectorRotationAttemptsApiClient {
74    configuration: Arc<configuration::Configuration>,
75}
76
77impl PamAccessConnectorRotationAttemptsApiClient {
78    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
79        Self { configuration }
80    }
81}
82
83#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
84#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
85impl PamAccessConnectorRotationAttemptsApi for PamAccessConnectorRotationAttemptsApiClient {
86    /// Reports a failed rotation attempt (spec RecordRotationFailed). Never forward raw
87    /// target-system error output as ErrorCode/Detail -- it can echo credentials. Send a bounded
88    /// error code plus an optional short detail instead. Either field exceeding its documented
89    /// length is rejected as a 400, so cap them before sending -- a rejected report leaves the
90    /// failure unrecorded until the job times out. The single reason the two combine into is
91    /// truncated rather than rejected.
92    async fn failure<'a>(
93        &self,
94        id: uuid::Uuid,
95        report_rotation_failed_request_model: models::ReportRotationFailedRequestModel,
96    ) -> Result<(), Error> {
97        let local_var_configuration = &self.configuration;
98
99        let local_var_client = &local_var_configuration.client;
100
101        let local_var_uri_str = format!(
102            "{}/access-connectors/rotation/attempts/{id}/failure",
103            local_var_configuration.base_path,
104            id = id
105        );
106        let mut local_var_req_builder =
107            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
108
109        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
110        local_var_req_builder = local_var_req_builder.json(&report_rotation_failed_request_model);
111
112        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
113    }
114
115    /// Returns the cipher for this access connector's claimed, executing attempt only -- never a
116    /// general cipher read. Data is returned exactly as stored: opaque ciphertext the server never
117    /// decrypts.
118    async fn get_cipher<'a>(
119        &self,
120        id: uuid::Uuid,
121    ) -> Result<models::RotationCipherResponseModel, 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            "{}/access-connectors/rotation/attempts/{id}/cipher",
128            local_var_configuration.base_path,
129            id = 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_json_response(local_var_req_builder).await
137    }
138
139    /// Writes the rotated secret back to the cipher (spec AcceptCipherUpdate) via an atomic
140    /// capability check. 409 means the claim/attempt no longer holds, or LastKnownRevisionDate no
141    /// longer matches the cipher's current revision (a concurrent user edit won) -- audited as
142    /// write_rejected. 404 means the attempt id is unknown (no audit).
143    async fn put_cipher<'a>(
144        &self,
145        id: uuid::Uuid,
146        submit_cipher_update_request_model: models::SubmitCipherUpdateRequestModel,
147    ) -> Result<(), Error> {
148        let local_var_configuration = &self.configuration;
149
150        let local_var_client = &local_var_configuration.client;
151
152        let local_var_uri_str = format!(
153            "{}/access-connectors/rotation/attempts/{id}/cipher",
154            local_var_configuration.base_path,
155            id = 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 = local_var_req_builder.json(&submit_cipher_update_request_model);
162
163        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
164    }
165
166    /// Reports a successful rotation (spec RecordRotationSucceeded). Requires the attempt to
167    /// already have a written cipher (the VerifiedBeforeSuccess backstop); otherwise the report is
168    /// treated as stale (409, audited as report_rejected).
169    async fn success<'a>(
170        &self,
171        id: uuid::Uuid,
172        report_rotation_succeeded_request_model: models::ReportRotationSucceededRequestModel,
173    ) -> Result<(), Error> {
174        let local_var_configuration = &self.configuration;
175
176        let local_var_client = &local_var_configuration.client;
177
178        let local_var_uri_str = format!(
179            "{}/access-connectors/rotation/attempts/{id}/success",
180            local_var_configuration.base_path,
181            id = id
182        );
183        let mut local_var_req_builder =
184            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
185
186        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
187        local_var_req_builder =
188            local_var_req_builder.json(&report_rotation_succeeded_request_model);
189
190        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
191    }
192}