Skip to main content

edgequake_sdk/resources/
users.rs

1//! Users resource.
2
3use crate::client::EdgeQuakeClient;
4use crate::error::Result;
5use crate::types::auth::*;
6
7pub struct UsersResource<'a> {
8    pub(crate) client: &'a EdgeQuakeClient,
9}
10
11impl<'a> UsersResource<'a> {
12    /// `GET /api/v1/users`
13    pub async fn list(&self) -> Result<Vec<UserInfo>> {
14        self.client.get("/api/v1/users").await
15    }
16
17    /// `POST /api/v1/users`
18    pub async fn create(&self, req: &CreateUserRequest) -> Result<UserInfo> {
19        self.client.post("/api/v1/users", Some(req)).await
20    }
21
22    /// `GET /api/v1/users/{id}`
23    pub async fn get(&self, id: &str) -> Result<UserInfo> {
24        self.client.get(&format!("/api/v1/users/{id}")).await
25    }
26
27    /// `DELETE /api/v1/users/{id}`
28    pub async fn delete(&self, id: &str) -> Result<()> {
29        self.client
30            .delete_no_content(&format!("/api/v1/users/{id}"))
31            .await
32    }
33}