use PVE::JSONSchema qw(get_standard_option);
use PVE::Firewall;
+use PVE::API2::Firewall::Rules;
use PVE::API2::Firewall::Groups;
#fixme: locking?
path => 'groups',
});
+__PACKAGE__->register_method ({
+ subclass => "PVE::API2::Firewall::ClusterRules",
+ path => 'rules',
+});
+
__PACKAGE__->register_method({
name => 'index',
path => '',
{ name => 'options' },
{ name => 'groups' },
{ name => 'netgroups' },
+ { name => 'macros' },
];
return $result;
path => 'options',
method => 'PUT',
description => "Set Firewall options.",
+ protected => 1,
parameters => {
additionalProperties => 0,
properties => &$add_option_properties({
$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;