-
Notifications
You must be signed in to change notification settings - Fork 20
/
service_endpoint.rs
47 lines (38 loc) · 1.46 KB
/
service_endpoint.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
44
45
46
47
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// service_endpoint.rs
// Service Endpoint (aka "Service Connection") example.
use anyhow::Result;
use azure_devops_rust_api::service_endpoint;
use std::env;
mod utils;
#[tokio::main]
async fn main() -> Result<()> {
// Get authentication credential
let credential = utils::get_credential()?;
// Get ADO configuration via environment variables
let organization = env::var("ADO_ORGANIZATION").expect("Must define ADO_ORGANIZATION");
let project = env::var("ADO_PROJECT").expect("Must define ADO_PROJECT");
// Create a service_endpoint client
let service_endpoint_client = service_endpoint::ClientBuilder::new(credential).build();
// Use the client to list all service endpoints (aka "service connections")
let service_endpoints = service_endpoint_client
.endpoints_client()
.get_service_endpoints(&organization, &project)
.await?
.value;
println!("Total service_endpoints: {}", service_endpoints.len());
// Display the returned service endpoints
for endpoint in service_endpoints.iter() {
println!(
"{:38} {:40} {}",
endpoint.id, endpoint.name, endpoint.description
);
}
// Display an example service endpoint struct
if let Some(endpoint) = service_endpoints.first() {
println!("\nExample service_endpoint struct:");
println!("{:#?}", endpoint);
}
Ok(())
}