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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//! Debuginfo management for Redis Enterprise
//!
//! ## Overview
//! - List and query resources
//! - Create and update configurations
//! - Monitor status and metrics
use crate::client::RestClient;
use crate::error::Result;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use typed_builder::TypedBuilder;
/// Debug info collection request
#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
pub struct DebugInfoRequest {
/// List of node UIDs to collect debug info from (if not specified, collects from all nodes)
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub node_uids: Option<Vec<u32>>,
/// List of database UIDs to collect debug info for (if not specified, collects for all databases)
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub bdb_uids: Option<Vec<u32>>,
/// Whether to include log files in the debug info collection
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub include_logs: Option<bool>,
/// Whether to include system and database metrics in the debug info
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub include_metrics: Option<bool>,
/// Whether to include configuration files and settings
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub include_configs: Option<bool>,
/// Time range for collecting historical data and logs
#[serde(skip_serializing_if = "Option::is_none")]
#[builder(default, setter(strip_option))]
pub time_range: Option<TimeRange>,
}
/// Time range for debug info collection
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TimeRange {
/// Start time for data collection (ISO 8601 format)
pub start: String,
/// End time for data collection (ISO 8601 format)
pub end: String,
}
/// Debug info status
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DebugInfoStatus {
/// Unique identifier for the debug info collection task
pub task_id: String,
/// Current status of the debug info collection (queued, running, completed, failed)
pub status: String,
/// Completion progress as a percentage (0.0-100.0)
#[serde(skip_serializing_if = "Option::is_none")]
pub progress: Option<f32>,
/// URL for downloading the collected debug info package
#[serde(skip_serializing_if = "Option::is_none")]
pub download_url: Option<String>,
/// Error description if the collection task failed
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
}
/// Debug info handler
pub struct DebugInfoHandler {
client: RestClient,
}
impl DebugInfoHandler {
pub fn new(client: RestClient) -> Self {
DebugInfoHandler { client }
}
/// Start debug info collection
pub async fn create(&self, request: DebugInfoRequest) -> Result<DebugInfoStatus> {
self.client.post("/v1/debuginfo", &request).await
}
/// Get debug info collection status
pub async fn status(&self, task_id: &str) -> Result<DebugInfoStatus> {
self.client.get(&format!("/v1/debuginfo/{}", task_id)).await
}
/// List all debug info tasks
pub async fn list(&self) -> Result<Vec<DebugInfoStatus>> {
self.client.get("/v1/debuginfo").await
}
/// Download debug info package
pub async fn download(&self, task_id: &str) -> Result<Vec<u8>> {
self.client
.get_binary(&format!("/v1/debuginfo/{}/download", task_id))
.await
}
/// Cancel debug info collection
pub async fn cancel(&self, task_id: &str) -> Result<()> {
self.client
.delete(&format!("/v1/debuginfo/{}", task_id))
.await
}
/// Get all debug info across nodes - GET /v1/debuginfo/all (DEPRECATED)
/// Use cluster_debuginfo_binary() for the new endpoint
pub async fn all(&self) -> Result<Value> {
self.client.get("/v1/debuginfo/all").await
}
/// Get all debug info for a specific database - GET /v1/debuginfo/all/bdb/{uid} (DEPRECATED)
/// Use database_debuginfo_binary() for the new endpoint
pub async fn all_bdb(&self, bdb_uid: u32) -> Result<Value> {
self.client
.get(&format!("/v1/debuginfo/all/bdb/{}", bdb_uid))
.await
}
/// Get node debug info - GET /v1/debuginfo/node (DEPRECATED)
/// Use nodes_debuginfo_binary() for the new endpoint
pub async fn node(&self) -> Result<Value> {
self.client.get("/v1/debuginfo/node").await
}
/// Get node debug info for a specific database - GET /v1/debuginfo/node/bdb/{uid} (DEPRECATED)
/// Use database_debuginfo_binary() for the new endpoint
pub async fn node_bdb(&self, bdb_uid: u32) -> Result<Value> {
self.client
.get(&format!("/v1/debuginfo/node/bdb/{}", bdb_uid))
.await
}
// New binary endpoints (current API)
/// Get cluster debug info package as binary - GET /v1/cluster/debuginfo
/// Returns a tar.gz file containing all cluster debug information
pub async fn cluster_debuginfo_binary(&self) -> Result<Vec<u8>> {
self.client.get_binary("/v1/cluster/debuginfo").await
}
/// Get all nodes debug info package as binary - GET /v1/nodes/debuginfo
/// Returns a tar.gz file containing debug information from all nodes
pub async fn nodes_debuginfo_binary(&self) -> Result<Vec<u8>> {
self.client.get_binary("/v1/nodes/debuginfo").await
}
/// Get specific node debug info package as binary - GET /v1/nodes/{uid}/debuginfo
/// Returns a tar.gz file containing debug information from a specific node
pub async fn node_debuginfo_binary(&self, node_uid: u32) -> Result<Vec<u8>> {
self.client
.get_binary(&format!("/v1/nodes/{}/debuginfo", node_uid))
.await
}
/// Get all databases debug info package as binary - GET /v1/bdbs/debuginfo
/// Returns a tar.gz file containing debug information from all databases
pub async fn databases_debuginfo_binary(&self) -> Result<Vec<u8>> {
self.client.get_binary("/v1/bdbs/debuginfo").await
}
/// Get specific database debug info package as binary - GET /v1/bdbs/{uid}/debuginfo
/// Returns a tar.gz file containing debug information from a specific database
pub async fn database_debuginfo_binary(&self, bdb_uid: u32) -> Result<Vec<u8>> {
self.client
.get_binary(&format!("/v1/bdbs/{}/debuginfo", bdb_uid))
.await
}
// Deprecated binary endpoints (for backward compatibility)
/// Get all debug info as binary - GET /v1/debuginfo/all (DEPRECATED)
/// Returns a tar.gz file - Use cluster_debuginfo_binary() instead
pub async fn all_binary(&self) -> Result<Vec<u8>> {
self.client.get_binary("/v1/debuginfo/all").await
}
/// Get all debug info for a specific database as binary - GET /v1/debuginfo/all/bdb/{uid} (DEPRECATED)
/// Returns a tar.gz file - Use database_debuginfo_binary() instead
pub async fn all_bdb_binary(&self, bdb_uid: u32) -> Result<Vec<u8>> {
self.client
.get_binary(&format!("/v1/debuginfo/all/bdb/{}", bdb_uid))
.await
}
/// Get node debug info as binary - GET /v1/debuginfo/node (DEPRECATED)
/// Returns a tar.gz file - Use nodes_debuginfo_binary() instead
pub async fn node_binary(&self) -> Result<Vec<u8>> {
self.client.get_binary("/v1/debuginfo/node").await
}
/// Get node debug info for a specific database as binary - GET /v1/debuginfo/node/bdb/{uid} (DEPRECATED)
/// Returns a tar.gz file - Use database_debuginfo_binary() instead
pub async fn node_bdb_binary(&self, bdb_uid: u32) -> Result<Vec<u8>> {
self.client
.get_binary(&format!("/v1/debuginfo/node/bdb/{}", bdb_uid))
.await
}
}