redis_enterprise/
bdb_groups.rs

1//! Database group configuration
2//!
3//! ## Overview
4//! - Manage database groups
5//! - Configure group settings
6//! - Query group membership
7
8use crate::client::RestClient;
9use crate::error::Result;
10use serde::{Deserialize, Serialize};
11use serde_json::Value;
12
13/// Database group information
14/// Represents a group of databases that share a memory pool
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct BdbGroup {
17    /// Cluster unique ID of the database group
18    pub uid: u32,
19    /// Group name (may be auto-generated if not specified)
20    pub name: String,
21    /// The common memory pool size limit for all databases in the group, expressed in bytes
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub memory_size: Option<u64>,
24    /// A list of UIDs of member databases (read-only)
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub members: Option<Vec<String>>,
27    #[serde(flatten)]
28    pub extra: Value,
29}
30
31/// Handler for database group operations
32pub struct BdbGroupsHandler {
33    client: RestClient,
34}
35
36impl BdbGroupsHandler {
37    pub fn new(client: RestClient) -> Self {
38        BdbGroupsHandler { client }
39    }
40
41    pub async fn list(&self) -> Result<Vec<BdbGroup>> {
42        self.client.get("/v1/bdb_groups").await
43    }
44
45    pub async fn get(&self, uid: u32) -> Result<BdbGroup> {
46        self.client.get(&format!("/v1/bdb_groups/{}", uid)).await
47    }
48
49    pub async fn create(&self, body: CreateBdbGroupRequest) -> Result<BdbGroup> {
50        self.client.post("/v1/bdb_groups", &body).await
51    }
52
53    pub async fn update(&self, uid: u32, body: UpdateBdbGroupRequest) -> Result<BdbGroup> {
54        self.client
55            .put(&format!("/v1/bdb_groups/{}", uid), &body)
56            .await
57    }
58
59    pub async fn delete(&self, uid: u32) -> Result<()> {
60        self.client.delete(&format!("/v1/bdb_groups/{}", uid)).await
61    }
62}
63
64/// Request to create a new database group
65#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct CreateBdbGroupRequest {
67    pub name: String,
68}
69
70/// Request to update an existing database group
71#[derive(Debug, Clone, Serialize, Deserialize)]
72pub struct UpdateBdbGroupRequest {
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub name: Option<String>,
75}