azure-devops 0.1.0

Idiomatic Rust client for Azure DevOps REST APIs
Documentation
use super::super::models::Build;
use super::super::BuildsClient;
use crate::constants;
use crate::constants::ApiPath;
use crate::error::Result;

impl BuildsClient<'_> {
    /// Get the latest build for a definition, optionally filtered by branch.
    ///
    /// # Arguments
    ///
    /// * `project` — The project name.
    /// * `def` — The build definition ID.
    /// * `branch` — Optional branch name filter.
    ///
    /// # Returns
    ///
    /// The latest [`Build`] matching the criteria.
    pub async fn get_latest(&self, project: &str, def: i64, branch: Option<&str>) -> Result<Build> {
        let qp = branch.map_or_else(Vec::new, |b| {
            vec![(constants::query::BRANCH_NAME.into(), b.into())]
        });
        self.http
            .get(
                &ApiPath::build_latest(project, def),
                &crate::util::ref_query(&qp),
            )
            .await
    }
}