forked from microsoft/azure-devops-rust-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
permissions_report.rs
43 lines (39 loc) · 1.4 KB
/
permissions_report.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
36
37
38
39
40
41
42
43
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// permissions_report.rs
// Permissions report example
use anyhow::Result;
use azure_devops_rust_api::permissions_report;
use azure_devops_rust_api::Credential;
use std::env;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<()> {
// Initialize logging
env_logger::init();
// Get authentication credential either from a PAT ("ADO_TOKEN") or via the az cli.
let credential = match env::var("ADO_TOKEN") {
Ok(token) => {
println!("Authenticate using PAT provided via $ADO_TOKEN");
Credential::from_pat(token)
}
Err(_) => {
println!("Authenticate using Azure CLI");
Credential::from_token_credential(Arc::new(azure_identity::AzureCliCredential::new()))
}
};
// Get ADO server configuration via environment variables
let organization = env::var("ADO_ORGANIZATION").expect("Must define ADO_ORGANIZATION");
// Create permissions_report client
let permissions_report_client = permissions_report::ClientBuilder::new(credential).build();
// Get Permissions reports
println!("Permissions reports:");
let permissions_reports = permissions_report_client
.permissions_report_client()
.list(&organization)
.into_future()
.await?
.value;
println!("{:#?}", permissions_reports);
Ok(())
}