use anyhow::Result;
use azure_devops_rust_api::build;
use std::env;
use time::{ext::NumericalDuration, OffsetDateTime};
mod utils;
#[tokio::main]
async fn main() -> Result<()> {
let credential = utils::get_credential()?;
let organization = env::var("ADO_ORGANIZATION").expect("Must define ADO_ORGANIZATION");
let project = env::var("ADO_PROJECT").expect("Must define ADO_PROJECT");
println!("Create build client");
let build_client = build::ClientBuilder::new(credential).build();
let end_time = OffsetDateTime::now_utc();
let start_time = end_time - 1.hours();
println!("Get list");
let builds = build_client
.builds_client()
.list(organization, project)
.min_time(start_time)
.max_time(end_time)
.await?
.value;
println!("Found {} builds", builds.len());
if let Some(build) = builds.first() {
println!("Example build struct: {build:#?}");
}
Ok(())
}