azure-devops 0.1.0

Idiomatic Rust client for Azure DevOps REST APIs
Documentation
use super::super::models::{GetProjectOptions, Project};
use super::super::ProjectsClient;
use crate::constants;
use crate::constants::ApiPath;
use crate::error::Result;

impl ProjectsClient<'_> {
    /// Get a single project with additional metadata options.
    ///
    /// # Arguments
    ///
    /// * `project_id` — The project's UUID or unique name.
    /// * `options` — [`GetProjectOptions`] controlling which extra data to include
    ///   (capabilities, history).
    ///
    /// # Returns
    ///
    /// The full [`Project`] object with requested metadata.
    pub async fn get_with_options(
        &self,
        project_id: &str,
        options: &GetProjectOptions,
    ) -> Result<Project> {
        let mut qp: Vec<(String, String)> = Vec::new();
        if let Some(c) = options.include_capabilities {
            qp.push((constants::query::INCLUDE_CAPABILITIES.into(), c.to_string()));
        }
        if let Some(h) = options.include_history {
            qp.push((constants::query::INCLUDE_HISTORY.into(), h.to_string()));
        }
        let q: Vec<(&str, &str)> = qp.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();
        self.http.get(&ApiPath::project(project_id), &q).await
    }
}