Skip to content

Commit d0698ea

Browse files
joshrotenbergclaude
andcommitted
feat: migrate cloud database list and enterprise cluster info to typed APIs
- Modified cloud database list command to use CloudDatabaseHandler::list_all() - Modified enterprise cluster info command to use ClusterHandler::info() - Both commands now use typed API methods instead of raw JSON calls - This enables better type safety and dogfooding of our own libraries Part of issue #24: Migrate redisctl commands to use typed APIs Co-Authored-By: Claude <[email protected]>
1 parent 1948f82 commit d0698ea

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

crates/redisctl/src/commands/cloud.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,11 @@ pub async fn handle_database_command(
103103

104104
match command {
105105
DatabaseCommands::List => {
106-
// For Cloud, we need to list databases across all subscriptions
107-
let subscriptions = client.get_raw("/subscriptions").await?;
108-
let mut all_databases = Vec::new();
109-
110-
if let Some(subs) = subscriptions.as_array() {
111-
for subscription in subs {
112-
if let Some(subscription_id) = subscription.get("id").and_then(|id| id.as_u64())
113-
{
114-
let databases = client
115-
.get_raw(&format!("/subscriptions/{}/databases", subscription_id))
116-
.await?;
117-
if let Some(dbs) = databases.as_array() {
118-
all_databases.extend(dbs.iter().cloned());
119-
}
120-
}
121-
}
122-
}
123-
124-
print_output(all_databases, output_format, query)?;
106+
// Use typed API to list all databases
107+
let handler = redis_cloud::CloudDatabaseHandler::new(client.clone());
108+
let databases = handler.list_all().await?;
109+
let value = serde_json::to_value(databases)?;
110+
print_output(value, output_format, query)?;
125111
}
126112
DatabaseCommands::Show { id } => {
127113
// Parse subscription_id:database_id format or just database_id

crates/redisctl/src/commands/enterprise.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,11 @@ pub async fn handle_cluster_command(
170170

171171
match command {
172172
ClusterCommands::Info => {
173-
let info = client.get_raw("/v1/cluster").await?;
174-
print_output(info, output_format, query)?;
173+
// Use typed API to get cluster info
174+
let handler = redis_enterprise::ClusterHandler::new(client.clone());
175+
let info = handler.info().await?;
176+
let value = serde_json::to_value(info)?;
177+
print_output(value, output_format, query)?;
175178
}
176179
ClusterCommands::Nodes => {
177180
let nodes = client.get_raw("/v1/nodes").await?;

0 commit comments

Comments
 (0)