]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/API2/ACL.pm
refactor API using get/register_standard_option
[pve-access-control.git] / PVE / API2 / ACL.pm
index d37771b029b425297c8d03aae310f94882582d33..3e42ac06d8a9a85131a00fc62b6a02997689203d 100644 (file)
@@ -6,6 +6,7 @@ use PVE::Cluster qw (cfs_read_file cfs_write_file);
 use PVE::Tools qw(split_list);
 use PVE::AccessControl;
 use PVE::Exception qw(raise_param_exc);
+use PVE::JSONSchema qw(get_standard_option register_standard_option);
 
 use PVE::SafeSyslog;
 
@@ -13,6 +14,17 @@ use PVE::RESTHandler;
 
 use base qw(PVE::RESTHandler);
 
+register_standard_option('acl-propagate', {
+    description => "Allow to propagate (inherit) permissions.",
+    type => 'boolean',
+    optional => 1,
+    default => 1,
+});
+register_standard_option('acl-path', {
+    description => "Access control path",
+    type => 'string',
+});
+
 __PACKAGE__->register_method ({
     name => 'read_acl',
     path => '',
@@ -32,11 +44,11 @@ __PACKAGE__->register_method ({
            type => "object",
            additionalProperties => 0,
            properties => {
-               path => { type => 'string' },
+               propagate => get_standard_option('acl-propagate'),
+               path => get_standard_option('acl-path'),
                type => { type => 'string', enum => ['user', 'group'] },
                ugid => { type => 'string' },
                roleid => { type => 'string' },
-               propagate => { type => 'boolean' },
            },
        },
     },
@@ -90,10 +102,8 @@ __PACKAGE__->register_method ({
     parameters => {
        additionalProperties => 0,
        properties => {
-           path => {
-               description => "Access control path",
-               type => 'string',
-           },
+           propagate => get_standard_option('acl-propagate'),
+           path => get_standard_option('acl-path'),
            users => {
                description => "List of users.",
                type => 'string',  format => 'pve-userid-list',
@@ -108,12 +118,6 @@ __PACKAGE__->register_method ({
                description => "List of roles.",
                type => 'string', format => 'pve-roleid-list',
            },
-           propagate => {
-               description => "Allow to propagate (inherit) permissions.",
-               type => 'boolean',
-               optional => 1,
-               default => 1,
-           },
            delete => {
                description => "Remove permissions (instead of adding it).",
                type => 'boolean',