Skip to main content

azure_devops/projects/methods/
list_with_options.rs

1use super::super::models::{ListProjectsOptions, ProjectList};
2use super::super::ProjectsClient;
3use crate::constants;
4use crate::constants::ApiPath;
5use crate::error::Result;
6
7impl ProjectsClient<'_> {
8    /// List projects with filtering, pagination, and continuation support.
9    ///
10    /// # Arguments
11    ///
12    /// * `options` — [`ListProjectsOptions`] with optional `state_filter`,
13    ///   `top`, `skip`, and `continuation_token` fields.
14    ///
15    /// # Returns
16    ///
17    /// A filtered and paginated [`ProjectList`].
18    pub async fn list_with_options(&self, options: &ListProjectsOptions) -> Result<ProjectList> {
19        let mut qp: Vec<(String, String)> = Vec::new();
20        if let Some(ref f) = options.state_filter {
21            qp.push((constants::query::STATE_FILTER.into(), f.as_str().into()));
22        }
23        if let Some(t) = options.top {
24            qp.push((constants::query::TOP.into(), t.to_string()));
25        }
26        if let Some(s) = options.skip {
27            qp.push((constants::query::SKIP.into(), s.to_string()));
28        }
29        if let Some(c) = options.continuation_token {
30            qp.push((constants::query::CT.into(), c.to_string()));
31        }
32        let q: Vec<(&str, &str)> = qp.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();
33        self.http.get(&ApiPath::projects(), &q).await
34    }
35}