bitwarden_sm/
client.rs

1//! Client for the Bitwarden Secrets Manager API
2
3pub use bitwarden_core::ClientSettings;
4use bitwarden_core::{OrganizationId, auth::auth_client::AuthClient};
5use bitwarden_generators::GeneratorClientsExt;
6
7use crate::{ProjectsClient, SecretsClient};
8
9/// The main struct for interacting with the Secrets Manager service through the SM SDK.
10pub struct SecretsManagerClient {
11    client: bitwarden_core::Client,
12}
13
14impl SecretsManagerClient {
15    /// Create a new SecretsManagerClient
16    pub fn new(settings: Option<ClientSettings>) -> Self {
17        Self {
18            client: bitwarden_core::Client::new(settings),
19        }
20    }
21
22    /// Get access to the Projects API
23    pub fn projects(&self) -> ProjectsClient {
24        ProjectsClient::new(self.client.clone())
25    }
26
27    /// Get access to the Secrets API
28    pub fn secrets(&self) -> SecretsClient {
29        SecretsClient::new(self.client.clone())
30    }
31
32    /// Get access to the Auth API
33    pub fn auth(&self) -> AuthClient {
34        self.client.auth()
35    }
36
37    /// Get access to the Generators API
38    pub fn generator(&self) -> bitwarden_generators::GeneratorClient {
39        self.client.generator()
40    }
41
42    #[doc(hidden)]
43    pub fn get_access_token_organization(&self) -> Option<OrganizationId> {
44        self.client.internal.get_access_token_organization()
45    }
46}