bitwarden_sm/secrets/
get_by_ids.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use bitwarden_api_api::models::GetSecretsRequestModel;
use bitwarden_core::{client::Client, Error};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use super::SecretsResponse;

#[derive(Serialize, Deserialize, Debug, JsonSchema)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct SecretsGetRequest {
    /// IDs of the secrets to retrieve
    pub ids: Vec<Uuid>,
}

pub(crate) async fn get_secrets_by_ids(
    client: &Client,
    input: SecretsGetRequest,
) -> Result<SecretsResponse, Error> {
    let request = Some(GetSecretsRequestModel { ids: input.ids });

    let config = client.internal.get_api_configurations().await;

    let res =
        bitwarden_api_api::apis::secrets_api::secrets_get_by_ids_post(&config.api, request).await?;

    let enc = client.internal.get_encryption_settings()?;

    SecretsResponse::process_response(res, &enc)
}