[−][src]Struct azure_sdk_keyvault::KeyVaultClient
Client for Key Vault operations - getting a secret, listing secrets, etc.
Example
use azure_sdk_keyvault::KeyVaultClient; let client = KeyVaultClient::new(&"{client_id}", &"{client_secret}", &"{tenant_id}", &"test-keyvault");
Implementations
impl<'a> KeyVaultClient<'a>
[src]
pub fn with_endpoint_suffix(
aad_client_id: &'a str,
aad_client_secret: &'a str,
aad_tenant_id: &'a str,
keyvault_name: &'a str,
endpoint_suffix: String
) -> Self
[src]
aad_client_id: &'a str,
aad_client_secret: &'a str,
aad_tenant_id: &'a str,
keyvault_name: &'a str,
endpoint_suffix: String
) -> Self
Creates a new KeyVaultClient
with an endpoint suffix. Useful for non-public Azure clouds.
For the default public environment, use KeyVaultClient::new
.
Example
use azure_sdk_keyvault::KeyVaultClient; let client = KeyVaultClient::with_endpoint_suffix(&"c1a6d79b-082b-4798-b362-a77e96de50db", &"SUPER_SECRET_KEY", &"bc598e67-03d8-44d5-aa46-8289b9a39a14", &"test-keyvault", "vault.azure.net".to_owned());
pub fn with_aad_token(
aad_client_id: &'a str,
aad_client_secret: &'a str,
aad_tenant_id: &'a str,
keyvault_name: &'a str,
aad_token: AccessToken,
aad_token_expiration: DateTime<Utc>
) -> Self
[src]
aad_client_id: &'a str,
aad_client_secret: &'a str,
aad_tenant_id: &'a str,
keyvault_name: &'a str,
aad_token: AccessToken,
aad_token_expiration: DateTime<Utc>
) -> Self
Creates a new KeyVaultClient
with a pre-existing AAD token.
Example
use azure_sdk_keyvault::KeyVaultClient; use chrono::{Utc, Duration}; use oauth2::AccessToken; let client = KeyVaultClient::with_aad_token(&"c1a6d79b-082b-4798-b362-a77e96de50db", &"SUPER_SECRET_KEY", &"bc598e67-03d8-44d5-aa46-8289b9a39a14", &"test-keyvault", AccessToken::new(String::new()), Utc::now() + Duration::days(14));
pub fn with_aad_token_and_endpoint_suffix(
aad_client_id: &'a str,
aad_client_secret: &'a str,
aad_tenant_id: &'a str,
keyvault_name: &'a str,
aad_token: AccessToken,
aad_token_expiration: DateTime<Utc>
) -> Self
[src]
aad_client_id: &'a str,
aad_client_secret: &'a str,
aad_tenant_id: &'a str,
keyvault_name: &'a str,
aad_token: AccessToken,
aad_token_expiration: DateTime<Utc>
) -> Self
Creates a new KeyVaultClient
with a pre-existing AAD token.
Example
use azure_sdk_keyvault::KeyVaultClient; use chrono::{Utc, Duration}; use oauth2::AccessToken; let client = KeyVaultClient::with_aad_token(&"c1a6d79b-082b-4798-b362-a77e96de50db", &"SUPER_SECRET_KEY", &"bc598e67-03d8-44d5-aa46-8289b9a39a14", &"test-keyvault", AccessToken::new(String::new()), Utc::now() + Duration::days(14));
pub fn new(
aad_client_id: &'a str,
aad_client_secret: &'a str,
aad_tenant_id: &'a str,
keyvault_name: &'a str
) -> Self
[src]
aad_client_id: &'a str,
aad_client_secret: &'a str,
aad_tenant_id: &'a str,
keyvault_name: &'a str
) -> Self
Creates a new KeyVaultClient
.
Example
use azure_sdk_keyvault::KeyVaultClient; let client = KeyVaultClient::new(&"c1a6d79b-082b-4798-b362-a77e96de50db", &"SUPER_SECRET_KEY", &"bc598e67-03d8-44d5-aa46-8289b9a39a14", &"test-keyvault");
impl<'a> KeyVaultClient<'a>
[src]
pub async fn get_secret<'_>(
&'_ mut self,
secret_name: &'a str
) -> Result<KeyVaultSecret, KeyVaultError>
[src]
&'_ mut self,
secret_name: &'a str
) -> Result<KeyVaultSecret, KeyVaultError>
Gets a secret from the Key Vault.
Note that the latest version is fetched. For a specific version, use get_version_with_version
.
Example
use azure_sdk_keyvault::KeyVaultClient; use tokio::runtime::Runtime; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); let secret = client.get_secret(&"SECRET_NAME").await.unwrap(); dbg!(&secret); } Runtime::new().unwrap().block_on(example());
pub async fn get_secret_with_version<'_>(
&'_ mut self,
secret_name: &'a str,
secret_version_name: &'a str
) -> Result<KeyVaultSecret, KeyVaultError>
[src]
&'_ mut self,
secret_name: &'a str,
secret_version_name: &'a str
) -> Result<KeyVaultSecret, KeyVaultError>
Gets a secret from the Key Vault with a specific version.
If you need the latest version, use get_secret
.
Example
use azure_sdk_keyvault::KeyVaultClient; use tokio::runtime::Runtime; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); let secret = client.get_secret_with_version(&"SECRET_NAME", &"SECRET_VERSION").await.unwrap(); dbg!(&secret); } Runtime::new().unwrap().block_on(example());
pub async fn list_secrets<'_>(
&'_ mut self
) -> Result<Vec<KeyVaultSecretBaseIdentifier>, KeyVaultError>
[src]
&'_ mut self
) -> Result<Vec<KeyVaultSecretBaseIdentifier>, KeyVaultError>
Lists all the secrets in the Key Vault.
use azure_sdk_keyvault::KeyVaultClient; use tokio::runtime::Runtime; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); let secrets = client.list_secrets().await.unwrap(); dbg!(&secrets); } Runtime::new().unwrap().block_on(example());
pub async fn get_secret_versions<'_>(
&'_ mut self,
secret_name: &'a str
) -> Result<Vec<KeyVaultSecretBaseIdentifier>, KeyVaultError>
[src]
&'_ mut self,
secret_name: &'a str
) -> Result<Vec<KeyVaultSecretBaseIdentifier>, KeyVaultError>
Gets all the versions for a secret in the Key Vault.
Example
use azure_sdk_keyvault::KeyVaultClient; use tokio::runtime::Runtime; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); let secret_versions = client.get_secret_versions(&"SECRET_NAME").await.unwrap(); dbg!(&secret_versions); } Runtime::new().unwrap().block_on(example());
pub async fn set_secret<'_>(
&'_ mut self,
secret_name: &'a str,
new_secret_value: &'a str
) -> Result<(), KeyVaultError>
[src]
&'_ mut self,
secret_name: &'a str,
new_secret_value: &'a str
) -> Result<(), KeyVaultError>
Sets the value of a secret in the Key Vault.
Example
use azure_sdk_keyvault::KeyVaultClient; use tokio::runtime::Runtime; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); client.set_secret(&"SECRET_NAME", &"NEW_VALUE").await.unwrap(); } Runtime::new().unwrap().block_on(example());
pub async fn update_secret_enabled<'_>(
&'_ mut self,
secret_name: &'a str,
secret_version: &'a str,
enabled: bool
) -> Result<(), KeyVaultError>
[src]
&'_ mut self,
secret_name: &'a str,
secret_version: &'a str,
enabled: bool
) -> Result<(), KeyVaultError>
Updates whether a secret version is enabled or not.
Arguments
secret_name
- Name of the secretsecret_version
- Version of the secret. Use an empty string for the latest versionenabled
- Newenabled
value of the secret
Example
use azure_sdk_keyvault::KeyVaultClient; use tokio::runtime::Runtime; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); client.update_secret_enabled(&"SECRET_NAME", &"", true).await.unwrap(); } Runtime::new().unwrap().block_on(example());
pub async fn update_secret_recovery_level<'_>(
&'_ mut self,
secret_name: &'a str,
secret_version: &'a str,
recovery_level: RecoveryLevel
) -> Result<(), KeyVaultError>
[src]
&'_ mut self,
secret_name: &'a str,
secret_version: &'a str,
recovery_level: RecoveryLevel
) -> Result<(), KeyVaultError>
Updates the RecoveryLevel
of a secret version.
Arguments
secret_name
- Name of the secretsecret_version
- Version of the secret. Use an empty string for the latest versionrecovery_level
- NewRecoveryLevel
(RecoveryLevel) value of the secret
Example
use azure_sdk_keyvault::{KeyVaultClient, RecoveryLevel}; use tokio::runtime::Runtime; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); client.update_secret_recovery_level(&"SECRET_NAME", &"", RecoveryLevel::Purgeable).await.unwrap(); } Runtime::new().unwrap().block_on(example());
pub async fn update_secret_expiration_time<'_>(
&'_ mut self,
secret_name: &'a str,
secret_version: &'a str,
expiration_time: DateTime<Utc>
) -> Result<(), KeyVaultError>
[src]
&'_ mut self,
secret_name: &'a str,
secret_version: &'a str,
expiration_time: DateTime<Utc>
) -> Result<(), KeyVaultError>
Updates the expiration time of a secret version.
Arguments
secret_name
- Name of the secretsecret_version
- Version of the secret. Use an empty string for the latest version- `expiration_time - New expiration time of the secret
Example
use azure_sdk_keyvault::{KeyVaultClient, RecoveryLevel}; use tokio::runtime::Runtime; use chrono::{Utc, Duration}; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); client.update_secret_expiration_time(&"SECRET_NAME", &"", Utc::now() + Duration::days(14)).await.unwrap(); } Runtime::new().unwrap().block_on(example());
pub async fn restore_secret<'_>(
&'_ mut self,
backup_blob: &'a str
) -> Result<(), KeyVaultError>
[src]
&'_ mut self,
backup_blob: &'a str
) -> Result<(), KeyVaultError>
Restores a backed up secret and all its versions. This operation requires the secrets/restore permission.
Example
use azure_sdk_keyvault::KeyVaultClient; use tokio::runtime::Runtime; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); client.restore_secret(&"KUF6dXJlS2V5VmF1bHRTZWNyZXRCYWNrdXBWMS5taW").await.unwrap(); } Runtime::new().unwrap().block_on(example());
pub async fn backup_secret<'_>(
&'_ mut self,
secret_name: &'a str
) -> Result<KeyVaultSecretBackupBlob, KeyVaultError>
[src]
&'_ mut self,
secret_name: &'a str
) -> Result<KeyVaultSecretBackupBlob, KeyVaultError>
Restores a backed up secret and all its versions. This operation requires the secrets/restore permission.
Example
use azure_sdk_keyvault::KeyVaultClient; use tokio::runtime::Runtime; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); client.backup_secret(&"SECRET_NAME").await.unwrap(); } Runtime::new().unwrap().block_on(example());
pub async fn delete_secret<'_>(
&'_ mut self,
secret_name: &'a str
) -> Result<(), KeyVaultError>
[src]
&'_ mut self,
secret_name: &'a str
) -> Result<(), KeyVaultError>
Deletes a secret in the Key Vault.
Arguments
secret_name
- Name of the secret
Example
use azure_sdk_keyvault::{KeyVaultClient, RecoveryLevel}; use tokio::runtime::Runtime; async fn example() { let mut client = KeyVaultClient::new( &"CLIENT_ID", &"CLIENT_SECRET", &"TENANT_ID", &"KEYVAULT_NAME", ); client.delete_secret(&"SECRET_NAME").await.unwrap(); } Runtime::new().unwrap().block_on(example());
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for KeyVaultClient<'a>
impl<'a> Send for KeyVaultClient<'a>
impl<'a> Sync for KeyVaultClient<'a>
impl<'a> Unpin for KeyVaultClient<'a>
impl<'a> UnwindSafe for KeyVaultClient<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,