X-Git-Url: https://git.proxmox.com/?p=pve-firewall.git;a=blobdiff_plain;f=src%2FPVE%2FAPI2%2FFirewall%2FCluster.pm;h=028600cf4174b62e737df8655c6e9c92115aa9ce;hp=5923aa84bd219f33f220a7ba820d6b3b940b5785;hb=ebd54ae918365a722c1091109e74ec21ca7f4be6;hpb=5b7974dfa29048836d6ca5f66a05c96e54732cbf diff --git a/src/PVE/API2/Firewall/Cluster.pm b/src/PVE/API2/Firewall/Cluster.pm index 5923aa8..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; @@ -138,3 +139,43 @@ __PACKAGE__->register_method({ 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;