X-Git-Url: https://git.proxmox.com/?p=pve-firewall.git;a=blobdiff_plain;f=src%2FPVE%2FAPI2%2FFirewall%2FCluster.pm;h=028600cf4174b62e737df8655c6e9c92115aa9ce;hp=d7146f39970ecee89c5958f73b7bc58255d84978;hb=ebd54ae918365a722c1091109e74ec21ca7f4be6;hpb=8679128955c3dde0e3dbc61027b1f2d88e02e243 diff --git a/src/PVE/API2/Firewall/Cluster.pm b/src/PVE/API2/Firewall/Cluster.pm index d7146f3..028600c 100644 --- a/src/PVE/API2/Firewall/Cluster.pm +++ b/src/PVE/API2/Firewall/Cluster.pm @@ -50,6 +50,7 @@ __PACKAGE__->register_method({ { name => 'options' }, { name => 'groups' }, { name => 'netgroups' }, + { name => 'macros' }, ]; return $result; @@ -105,6 +106,7 @@ __PACKAGE__->register_method({ path => 'options', method => 'PUT', description => "Set Firewall options.", + protected => 1, parameters => { additionalProperties => 0, properties => &$add_option_properties({ @@ -133,8 +135,47 @@ __PACKAGE__->register_method({ $cluster_conf->{options}->{enable} = $param->{enable} ? 1 : 0; } - PVE::Firewall::save_clusterfw_conf($cluster_conf); return undef; }}); + +__PACKAGE__->register_method({ + name => 'get_macros', + path => 'macros', + method => 'GET', + description => "List available macros", + parameters => { + additionalProperties => 0, + }, + returns => { + type => 'array', + items => { + type => "object", + properties => { + macro => { + description => "Macro name.", + type => 'string', + }, + descr => { + description => "More verbose description (if available).", + type => 'string', + } + }, + }, + }, + code => sub { + my ($param) = @_; + + my $res = []; + + my ($macros, $descr) = PVE::Firewall::get_macros(); + + foreach my $macro (keys %$macros) { + push @$res, { macro => $macro, descr => $descr->{$macro} || $macro }; + } + + return $res; + }}); + +1;