azure-devops 0.1.0

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

impl ProjectsClient<'_> {
    /// List projects with filtering, pagination, and continuation support.
    ///
    /// # Arguments
    ///
    /// * `options` — [`ListProjectsOptions`] with optional `state_filter`,
    ///   `top`, `skip`, and `continuation_token` fields.
    ///
    /// # Returns
    ///
    /// A filtered and paginated [`ProjectList`].
    pub async fn list_with_options(&self, options: &ListProjectsOptions) -> Result<ProjectList> {
        let mut qp: Vec<(String, String)> = Vec::new();
        if let Some(ref f) = options.state_filter {
            qp.push((constants::query::STATE_FILTER.into(), f.as_str().into()));
        }
        if let Some(t) = options.top {
            qp.push((constants::query::TOP.into(), t.to_string()));
        }
        if let Some(s) = options.skip {
            qp.push((constants::query::SKIP.into(), s.to_string()));
        }
        if let Some(c) = options.continuation_token {
            qp.push((constants::query::CT.into(), c.to_string()));
        }
        let q: Vec<(&str, &str)> = qp.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();
        self.http.get(&ApiPath::projects(), &q).await
    }
}