redis_cloud/handlers/
users.rs1use crate::{Result, client::CloudClient};
4use serde_json::Value;
5
6pub struct CloudUsersHandler {
8 client: CloudClient,
9}
10
11impl CloudUsersHandler {
12 pub fn new(client: CloudClient) -> Self {
13 CloudUsersHandler { client }
14 }
15
16 pub async fn list(&self) -> Result<Value> {
18 self.client.get("/users").await
19 }
20
21 pub async fn get(&self, user_id: u32) -> Result<Value> {
23 self.client.get(&format!("/users/{}", user_id)).await
24 }
25
26 pub async fn create(&self, request: Value) -> Result<Value> {
28 self.client.post("/users", &request).await
29 }
30
31 pub async fn update(&self, user_id: u32, request: Value) -> Result<Value> {
33 self.client
34 .put(&format!("/users/{}", user_id), &request)
35 .await
36 }
37
38 pub async fn delete(&self, user_id: u32) -> Result<Value> {
40 self.client.delete(&format!("/users/{}", user_id)).await?;
41 Ok(serde_json::json!({"message": format!("User {} deleted", user_id)}))
42 }
43}