mongodb_atlas_admin/api/projects/
get_all.rs1use std::borrow::Cow;
2
3use http::Method;
4use reqwest::Response;
5use serde::Deserialize;
6
7use super::Project;
8use crate::Endpoint;
9
10pub struct GetAllProject;
11
12#[derive(Debug, Deserialize)]
13#[serde(rename_all = "camelCase")]
14pub struct GetAllProjectData {
15 pub results: Vec<Project>,
16 pub total_count: usize,
17}
18
19#[derive(Debug, thiserror::Error)]
20#[error("Error")]
21pub struct Error;
22
23#[async_trait::async_trait]
24impl Endpoint for GetAllProject {
25 type Data = GetAllProjectData;
26 type Error = Error;
27
28 fn method() -> Method {
29 Method::GET
30 }
31
32 fn path(&self) -> Cow<'static, str> {
33 Cow::from("/groups")
34 }
35
36 async fn get_data(res: Response) -> Result<Self::Data, Self::Error> {
37 Ok(res.json::<Self::Data>().await.unwrap())
38 }
39}