[pmg-devel] [PATCH pmg-api 1/3] user white/blacklist: allow multiple entries for adding/deleting
Dominik Csapak
d.csapak at proxmox.com
Tue Feb 26 09:12:34 CET 2019
and reallow globs (like previously) like *.com
entries are seperated by ','
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PMG/API2/Quarantine.pm | 20 ++++++++++++--------
PMG/Utils.pm | 7 +++++++
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/PMG/API2/Quarantine.pm b/PMG/API2/Quarantine.pm
index 8937241..3572c41 100644
--- a/PMG/API2/Quarantine.pm
+++ b/PMG/API2/Quarantine.pm
@@ -253,7 +253,7 @@ __PACKAGE__->register_method ({
additionalProperties => 0,
properties => {
pmail => $pmail_param_type,
- address => get_standard_option('pmg-email-address', {
+ address => get_standard_option('pmg-whiteblacklist-entry-list', {
description => "The address you want to add.",
}),
},
@@ -262,7 +262,8 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
- $read_or_modify_user_bw_list->('WL', $param, [ $param->{address} ]);
+ my $addresses = [split(',', $param->{address})];
+ $read_or_modify_user_bw_list->('WL', $param, $addresses);
return undef;
}});
@@ -278,7 +279,7 @@ __PACKAGE__->register_method ({
additionalProperties => 0,
properties => {
pmail => $pmail_param_type,
- address => get_standard_option('pmg-email-address', {
+ address => get_standard_option('pmg-whiteblacklist-entry-list', {
description => "The address you want to remove.",
}),
},
@@ -287,7 +288,8 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
- $read_or_modify_user_bw_list->('WL', $param, [ $param->{address} ], 1);
+ my $addresses = [split(',', $param->{address})];
+ $read_or_modify_user_bw_list->('WL', $param, $addresses, 1);
return undef;
}});
@@ -332,7 +334,7 @@ __PACKAGE__->register_method ({
additionalProperties => 0,
properties => {
pmail => $pmail_param_type,
- address => get_standard_option('pmg-email-address', {
+ address => get_standard_option('pmg-whiteblacklist-entry-list', {
description => "The address you want to add.",
}),
},
@@ -341,7 +343,8 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
- $read_or_modify_user_bw_list->('BL', $param, [ $param->{address} ]);
+ my $addresses = [split(',', $param->{address})];
+ $read_or_modify_user_bw_list->('BL', $param, $addresses);
return undef;
}});
@@ -357,7 +360,7 @@ __PACKAGE__->register_method ({
additionalProperties => 0,
properties => {
pmail => $pmail_param_type,
- address => get_standard_option('pmg-email-address', {
+ address => get_standard_option('pmg-whiteblacklist-entry-list', {
description => "The address you want to remove.",
}),
},
@@ -366,7 +369,8 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
- $read_or_modify_user_bw_list->('BL', $param, [ $param->{address} ], 1);
+ my $addresses = [split(',', $param->{address})];
+ $read_or_modify_user_bw_list->('BL', $param, $addresses, 1);
return undef;
}});
diff --git a/PMG/Utils.pm b/PMG/Utils.pm
index 60fdc5e..6847054 100644
--- a/PMG/Utils.pm
+++ b/PMG/Utils.pm
@@ -113,6 +113,13 @@ PVE::JSONSchema::register_standard_option('pmg-email-address', {
minLength => 3,
});
+PVE::JSONSchema::register_standard_option('pmg-whiteblacklist-entry-list', {
+ description => "White/Blacklist entry list (allow most characters). Can contain globs",
+ type => 'string',
+ pattern => '(?:[^\s\/\\\;\,]+)(?:\,[^\s\/\\\;\,]+)*',
+ minLength => 3,
+});
+
sub lastid {
my ($dbh, $seq) = @_;
--
2.11.0
More information about the pmg-devel
mailing list