akv_cli/
lib.rs

1// Copyright 2025 Heath Stewart.
2// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
3
4pub mod cache;
5mod error;
6pub mod parsing;
7
8use async_stream::try_stream;
9use azure_security_keyvault_secrets::{models::SecretItem, SecretClient};
10pub use error::*;
11use futures::{Stream, StreamExt as _};
12use std::pin::Pin;
13use tracing::Level;
14
15#[tracing::instrument(level = Level::INFO, skip(client), fields(vault = %client.endpoint()))]
16pub fn list_secrets(
17    client: &SecretClient,
18) -> Pin<Box<impl Stream<Item = Result<SecretItem>> + '_>> {
19    Box::pin(try_stream! {
20        let mut pager = client.get_secrets(None)?;
21        while let Some(page) = pager.next().await {
22            let result = page?.into_body().await?;
23            if let Some(secrets) = result.value {
24                for secret in secrets {
25                    yield secret;
26                }
27            }
28        }
29    })
30}