mongodb_atlas_admin/api/database_users/routes/
get_all.rs

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