forked from Azure/azure-sdk-for-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
private_cloud_list.rs
34 lines (29 loc) · 1.17 KB
/
private_cloud_list.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
/*
Lists the private clouds, similar to:
az vmware private-cloud list --query [].id
az extension documentation:
https://docs.microsoft.com/cli/azure/ext/vmware/vmware/private-cloud?view=azure-cli-latest#ext_vmware_az_vmware_private_cloud_list
API documentation:
https://docs.microsoft.com/rest/api/vmware/privateclouds/list
cargo run --package azure_mgmt_vmware --example private_cloud_list
*/
use azure_identity::AzureCliCredential;
use futures::stream::StreamExt;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let subscription_id = AzureCliCredential::get_subscription().await?;
let credential = Arc::new(AzureCliCredential::new());
let client = azure_mgmt_vmware::Client::builder(credential).build()?;
let mut count = 0;
let mut clouds = client.private_clouds_client().list_in_subscription(subscription_id).into_stream();
while let Some(clouds) = clouds.next().await {
let clouds = clouds?;
count += clouds.value.len();
for cloud in clouds.value {
println!("{:?}", cloud.tracked_resource.resource.id);
}
}
println!("# of private clouds {count}");
Ok(())
}