diff --git a/Cargo.lock b/Cargo.lock
index 25f065c..565207a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1071,7 +1071,6 @@ dependencies = [
[[package]]
name = "rabbitmq_http_client"
version = "0.9.0"
-source = "git+https://github.com/michaelklishin/rabbitmq-http-api-rs#9e3c4b386f4c5f83b78ed5f7bb509349d7804222"
dependencies = [
"percent-encoding",
"rand",
diff --git a/Cargo.toml b/Cargo.toml
index 5623ad7..18ca07b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,7 +8,8 @@ clap = { version = "4.5", features = ["derive", "help", "color", "cargo"] }
url = "2"
thiserror = "1"
sysexits = "0.8.1"
-rabbitmq_http_client = { git = "https://github.com/michaelklishin/rabbitmq-http-api-rs", features = ["core", "tabled"] }
+# rabbitmq_http_client = { git = "https://github.com/michaelklishin/rabbitmq-http-api-rs", features = ["core", "tabled"] }
+rabbitmq_http_client = { path = "/Users/antares/Development/RabbitMQ/rabbitmq-http-api-client-rs.git", features = ["core", "tabled"] }
serde = { version = "1.0", features = ["derive", "std"] }
serde_json = "1"
tabled = "0.16"
diff --git a/src/cli.rs b/src/cli.rs
index c6e8bb1..a8e119b 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -861,7 +861,7 @@ fn close_subcommands() -> [Command; 1] {
)]
}
-fn definitions_subcommands() -> [Command; 2] {
+fn definitions_subcommands() -> [Command; 3] {
let export_cmd = Command::new("export")
.about("export all definitions (queues, exchanges, bindings, users, etc)")
.after_long_help(color_print::cstr!(
@@ -885,7 +885,21 @@ fn definitions_subcommands() -> [Command; 2] {
.help("JSON file with definitions")
.required(true));
- [export_cmd, import_cmd]
+ let transform_cmd = Command::new("transform")
+ .about("exports and transforms (post-processes) definitions")
+ .after_long_help(color_print::cstr!(
+ "Doc guide: https://rabbitmq.com/docs/definitions/"
+ )).arg(
+ Arg::new("file")
+ .long("file")
+ .help("JSON file with definitions")
+ .required(true))
+ .arg(Arg::new("transformations")
+ .required(true)
+ .long("transformations")
+ .help("command-separated names of transformations to apply"));
+
+ [export_cmd, import_cmd, transform_cmd]
}
fn export_subcommands() -> [Command; 1] {
diff --git a/src/commands.rs b/src/commands.rs
index 918ae2a..f4193b1 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -5,6 +5,8 @@ use rabbitmq_http_client::commons::VirtualHostLimitTarget;
use std::fs;
use std::process;
+use serde_json::json;
+
use rabbitmq_http_client::blocking::Client as APIClient;
use rabbitmq_http_client::blocking::Result as ClientResult;
use rabbitmq_http_client::requests::EnforcedLimitParams;
@@ -543,6 +545,17 @@ pub fn import_definitions(client: APIClient, command_args: &ArgMatches) -> Clien
}
}
+pub fn transform_definitions(client: APIClient, command_args: &ArgMatches) -> ClientResult<()> {
+ let transformation_names = command_args.get_one::("transformations").unwrap();
+ match client.export_definitions_as_data() {
+ Ok(definitions) => {
+ println!("Definitions: {:?}", json!(definitions));
+ Ok(())
+ }
+ Err(err) => Err(err),
+ }
+}
+
pub fn publish_message(
client: APIClient,
vhost: &str,
diff --git a/src/main.rs b/src/main.rs
index 50af552..d31d177 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,6 +11,7 @@ use tabled::{Table, Tabled};
mod cli;
mod commands;
mod constants;
+mod transformations;
use crate::cli::SharedFlags;
use crate::constants::DEFAULT_VHOST;
@@ -229,6 +230,10 @@ fn main() {
let result = commands::import_definitions(client, command_args);
print_nothing_or_fail(result);
}
+ ("definitions", "transform") => {
+ let result = commands::transform_definitions(client, command_args);
+ print_nothing_or_fail(result);
+ }
("export", "definitions") => {
let result = commands::export_definitions(client, command_args);
print_nothing_or_fail(result);
diff --git a/src/transformations.rs b/src/transformations.rs
new file mode 100644
index 0000000..76ac076
--- /dev/null
+++ b/src/transformations.rs
@@ -0,0 +1,20 @@
+use rabbitmq_http_client::blocking::Error;
+use rabbitmq_http_client::responses::DefinitionSet;
+
+pub type Result = std::result::Result;
+
+
+
+pub trait Tranformation {
+ fn transform(&self: Self, &defs: &mut DefinitionSet) -> Result<&DefinitionSet>;
+}
+
+pub struct RemoveClassicQueueMirroringTransformation<'a> {
+ pub definition_set: &'a DefinitionSet
+}
+
+impl Tranformation for RemoveClassicQueueMirroringTransformation {
+ fn transform(defs: &mut DefinitionSet) -> Result<&DefinitionSet> {
+ todo!()
+ }
+}
\ No newline at end of file