bitwarden_api_api/apis/
accounts_key_management_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 reqwest;
12use serde::{Deserialize, Serialize};
13
14use super::{configuration, Error};
15use crate::{apis::ResponseContent, models};
16
17/// struct for typed errors of method [`accounts_key_management_regenerate_keys_post`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum AccountsKeyManagementRegenerateKeysPostError {
21    UnknownValue(serde_json::Value),
22}
23
24pub async fn accounts_key_management_regenerate_keys_post(
25    configuration: &configuration::Configuration,
26    key_regeneration_request_model: Option<models::KeyRegenerationRequestModel>,
27) -> Result<(), Error<AccountsKeyManagementRegenerateKeysPostError>> {
28    let local_var_configuration = configuration;
29
30    let local_var_client = &local_var_configuration.client;
31
32    let local_var_uri_str = format!(
33        "{}/accounts/key-management/regenerate-keys",
34        local_var_configuration.base_path
35    );
36    let mut local_var_req_builder =
37        local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
38
39    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
40        local_var_req_builder =
41            local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
42    }
43    if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
44        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
45    };
46    local_var_req_builder = local_var_req_builder.json(&key_regeneration_request_model);
47
48    let local_var_req = local_var_req_builder.build()?;
49    let local_var_resp = local_var_client.execute(local_var_req).await?;
50
51    let local_var_status = local_var_resp.status();
52    let local_var_content = local_var_resp.text().await?;
53
54    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
55        Ok(())
56    } else {
57        let local_var_entity: Option<AccountsKeyManagementRegenerateKeysPostError> =
58            serde_json::from_str(&local_var_content).ok();
59        let local_var_error = ResponseContent {
60            status: local_var_status,
61            content: local_var_content,
62            entity: local_var_entity,
63        };
64        Err(Error::ResponseError(local_var_error))
65    }
66}