Skip to main content

redis_enterprise/
debuginfo.rs

1//! Debuginfo management for Redis Enterprise
2//!
3//! ## Overview
4//! - List and query resources
5//! - Create and update configurations
6//! - Monitor status and metrics
7
8use crate::client::RestClient;
9use crate::error::Result;
10use serde::{Deserialize, Serialize};
11use serde_json::Value;
12use typed_builder::TypedBuilder;
13
14/// Debug info collection request
15#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
16pub struct DebugInfoRequest {
17    /// List of node UIDs to collect debug info from (if not specified, collects from all nodes)
18    #[serde(skip_serializing_if = "Option::is_none")]
19    #[builder(default, setter(strip_option))]
20    pub node_uids: Option<Vec<u32>>,
21    /// List of database UIDs to collect debug info for (if not specified, collects for all databases)
22    #[serde(skip_serializing_if = "Option::is_none")]
23    #[builder(default, setter(strip_option))]
24    pub bdb_uids: Option<Vec<u32>>,
25    /// Whether to include log files in the debug info collection
26    #[serde(skip_serializing_if = "Option::is_none")]
27    #[builder(default, setter(strip_option))]
28    pub include_logs: Option<bool>,
29    /// Whether to include system and database metrics in the debug info
30    #[serde(skip_serializing_if = "Option::is_none")]
31    #[builder(default, setter(strip_option))]
32    pub include_metrics: Option<bool>,
33    /// Whether to include configuration files and settings
34    #[serde(skip_serializing_if = "Option::is_none")]
35    #[builder(default, setter(strip_option))]
36    pub include_configs: Option<bool>,
37    /// Time range for collecting historical data and logs
38    #[serde(skip_serializing_if = "Option::is_none")]
39    #[builder(default, setter(strip_option))]
40    pub time_range: Option<TimeRange>,
41}
42
43/// Time range for debug info collection
44#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct TimeRange {
46    /// Start time for data collection (ISO 8601 format)
47    pub start: String,
48    /// End time for data collection (ISO 8601 format)
49    pub end: String,
50}
51
52/// Debug info status
53#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct DebugInfoStatus {
55    /// Unique identifier for the debug info collection task
56    pub task_id: String,
57    /// Current status of the debug info collection (queued, running, completed, failed)
58    pub status: String,
59    /// Completion progress as a percentage (0.0-100.0)
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub progress: Option<f32>,
62    /// URL for downloading the collected debug info package
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub download_url: Option<String>,
65    /// Error description if the collection task failed
66    #[serde(skip_serializing_if = "Option::is_none")]
67    pub error: Option<String>,
68}
69
70/// Debug info handler
71pub struct DebugInfoHandler {
72    client: RestClient,
73}
74
75impl DebugInfoHandler {
76    /// Create a new handler bound to the given REST client.
77    pub fn new(client: RestClient) -> Self {
78        DebugInfoHandler { client }
79    }
80
81    /// Retired task-style debug info creation helper.
82    #[deprecated(note = "use the documented cluster, node, or database debuginfo methods")]
83    pub async fn create(&self, _request: DebugInfoRequest) -> Result<DebugInfoStatus> {
84        crate::error::unsupported_operation("create generic debuginfo task")
85    }
86
87    /// Retired task-style debug info status helper.
88    #[deprecated(note = "Redis Software does not register task-style debuginfo routes")]
89    pub async fn status(&self, _task_id: &str) -> Result<DebugInfoStatus> {
90        crate::error::unsupported_operation("get generic debuginfo task status")
91    }
92
93    /// Retired task-style debug info list helper.
94    #[deprecated(note = "Redis Software does not register task-style debuginfo routes")]
95    pub async fn list(&self) -> Result<Vec<DebugInfoStatus>> {
96        crate::error::unsupported_operation("list generic debuginfo tasks")
97    }
98
99    /// Retired task-style debug info download helper.
100    #[deprecated(note = "use the documented cluster, node, or database debuginfo methods")]
101    pub async fn download(&self, _task_id: &str) -> Result<Vec<u8>> {
102        crate::error::unsupported_operation("download generic debuginfo task")
103    }
104
105    /// Retired task-style debug info cancellation helper.
106    #[deprecated(note = "Redis Software does not register task-style debuginfo routes")]
107    pub async fn cancel(&self, _task_id: &str) -> Result<()> {
108        crate::error::unsupported_operation("cancel generic debuginfo task")
109    }
110
111    /// Get all debug info across nodes - GET /v1/debuginfo/all (DEPRECATED)
112    /// Use cluster_debuginfo_binary() for the new endpoint
113    pub async fn all(&self) -> Result<Value> {
114        self.client.get("/v1/debuginfo/all").await
115    }
116
117    /// Get all debug info for a specific database - GET /v1/debuginfo/all/bdb/{uid} (DEPRECATED)
118    /// Use database_debuginfo_binary() for the new endpoint
119    pub async fn all_bdb(&self, bdb_uid: u32) -> Result<Value> {
120        self.client
121            .get(&format!("/v1/debuginfo/all/bdb/{}", bdb_uid))
122            .await
123    }
124
125    /// Get node debug info - GET /v1/debuginfo/node (DEPRECATED)
126    /// Use nodes_debuginfo_binary() for the new endpoint
127    pub async fn node(&self) -> Result<Value> {
128        self.client.get("/v1/debuginfo/node").await
129    }
130
131    /// Get node debug info for a specific database - GET /v1/debuginfo/node/bdb/{uid} (DEPRECATED)
132    /// Use database_debuginfo_binary() for the new endpoint
133    pub async fn node_bdb(&self, bdb_uid: u32) -> Result<Value> {
134        self.client
135            .get(&format!("/v1/debuginfo/node/bdb/{}", bdb_uid))
136            .await
137    }
138
139    // New binary endpoints (current API)
140
141    /// Get cluster debug info package as binary - GET /v1/cluster/debuginfo
142    /// Returns a tar.gz file containing all cluster debug information
143    pub async fn cluster_debuginfo_binary(&self) -> Result<Vec<u8>> {
144        self.client.get_binary("/v1/cluster/debuginfo").await
145    }
146
147    /// Get all nodes debug info package as binary - GET /v1/nodes/debuginfo
148    /// Returns a tar.gz file containing debug information from all nodes
149    pub async fn nodes_debuginfo_binary(&self) -> Result<Vec<u8>> {
150        self.client.get_binary("/v1/nodes/debuginfo").await
151    }
152
153    /// Get specific node debug info package as binary - GET /v1/nodes/{uid}/debuginfo
154    /// Returns a tar.gz file containing debug information from a specific node
155    pub async fn node_debuginfo_binary(&self, node_uid: u32) -> Result<Vec<u8>> {
156        self.client
157            .get_binary(&format!("/v1/nodes/{}/debuginfo", node_uid))
158            .await
159    }
160
161    /// Get all databases debug info package as binary - GET /v1/bdbs/debuginfo
162    /// Returns a tar.gz file containing debug information from all databases
163    pub async fn databases_debuginfo_binary(&self) -> Result<Vec<u8>> {
164        self.client.get_binary("/v1/bdbs/debuginfo").await
165    }
166
167    /// Get specific database debug info package as binary - GET /v1/bdbs/{uid}/debuginfo
168    /// Returns a tar.gz file containing debug information from a specific database
169    pub async fn database_debuginfo_binary(&self, bdb_uid: u32) -> Result<Vec<u8>> {
170        self.client
171            .get_binary(&format!("/v1/bdbs/{}/debuginfo", bdb_uid))
172            .await
173    }
174
175    // Deprecated binary endpoints (for backward compatibility)
176
177    /// Get all debug info as binary - GET /v1/debuginfo/all (DEPRECATED)
178    /// Returns a tar.gz file - Use cluster_debuginfo_binary() instead
179    pub async fn all_binary(&self) -> Result<Vec<u8>> {
180        self.client.get_binary("/v1/debuginfo/all").await
181    }
182
183    /// Get all debug info for a specific database as binary - GET /v1/debuginfo/all/bdb/{uid} (DEPRECATED)
184    /// Returns a tar.gz file - Use database_debuginfo_binary() instead
185    pub async fn all_bdb_binary(&self, bdb_uid: u32) -> Result<Vec<u8>> {
186        self.client
187            .get_binary(&format!("/v1/debuginfo/all/bdb/{}", bdb_uid))
188            .await
189    }
190
191    /// Get node debug info as binary - GET /v1/debuginfo/node (DEPRECATED)
192    /// Returns a tar.gz file - Use nodes_debuginfo_binary() instead
193    pub async fn node_binary(&self) -> Result<Vec<u8>> {
194        self.client.get_binary("/v1/debuginfo/node").await
195    }
196
197    /// Get node debug info for a specific database as binary - GET /v1/debuginfo/node/bdb/{uid} (DEPRECATED)
198    /// Returns a tar.gz file - Use database_debuginfo_binary() instead
199    pub async fn node_bdb_binary(&self, bdb_uid: u32) -> Result<Vec<u8>> {
200        self.client
201            .get_binary(&format!("/v1/debuginfo/node/bdb/{}", bdb_uid))
202            .await
203    }
204}