1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//! Redis module management
//!
//! ## Overview
//! - List available modules
//! - Query module versions
//! - Configure module settings
use crate::client::RestClient;
use crate::error::Result;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
/// Platform-specific information for a module
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PlatformInfo {
/// Platform dependencies (typically an empty object)
#[serde(default)]
pub dependencies: Value,
/// SHA256 checksum of the module binary for this platform
pub sha256: Option<String>,
}
/// Module information
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Module {
pub uid: String,
pub module_name: Option<String>,
pub version: Option<u32>,
pub semantic_version: Option<String>,
pub author: Option<String>,
pub description: Option<String>,
pub homepage: Option<String>,
pub license: Option<String>,
pub command_line_args: Option<String>,
pub capabilities: Option<Vec<String>>,
pub min_redis_version: Option<String>,
pub compatible_redis_version: Option<String>,
pub display_name: Option<String>,
pub is_bundled: Option<bool>,
// Additional fields from API audit
/// Whether the module supports BigStore (Auto Tiering) version 2
pub bigstore_version_2_support: Option<bool>,
/// Name of the capability this module provides
pub capability_name: Option<String>,
/// Redis command used to configure this module
pub config_command: Option<String>,
/// CRDB (Conflict-free Replicated Database) configuration
/// The API returns an empty object {} for modules without CRDB support
pub crdb: Option<Value>,
/// Module dependencies
/// The API returns an empty object {} for modules without dependencies
pub dependencies: Option<Value>,
/// Contact email address of the module author
pub email: Option<String>,
/// Minimum Redis Enterprise version required for this module
pub min_redis_pack_version: Option<String>,
/// Platform-specific information for this module
/// Maps platform names (e.g., 'rhel9/x86_64', 'rhel8/x86_64') to platform details
#[serde(default)]
pub platforms: Option<HashMap<String, PlatformInfo>>,
/// SHA256 checksum of the module binary for verification
pub sha256: Option<String>,
}
/// Module handler for managing Redis modules
pub struct ModuleHandler {
client: RestClient,
}
/// Alias for backwards compatibility and intuitive plural naming
pub type ModulesHandler = ModuleHandler;
impl ModuleHandler {
pub fn new(client: RestClient) -> Self {
ModuleHandler { client }
}
/// List all modules
pub async fn list(&self) -> Result<Vec<Module>> {
self.client.get("/v1/modules").await
}
/// Get specific module
pub async fn get(&self, uid: &str) -> Result<Module> {
self.client.get(&format!("/v1/modules/{}", uid)).await
}
/// Upload new module (tries v2 first, falls back to v1)
///
/// Note: Some Redis Enterprise versions (particularly RE 8.x) do not support
/// module upload via the REST API. In those cases, use the Admin UI or
/// node-level CLI tools (rladmin) to upload modules.
pub async fn upload(&self, module_data: Vec<u8>, file_name: &str) -> Result<Value> {
// Try v2 first (returns action_uid for async tracking)
match self
.client
.post_multipart("/v2/modules", module_data.clone(), "module", file_name)
.await
{
Ok(response) => Ok(response),
Err(crate::error::RestError::NotFound) => {
// v2 endpoint doesn't exist, try v1
match self
.client
.post_multipart("/v1/modules", module_data, "module", file_name)
.await
{
Ok(response) => Ok(response),
Err(crate::error::RestError::ApiError { code: 405, .. }) => {
Err(crate::error::RestError::ValidationError(
"Module upload via REST API is not supported in this Redis Enterprise version. \
Use the Admin UI or rladmin CLI to upload modules.".to_string()
))
}
Err(e) => Err(e),
}
}
Err(crate::error::RestError::ApiError { code: 405, .. }) => {
Err(crate::error::RestError::ValidationError(
"Module upload via REST API is not supported in this Redis Enterprise version. \
Use the Admin UI or rladmin CLI to upload modules.".to_string()
))
}
Err(e) => Err(e),
}
}
/// Delete module
pub async fn delete(&self, uid: &str) -> Result<()> {
self.client.delete(&format!("/v1/modules/{}", uid)).await
}
/// Update module configuration
pub async fn update(&self, uid: &str, updates: Value) -> Result<Module> {
self.client
.put(&format!("/v1/modules/{}", uid), &updates)
.await
}
/// Configure modules for a specific database - POST /v1/modules/config/bdb/{uid}
pub async fn config_bdb(&self, bdb_uid: u32, config: Value) -> Result<Module> {
self.client
.post(&format!("/v1/modules/config/bdb/{}", bdb_uid), &config)
.await
}
}