[][src]Struct azure_sdk_keyvault::KeyVaultClient

pub struct KeyVaultClient<'a> { /* fields omitted */ }

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]

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]

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]

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]

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]

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]

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]

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]

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]

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]

Updates whether a secret version is enabled or not.

Arguments

  • secret_name - Name of the secret
  • secret_version - Version of the secret. Use an empty string for the latest version
  • enabled - New enabled 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]

Updates the RecoveryLevel of a secret version.

Arguments

  • secret_name - Name of the secret
  • secret_version - Version of the secret. Use an empty string for the latest version
  • recovery_level - New RecoveryLevel(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]

Updates the expiration time of a secret version.

Arguments

  • secret_name - Name of the secret
  • secret_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]

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]

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]

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

impl<'a> Debug for KeyVaultClient<'a>[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,