config/tape_job: add notify-user config to tape jobs

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-03-05 09:45:30 +01:00 committed by Dietmar Maurer
parent 0b90c67fb4
commit 9152a0077f
2 changed files with 18 additions and 0 deletions

View File

@ -8,6 +8,7 @@ use proxmox::tools::fs::open_file_locked;
use crate::{ use crate::{
api2::types::{ api2::types::{
Authid, Authid,
Userid,
JOB_ID_SCHEMA, JOB_ID_SCHEMA,
DATASTORE_SCHEMA, DATASTORE_SCHEMA,
DRIVE_NAME_SCHEMA, DRIVE_NAME_SCHEMA,
@ -149,6 +150,8 @@ pub enum DeletableProperty {
ExportMediaSet, ExportMediaSet,
/// Delete the 'latest-only' property /// Delete the 'latest-only' property
LatestOnly, LatestOnly,
/// Delete the 'notify-user' property
NotifyUser,
} }
#[api( #[api(
@ -185,6 +188,10 @@ pub enum DeletableProperty {
type: bool, type: bool,
optional: true, optional: true,
}, },
"notify-user": {
optional: true,
type: Userid,
},
comment: { comment: {
optional: true, optional: true,
schema: SINGLE_LINE_COMMENT_SCHEMA, schema: SINGLE_LINE_COMMENT_SCHEMA,
@ -220,6 +227,7 @@ pub fn update_tape_backup_job(
eject_media: Option<bool>, eject_media: Option<bool>,
export_media_set: Option<bool>, export_media_set: Option<bool>,
latest_only: Option<bool>, latest_only: Option<bool>,
notify_user: Option<Userid>,
comment: Option<String>, comment: Option<String>,
schedule: Option<String>, schedule: Option<String>,
delete: Option<Vec<DeletableProperty>>, delete: Option<Vec<DeletableProperty>>,
@ -242,6 +250,7 @@ pub fn update_tape_backup_job(
DeletableProperty::EjectMedia => { data.setup.eject_media = None; }, DeletableProperty::EjectMedia => { data.setup.eject_media = None; },
DeletableProperty::ExportMediaSet => { data.setup.export_media_set = None; }, DeletableProperty::ExportMediaSet => { data.setup.export_media_set = None; },
DeletableProperty::LatestOnly => { data.setup.latest_only = None; }, DeletableProperty::LatestOnly => { data.setup.latest_only = None; },
DeletableProperty::NotifyUser => { data.setup.notify_user = None; },
DeletableProperty::Schedule => { data.schedule = None; }, DeletableProperty::Schedule => { data.schedule = None; },
DeletableProperty::Comment => { data.comment = None; }, DeletableProperty::Comment => { data.comment = None; },
} }
@ -255,6 +264,7 @@ pub fn update_tape_backup_job(
if eject_media.is_some() { data.setup.eject_media = eject_media; }; if eject_media.is_some() { data.setup.eject_media = eject_media; };
if export_media_set.is_some() { data.setup.export_media_set = export_media_set; } if export_media_set.is_some() { data.setup.export_media_set = export_media_set; }
if latest_only.is_some() { data.setup.latest_only = latest_only; } if latest_only.is_some() { data.setup.latest_only = latest_only; }
if notify_user.is_some() { data.setup.notify_user = notify_user; }
if schedule.is_some() { data.schedule = schedule; } if schedule.is_some() { data.schedule = schedule; }

View File

@ -16,6 +16,7 @@ use proxmox::api::{
use proxmox::tools::{fs::replace_file, fs::CreateOptions}; use proxmox::tools::{fs::replace_file, fs::CreateOptions};
use crate::api2::types::{ use crate::api2::types::{
Userid,
JOB_ID_SCHEMA, JOB_ID_SCHEMA,
DATASTORE_SCHEMA, DATASTORE_SCHEMA,
DRIVE_NAME_SCHEMA, DRIVE_NAME_SCHEMA,
@ -55,6 +56,10 @@ lazy_static! {
type: bool, type: bool,
optional: true, optional: true,
}, },
"notify-user": {
optional: true,
type: Userid,
},
} }
)] )]
#[serde(rename_all="kebab-case")] #[serde(rename_all="kebab-case")]
@ -70,6 +75,9 @@ pub struct TapeBackupJobSetup {
pub export_media_set: Option<bool>, pub export_media_set: Option<bool>,
#[serde(skip_serializing_if="Option::is_none")] #[serde(skip_serializing_if="Option::is_none")]
pub latest_only: Option<bool>, pub latest_only: Option<bool>,
/// Send job email notification to this user
#[serde(skip_serializing_if="Option::is_none")]
pub notify_user: Option<Userid>,
} }
#[api( #[api(