Skip to main content

azure_devops/projects/methods/
get_with_options.rs

1use super::super::models::{GetProjectOptions, Project};
2use super::super::ProjectsClient;
3use crate::constants;
4use crate::constants::ApiPath;
5use crate::error::Result;
6
7impl ProjectsClient<'_> {
8    /// Get a single project with additional metadata options.
9    ///
10    /// # Arguments
11    ///
12    /// * `project_id` — The project's UUID or unique name.
13    /// * `options` — [`GetProjectOptions`] controlling which extra data to include
14    ///   (capabilities, history).
15    ///
16    /// # Returns
17    ///
18    /// The full [`Project`] object with requested metadata.
19    pub async fn get_with_options(
20        &self,
21        project_id: &str,
22        options: &GetProjectOptions,
23    ) -> Result<Project> {
24        let mut qp: Vec<(String, String)> = Vec::new();
25        if let Some(c) = options.include_capabilities {
26            qp.push((constants::query::INCLUDE_CAPABILITIES.into(), c.to_string()));
27        }
28        if let Some(h) = options.include_history {
29            qp.push((constants::query::INCLUDE_HISTORY.into(), h.to_string()));
30        }
31        let q: Vec<(&str, &str)> = qp.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();
32        self.http.get(&ApiPath::project(project_id), &q).await
33    }
34}