mod add_write_perm_sub_command;
mod delete_kv_config_sub_command;
mod get_namesrv_config_sub_command;
mod update_kv_config_sub_command;
mod update_namesrv_config_sub_command;
mod wipe_write_perm_sub_command;
use clap::Subcommand;
use rocketmq_error::Result as CanonicalResult;
use crate::commands::CommandExecute;
use crate::commands::namesrv::add_write_perm_sub_command::AddWritePermSubCommand;
use crate::commands::namesrv::delete_kv_config_sub_command::DeleteKvConfigSubCommand;
use crate::commands::namesrv::get_namesrv_config_sub_command::GetNamesrvConfigSubCommand;
use crate::commands::namesrv::update_kv_config_sub_command::UpdateKvConfigSubCommand;
use crate::commands::namesrv::update_namesrv_config_sub_command::UpdateNamesrvConfigSubCommand;
use crate::commands::namesrv::wipe_write_perm_sub_command::WipeWritePermSubCommand;
#[derive(Subcommand)]
pub enum NameServerCommands {
#[command(
name = "addWritePerm",
about = "Add write perm of broker in all name server you defined in the -n param.",
long_about = None,
)]
AddWritePerm(AddWritePermSubCommand),
#[command(
name = "deleteKvConfig",
about = "Delete KV config.",
long_about = None,
)]
DeleteKvConfig(DeleteKvConfigSubCommand),
#[command(
name = "getNamesrvConfig",
about = "Get configs of name server.",
long_about = None,
)]
GetNamesrvConfig(GetNamesrvConfigSubCommand),
#[command(
name = "updateKvConfig",
about = "Create or update KV config.",
long_about = None,
)]
UpdateKvConfig(UpdateKvConfigSubCommand),
#[command(
name = "updateNamesrvConfig",
about = "Update configs of name server.",
long_about = None,
)]
UpdateNamesrvConfig(UpdateNamesrvConfigSubCommand),
#[command(
name = "wipeWritePerm",
about = "Wipe write perm of broker in all name server you defined in the -n param.",
long_about = None,
)]
WipeWritePerm(WipeWritePermSubCommand),
}
impl CommandExecute for NameServerCommands {
async fn execute(
&self,
credentials: Option<rocketmq_admin_core::core::security::AdminCredentials>,
client_runtime: std::sync::Arc<rocketmq_admin_core::client_adapter::ClientRuntime>,
) -> CanonicalResult<()> {
match self {
NameServerCommands::AddWritePerm(value) => value.execute(credentials, client_runtime.clone()).await,
NameServerCommands::DeleteKvConfig(value) => value.execute(credentials, client_runtime.clone()).await,
NameServerCommands::GetNamesrvConfig(value) => value.execute(credentials, client_runtime.clone()).await,
NameServerCommands::UpdateKvConfig(value) => value.execute(credentials, client_runtime.clone()).await,
NameServerCommands::UpdateNamesrvConfig(value) => value.execute(credentials, client_runtime.clone()).await,
NameServerCommands::WipeWritePerm(value) => value.execute(credentials, client_runtime.clone()).await,
}
}
}