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 of this access connector's claimed, executing attempt, with its full
44    /// encrypted data.
45    async fn get_cipher<'a>(
46        &self,
47        id: uuid::Uuid,
48    ) -> Result<models::CipherMiniResponseModel, Error>;
49
50    /// PUT /access-connectors/rotation/attempts/{id}/cipher
51    /// Writes the rotated cipher (spec AcceptCipherUpdate): a Login cipher request without Data,
52    /// with the item key unchanged and LastKnownRevisionDate from the read. 409: the claim or
53    /// attempt no longer holds, or the revision moved (audited as write_rejected). 404: unknown
54    /// attempt.
55    async fn put_cipher<'a>(
56        &self,
57        id: uuid::Uuid,
58        cipher_request_model: models::CipherRequestModel,
59    ) -> Result<(), Error>;
60
61    /// POST /access-connectors/rotation/attempts/{id}/success
62    /// Reports a successful rotation (spec RecordRotationSucceeded). Requires the attempt to
63    /// already have a written cipher (the VerifiedBeforeSuccess backstop); otherwise the report is
64    /// treated as stale (409, audited as report_rejected).
65    async fn success<'a>(
66        &self,
67        id: uuid::Uuid,
68        report_rotation_succeeded_request_model: models::ReportRotationSucceededRequestModel,
69    ) -> Result<(), Error>;
70}
71
72pub struct PamAccessConnectorRotationAttemptsApiClient {
73    configuration: Arc<configuration::Configuration>,
74}
75
76impl PamAccessConnectorRotationAttemptsApiClient {
77    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
78        Self { configuration }
79    }
80}
81
82#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
83#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
84impl PamAccessConnectorRotationAttemptsApi for PamAccessConnectorRotationAttemptsApiClient {
85    /// Reports a failed rotation attempt (spec RecordRotationFailed). Never forward raw
86    /// target-system error output as ErrorCode/Detail -- it can echo credentials. Send a bounded
87    /// error code plus an optional short detail instead. Either field exceeding its documented
88    /// length is rejected as a 400, so cap them before sending -- a rejected report leaves the
89    /// failure unrecorded until the job times out. The single reason the two combine into is
90    /// truncated rather than rejected.
91    async fn failure<'a>(
92        &self,
93        id: uuid::Uuid,
94        report_rotation_failed_request_model: models::ReportRotationFailedRequestModel,
95    ) -> Result<(), Error> {
96        let local_var_configuration = &self.configuration;
97
98        let local_var_client = &local_var_configuration.client;
99
100        let local_var_uri_str = format!(
101            "{}/access-connectors/rotation/attempts/{id}/failure",
102            local_var_configuration.base_path,
103            id = id
104        );
105        let mut local_var_req_builder =
106            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
107
108        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
109        local_var_req_builder = local_var_req_builder.json(&report_rotation_failed_request_model);
110
111        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
112    }
113
114    /// Returns the cipher of this access connector's claimed, executing attempt, with its full
115    /// encrypted data.
116    async fn get_cipher<'a>(
117        &self,
118        id: uuid::Uuid,
119    ) -> Result<models::CipherMiniResponseModel, Error> {
120        let local_var_configuration = &self.configuration;
121
122        let local_var_client = &local_var_configuration.client;
123
124        let local_var_uri_str = format!(
125            "{}/access-connectors/rotation/attempts/{id}/cipher",
126            local_var_configuration.base_path,
127            id = id
128        );
129        let mut local_var_req_builder =
130            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
131
132        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
133
134        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
135    }
136
137    /// Writes the rotated cipher (spec AcceptCipherUpdate): a Login cipher request without Data,
138    /// with the item key unchanged and LastKnownRevisionDate from the read. 409: the claim or
139    /// attempt no longer holds, or the revision moved (audited as write_rejected). 404: unknown
140    /// attempt.
141    async fn put_cipher<'a>(
142        &self,
143        id: uuid::Uuid,
144        cipher_request_model: models::CipherRequestModel,
145    ) -> Result<(), Error> {
146        let local_var_configuration = &self.configuration;
147
148        let local_var_client = &local_var_configuration.client;
149
150        let local_var_uri_str = format!(
151            "{}/access-connectors/rotation/attempts/{id}/cipher",
152            local_var_configuration.base_path,
153            id = id
154        );
155        let mut local_var_req_builder =
156            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
157
158        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
159        local_var_req_builder = local_var_req_builder.json(&cipher_request_model);
160
161        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
162    }
163
164    /// Reports a successful rotation (spec RecordRotationSucceeded). Requires the attempt to
165    /// already have a written cipher (the VerifiedBeforeSuccess backstop); otherwise the report is
166    /// treated as stale (409, audited as report_rejected).
167    async fn success<'a>(
168        &self,
169        id: uuid::Uuid,
170        report_rotation_succeeded_request_model: models::ReportRotationSucceededRequestModel,
171    ) -> Result<(), Error> {
172        let local_var_configuration = &self.configuration;
173
174        let local_var_client = &local_var_configuration.client;
175
176        let local_var_uri_str = format!(
177            "{}/access-connectors/rotation/attempts/{id}/success",
178            local_var_configuration.base_path,
179            id = id
180        );
181        let mut local_var_req_builder =
182            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
183
184        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
185        local_var_req_builder =
186            local_var_req_builder.json(&report_rotation_succeeded_request_model);
187
188        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
189    }
190}