forked from Azure/azure-sdk-for-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_pools.rs
35 lines (28 loc) · 1.13 KB
/
list_pools.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
31
32
33
34
35
/*
Prints the name of pools using the data plane APIs
cargo run --package azure_svc_batch --example list_pools
*/
use azure_identity::AzureCliCredential;
use futures::stream::StreamExt;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
let account_name = std::env::args().nth(1).expect("please specify batch account");
let region = std::env::args().nth(2).expect("please specify region");
let endpoint = azure_core::Url::parse(&format!("https://{account_name}.{region}.batch.azure.com"))?;
let scopes = &["https://batch.core.windows.net/.default"];
let credential = Arc::new(AzureCliCredential::new());
let client = azure_svc_batch::Client::builder(credential)
.endpoint(endpoint)
.scopes(scopes)
.build()?;
let mut stream = client.pool_client().list().into_stream();
while let Some(pools) = stream.next().await {
let pools = pools?;
for pool in pools.value {
println!("id: {:?}", pool.id);
}
}
Ok(())
}