common: notify: add bindings for get_targets

This allows us to drop the impl of that function on the perl side.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-By: Stefan Hanreich <s.hanreich@proxmox.com>
This commit is contained in:
Lukas Wagner 2024-11-08 15:41:15 +01:00 committed by Thomas Lamprecht
parent 7747ac46de
commit 21886bb2ac

View File

@ -27,6 +27,7 @@ mod export {
MatcherConfigUpdater, SeverityMatcher,
};
use proxmox_notify::{api, Config, Notification, Severity};
use proxmox_notify::api::Target;
pub struct NotificationConfig {
config: Mutex<Config>,
@ -112,6 +113,14 @@ mod export {
api::common::send(&config, &notification)
}
#[export(serialize_error)]
fn get_targets(
#[try_from_ref] this: &NotificationConfig,
) -> Result<Vec<Target>, HttpError> {
let config = this.config.lock().unwrap();
api::get_targets(&config)
}
#[export(serialize_error)]
fn test_target(
#[try_from_ref] this: &NotificationConfig,