Skip to content

Commit 0116d05

Browse files
committed
fix: resolve merge conflicts with main
- Include both JSON Schema and DNS Suffixes in SUMMARY.md
2 parents 3c7e7cd + 6df5824 commit 0116d05

File tree

8 files changed

+821
-0
lines changed

8 files changed

+821
-0
lines changed

crates/redisctl/src/cli.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,10 +1023,18 @@ pub enum EnterpriseCommands {
10231023
#[command(subcommand, name = "job-scheduler")]
10241024
JobScheduler(crate::commands::enterprise::job_scheduler::JobSchedulerCommands),
10251025

1026+
/// JSON schema operations
1027+
#[command(subcommand)]
1028+
Jsonschema(crate::commands::enterprise::jsonschema::JsonSchemaCommands),
1029+
10261030
/// Log operations
10271031
#[command(subcommand)]
10281032
Logs(crate::commands::enterprise::logs::LogsCommands),
10291033

1034+
/// Migration operations
1035+
#[command(subcommand)]
1036+
Migration(crate::commands::enterprise::migration::MigrationCommands),
1037+
10301038
/// Module management operations
10311039
#[command(subcommand)]
10321040
Module(crate::commands::enterprise::module::ModuleCommands),
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
use anyhow::Context;
2+
use clap::Subcommand;
3+
4+
use crate::{cli::OutputFormat, connection::ConnectionManager, error::Result as CliResult};
5+
6+
#[allow(dead_code)]
7+
pub async fn handle_jsonschema_command(
8+
conn_mgr: &ConnectionManager,
9+
profile_name: Option<&str>,
10+
jsonschema_cmd: JsonSchemaCommands,
11+
output_format: OutputFormat,
12+
query: Option<&str>,
13+
) -> CliResult<()> {
14+
jsonschema_cmd
15+
.execute(conn_mgr, profile_name, output_format, query)
16+
.await
17+
}
18+
19+
#[derive(Debug, Clone, Subcommand)]
20+
pub enum JsonSchemaCommands {
21+
/// Get JSON schema for API validation
22+
Get,
23+
}
24+
25+
impl JsonSchemaCommands {
26+
#[allow(dead_code)]
27+
pub async fn execute(
28+
&self,
29+
conn_mgr: &ConnectionManager,
30+
profile_name: Option<&str>,
31+
output_format: OutputFormat,
32+
query: Option<&str>,
33+
) -> CliResult<()> {
34+
handle_jsonschema_command_impl(conn_mgr, profile_name, self, output_format, query).await
35+
}
36+
}
37+
38+
#[allow(dead_code)]
39+
async fn handle_jsonschema_command_impl(
40+
conn_mgr: &ConnectionManager,
41+
profile_name: Option<&str>,
42+
command: &JsonSchemaCommands,
43+
output_format: OutputFormat,
44+
query: Option<&str>,
45+
) -> CliResult<()> {
46+
let client = conn_mgr.create_enterprise_client(profile_name).await?;
47+
48+
match command {
49+
JsonSchemaCommands::Get => {
50+
let response: serde_json::Value = client
51+
.get("/v1/jsonschema")
52+
.await
53+
.context("Failed to get JSON schema")?;
54+
55+
let output_data = if let Some(q) = query {
56+
super::utils::apply_jmespath(&response, q)?
57+
} else {
58+
response
59+
};
60+
61+
super::utils::print_formatted_output(output_data, output_format)?;
62+
}
63+
}
64+
65+
Ok(())
66+
}
67+
68+
#[cfg(test)]
69+
mod tests {
70+
use super::*;
71+
72+
#[test]
73+
fn test_jsonschema_command_parsing() {
74+
use clap::Parser;
75+
76+
#[derive(Parser)]
77+
struct TestCli {
78+
#[command(subcommand)]
79+
cmd: JsonSchemaCommands,
80+
}
81+
82+
// Test get command
83+
let cli = TestCli::parse_from(["test", "get"]);
84+
assert!(matches!(cli.cmd, JsonSchemaCommands::Get));
85+
}
86+
}
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
use anyhow::Context;
2+
use clap::Subcommand;
3+
4+
use crate::{cli::OutputFormat, connection::ConnectionManager, error::Result as CliResult};
5+
6+
#[allow(dead_code)]
7+
pub async fn handle_migration_command(
8+
conn_mgr: &ConnectionManager,
9+
profile_name: Option<&str>,
10+
migration_cmd: MigrationCommands,
11+
output_format: OutputFormat,
12+
query: Option<&str>,
13+
) -> CliResult<()> {
14+
migration_cmd
15+
.execute(conn_mgr, profile_name, output_format, query)
16+
.await
17+
}
18+
19+
#[derive(Debug, Clone, Subcommand)]
20+
pub enum MigrationCommands {
21+
/// Get migration status
22+
Get {
23+
/// Migration UID
24+
uid: u64,
25+
},
26+
27+
/// Export database data
28+
Export {
29+
/// Database UID
30+
bdb_uid: u64,
31+
},
32+
33+
/// Import database data
34+
Import {
35+
/// Database UID
36+
bdb_uid: u64,
37+
/// Import data (use @filename or - for stdin)
38+
#[arg(short, long)]
39+
data: String,
40+
},
41+
}
42+
43+
impl MigrationCommands {
44+
#[allow(dead_code)]
45+
pub async fn execute(
46+
&self,
47+
conn_mgr: &ConnectionManager,
48+
profile_name: Option<&str>,
49+
output_format: OutputFormat,
50+
query: Option<&str>,
51+
) -> CliResult<()> {
52+
handle_migration_command_impl(conn_mgr, profile_name, self, output_format, query).await
53+
}
54+
}
55+
56+
#[allow(dead_code)]
57+
async fn handle_migration_command_impl(
58+
conn_mgr: &ConnectionManager,
59+
profile_name: Option<&str>,
60+
command: &MigrationCommands,
61+
output_format: OutputFormat,
62+
query: Option<&str>,
63+
) -> CliResult<()> {
64+
let client = conn_mgr.create_enterprise_client(profile_name).await?;
65+
66+
match command {
67+
MigrationCommands::Get { uid } => {
68+
let response: serde_json::Value = client
69+
.get(&format!("/v1/migrations/{}", uid))
70+
.await
71+
.context(format!("Failed to get migration {}", uid))?;
72+
73+
let output_data = if let Some(q) = query {
74+
super::utils::apply_jmespath(&response, q)?
75+
} else {
76+
response
77+
};
78+
79+
super::utils::print_formatted_output(output_data, output_format)?;
80+
}
81+
MigrationCommands::Export { bdb_uid } => {
82+
let response: serde_json::Value = client
83+
.post(
84+
&format!("/v1/bdbs/{}/actions/export", bdb_uid),
85+
&serde_json::json!({}),
86+
)
87+
.await
88+
.context(format!("Failed to export database {}", bdb_uid))?;
89+
90+
let output_data = if let Some(q) = query {
91+
super::utils::apply_jmespath(&response, q)?
92+
} else {
93+
response
94+
};
95+
96+
super::utils::print_formatted_output(output_data, output_format)?;
97+
}
98+
MigrationCommands::Import { bdb_uid, data } => {
99+
let payload = super::utils::read_json_data(data)?;
100+
101+
let response: serde_json::Value = client
102+
.post(&format!("/v1/bdbs/{}/actions/import", bdb_uid), &payload)
103+
.await
104+
.context(format!("Failed to import data to database {}", bdb_uid))?;
105+
106+
let output_data = if let Some(q) = query {
107+
super::utils::apply_jmespath(&response, q)?
108+
} else {
109+
response
110+
};
111+
112+
super::utils::print_formatted_output(output_data, output_format)?;
113+
}
114+
}
115+
116+
Ok(())
117+
}
118+
119+
#[cfg(test)]
120+
mod tests {
121+
use super::*;
122+
123+
#[test]
124+
fn test_migration_command_parsing() {
125+
use clap::Parser;
126+
127+
#[derive(Parser)]
128+
struct TestCli {
129+
#[command(subcommand)]
130+
cmd: MigrationCommands,
131+
}
132+
133+
// Test get command
134+
let cli = TestCli::parse_from(["test", "get", "1"]);
135+
if let MigrationCommands::Get { uid } = cli.cmd {
136+
assert_eq!(uid, 1);
137+
} else {
138+
panic!("Expected Get command");
139+
}
140+
141+
// Test export command
142+
let cli = TestCli::parse_from(["test", "export", "2"]);
143+
if let MigrationCommands::Export { bdb_uid } = cli.cmd {
144+
assert_eq!(bdb_uid, 2);
145+
} else {
146+
panic!("Expected Export command");
147+
}
148+
149+
// Test import command
150+
let cli = TestCli::parse_from(["test", "import", "3", "--data", "@import.json"]);
151+
if let MigrationCommands::Import { bdb_uid, data } = cli.cmd {
152+
assert_eq!(bdb_uid, 3);
153+
assert_eq!(data, "@import.json");
154+
} else {
155+
panic!("Expected Import command");
156+
}
157+
}
158+
}

crates/redisctl/src/commands/enterprise/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ pub mod database_impl;
1313
pub mod diagnostics;
1414
pub mod endpoint;
1515
pub mod job_scheduler;
16+
pub mod jsonschema;
1617
pub mod logs;
1718
pub mod logs_impl;
19+
pub mod migration;
1820
pub mod module;
1921
pub mod module_impl;
2022
pub mod node;

crates/redisctl/src/main.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,32 @@ async fn execute_enterprise_command(
324324
)
325325
.await
326326
}
327+
Jsonschema(jsonschema_cmd) => {
328+
commands::enterprise::jsonschema::handle_jsonschema_command(
329+
conn_mgr,
330+
profile,
331+
jsonschema_cmd.clone(),
332+
output,
333+
query,
334+
)
335+
.await
336+
}
327337
Logs(logs_cmd) => {
328338
commands::enterprise::logs_impl::handle_logs_commands(
329339
conn_mgr, profile, logs_cmd, output, query,
330340
)
331341
.await
332342
}
343+
Migration(migration_cmd) => {
344+
commands::enterprise::migration::handle_migration_command(
345+
conn_mgr,
346+
profile,
347+
migration_cmd.clone(),
348+
output,
349+
query,
350+
)
351+
.await
352+
}
333353
Module(module_cmd) => {
334354
commands::enterprise::module_impl::handle_module_commands(
335355
conn_mgr, profile, module_cmd, output, query,

docs/src/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@
3939
- [Usage Reports](./enterprise/usage-report.md)
4040
- [Modules](./enterprise/modules.md)
4141
- [Logs](./enterprise/logs.md)
42+
- [Database Migration](./enterprise/migration.md)
4243
- [Active-Active (CRDB)](./enterprise/crdb.md)
4344
- [CRDB Tasks](./enterprise/crdb-tasks.md)
4445
- [Actions (Tasks)](./enterprise/actions.md)
4546
- [Diagnostics](./enterprise/diagnostics.md)
4647
- [Endpoints](./enterprise/endpoints.md)
4748
- [Job Scheduler](./enterprise/job-scheduler.md)
49+
- [JSON Schema](./enterprise/jsonschema.md)
4850
- [DNS Suffixes](./enterprise/suffix.md)
4951
- [Workflows](./enterprise/workflows.md)
5052
- [Raw API Access](./enterprise/api-access.md)

0 commit comments

Comments
 (0)