proxmox-backup-manager: add CLI for notification targets
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com> Tested-by: Gabriel Goller <g.goller@proxmox.com> Reviewed-by: Gabriel Goller <g.goller@proxmox.com> Tested-by: Maximiliano Sandoval <m.sandoval@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
ce15b51507
commit
e60e050a1b
@ -17,11 +17,11 @@ use crate::api2::config::datastore::list_datastores;
|
||||
use crate::api2::config::media_pool::list_pools;
|
||||
use crate::api2::tape::backup::list_tape_backup_jobs;
|
||||
|
||||
mod gotify;
|
||||
mod matchers;
|
||||
mod sendmail;
|
||||
mod smtp;
|
||||
mod targets;
|
||||
pub mod gotify;
|
||||
pub mod matchers;
|
||||
pub mod sendmail;
|
||||
pub mod smtp;
|
||||
pub mod targets;
|
||||
|
||||
#[sortable]
|
||||
const SUBDIRS: SubdirMap = &sorted!([
|
||||
|
@ -492,6 +492,7 @@ async fn get_versions(verbose: bool, param: Value) -> Result<Value, Error> {
|
||||
|
||||
async fn run() -> Result<(), Error> {
|
||||
init_cli_logger("PBS_LOG", "info");
|
||||
proxmox_backup::server::notifications::init()?;
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("acl", acl_commands())
|
||||
@ -501,6 +502,7 @@ async fn run() -> Result<(), Error> {
|
||||
.insert("ldap", ldap_commands())
|
||||
.insert("network", network_commands())
|
||||
.insert("node", node_commands())
|
||||
.insert("notification", notification_commands())
|
||||
.insert("user", user_commands())
|
||||
.insert("openid", openid_commands())
|
||||
.insert("remote", remote_commands())
|
||||
|
@ -28,6 +28,8 @@ mod disk;
|
||||
pub use disk::*;
|
||||
mod node;
|
||||
pub use node::*;
|
||||
mod notifications;
|
||||
pub use notifications::*;
|
||||
mod openid;
|
||||
pub use openid::*;
|
||||
mod traffic_control;
|
||||
|
9
src/bin/proxmox_backup_manager/notifications/mod.rs
Normal file
9
src/bin/proxmox_backup_manager/notifications/mod.rs
Normal file
@ -0,0 +1,9 @@
|
||||
use proxmox_router::cli::{CliCommandMap, CommandLineInterface};
|
||||
|
||||
mod targets;
|
||||
|
||||
pub fn notification_commands() -> CommandLineInterface {
|
||||
let cmd_def = CliCommandMap::new().insert("target", targets::commands());
|
||||
|
||||
cmd_def.into()
|
||||
}
|
51
src/bin/proxmox_backup_manager/notifications/targets.rs
Normal file
51
src/bin/proxmox_backup_manager/notifications/targets.rs
Normal file
@ -0,0 +1,51 @@
|
||||
use anyhow::Error;
|
||||
use serde_json::Value;
|
||||
|
||||
use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
|
||||
use proxmox_schema::api;
|
||||
|
||||
use proxmox_backup::api2;
|
||||
|
||||
#[api(
|
||||
input: {
|
||||
properties: {
|
||||
"output-format": {
|
||||
schema: OUTPUT_FORMAT,
|
||||
optional: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
)]
|
||||
/// List targets.
|
||||
fn list_targets(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result<Value, Error> {
|
||||
let output_format = get_output_format(¶m);
|
||||
|
||||
let info = &api2::config::notifications::targets::API_METHOD_LIST_TARGETS;
|
||||
let mut data = match info.handler {
|
||||
ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let options = default_table_format_options()
|
||||
.column(ColumnConfig::new("disable"))
|
||||
.column(ColumnConfig::new("name"))
|
||||
.column(ColumnConfig::new("type"))
|
||||
.column(ColumnConfig::new("origin"))
|
||||
.column(ColumnConfig::new("comment"));
|
||||
|
||||
format_and_print_result_full(&mut data, &info.returns, &output_format, &options);
|
||||
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
pub fn commands() -> CommandLineInterface {
|
||||
let cmd_def = CliCommandMap::new()
|
||||
.insert("list", CliCommand::new(&API_METHOD_LIST_TARGETS))
|
||||
.insert(
|
||||
"test",
|
||||
CliCommand::new(&api2::config::notifications::targets::API_METHOD_TEST_TARGET)
|
||||
.arg_param(&["name"]),
|
||||
);
|
||||
|
||||
cmd_def.into()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user