redis_enterprise/
debuginfo.rs1use crate::client::RestClient;
9use crate::error::Result;
10use serde::{Deserialize, Serialize};
11use serde_json::Value;
12use typed_builder::TypedBuilder;
13
14#[derive(Debug, Clone, Serialize, Deserialize, TypedBuilder)]
16pub struct DebugInfoRequest {
17 #[serde(skip_serializing_if = "Option::is_none")]
19 #[builder(default, setter(strip_option))]
20 pub node_uids: Option<Vec<u32>>,
21 #[serde(skip_serializing_if = "Option::is_none")]
23 #[builder(default, setter(strip_option))]
24 pub bdb_uids: Option<Vec<u32>>,
25 #[serde(skip_serializing_if = "Option::is_none")]
27 #[builder(default, setter(strip_option))]
28 pub include_logs: Option<bool>,
29 #[serde(skip_serializing_if = "Option::is_none")]
31 #[builder(default, setter(strip_option))]
32 pub include_metrics: Option<bool>,
33 #[serde(skip_serializing_if = "Option::is_none")]
35 #[builder(default, setter(strip_option))]
36 pub include_configs: Option<bool>,
37 #[serde(skip_serializing_if = "Option::is_none")]
39 #[builder(default, setter(strip_option))]
40 pub time_range: Option<TimeRange>,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct TimeRange {
46 pub start: String,
48 pub end: String,
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct DebugInfoStatus {
55 pub task_id: String,
57 pub status: String,
59 #[serde(skip_serializing_if = "Option::is_none")]
61 pub progress: Option<f32>,
62 #[serde(skip_serializing_if = "Option::is_none")]
64 pub download_url: Option<String>,
65 #[serde(skip_serializing_if = "Option::is_none")]
67 pub error: Option<String>,
68}
69
70pub struct DebugInfoHandler {
72 client: RestClient,
73}
74
75impl DebugInfoHandler {
76 pub fn new(client: RestClient) -> Self {
77 DebugInfoHandler { client }
78 }
79
80 pub async fn create(&self, request: DebugInfoRequest) -> Result<DebugInfoStatus> {
82 self.client.post("/v1/debuginfo", &request).await
83 }
84
85 pub async fn status(&self, task_id: &str) -> Result<DebugInfoStatus> {
87 self.client.get(&format!("/v1/debuginfo/{}", task_id)).await
88 }
89
90 pub async fn list(&self) -> Result<Vec<DebugInfoStatus>> {
92 self.client.get("/v1/debuginfo").await
93 }
94
95 pub async fn download(&self, task_id: &str) -> Result<Vec<u8>> {
97 self.client
98 .get_binary(&format!("/v1/debuginfo/{}/download", task_id))
99 .await
100 }
101
102 pub async fn cancel(&self, task_id: &str) -> Result<()> {
104 self.client
105 .delete(&format!("/v1/debuginfo/{}", task_id))
106 .await
107 }
108
109 pub async fn all(&self) -> Result<Value> {
112 self.client.get("/v1/debuginfo/all").await
113 }
114
115 pub async fn all_bdb(&self, bdb_uid: u32) -> Result<Value> {
118 self.client
119 .get(&format!("/v1/debuginfo/all/bdb/{}", bdb_uid))
120 .await
121 }
122
123 pub async fn node(&self) -> Result<Value> {
126 self.client.get("/v1/debuginfo/node").await
127 }
128
129 pub async fn node_bdb(&self, bdb_uid: u32) -> Result<Value> {
132 self.client
133 .get(&format!("/v1/debuginfo/node/bdb/{}", bdb_uid))
134 .await
135 }
136
137 pub async fn cluster_debuginfo_binary(&self) -> Result<Vec<u8>> {
142 self.client.get_binary("/v1/cluster/debuginfo").await
143 }
144
145 pub async fn nodes_debuginfo_binary(&self) -> Result<Vec<u8>> {
148 self.client.get_binary("/v1/nodes/debuginfo").await
149 }
150
151 pub async fn node_debuginfo_binary(&self, node_uid: u32) -> Result<Vec<u8>> {
154 self.client
155 .get_binary(&format!("/v1/nodes/{}/debuginfo", node_uid))
156 .await
157 }
158
159 pub async fn databases_debuginfo_binary(&self) -> Result<Vec<u8>> {
162 self.client.get_binary("/v1/bdbs/debuginfo").await
163 }
164
165 pub async fn database_debuginfo_binary(&self, bdb_uid: u32) -> Result<Vec<u8>> {
168 self.client
169 .get_binary(&format!("/v1/bdbs/{}/debuginfo", bdb_uid))
170 .await
171 }
172
173 pub async fn all_binary(&self) -> Result<Vec<u8>> {
178 self.client.get_binary("/v1/debuginfo/all").await
179 }
180
181 pub async fn all_bdb_binary(&self, bdb_uid: u32) -> Result<Vec<u8>> {
184 self.client
185 .get_binary(&format!("/v1/debuginfo/all/bdb/{}", bdb_uid))
186 .await
187 }
188
189 pub async fn node_binary(&self) -> Result<Vec<u8>> {
192 self.client.get_binary("/v1/debuginfo/node").await
193 }
194
195 pub async fn node_bdb_binary(&self, bdb_uid: u32) -> Result<Vec<u8>> {
198 self.client
199 .get_binary(&format!("/v1/debuginfo/node/bdb/{}", bdb_uid))
200 .await
201 }
202}