]> git.proxmox.com Git - pve-firewall.git/blobdiff - src/PVE/API2/Firewall/Host.pm
implement rules API for host.fw
[pve-firewall.git] / src / PVE / API2 / Firewall / Host.pm
index e82604e2313c332a40bc475140075ee1d4c65724..0ebdcceb494baa4688254b6abf82c883ade25a4e 100644 (file)
@@ -5,12 +5,17 @@ use warnings;
 use PVE::JSONSchema qw(get_standard_option);
 
 use PVE::Firewall;
-
+use PVE::API2::Firewall::Rules;
 
 use Data::Dumper; # fixme: remove
 
 use base qw(PVE::RESTHandler);
 
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Firewall::HostRules",  
+    path => 'rules',
+});
+
 __PACKAGE__->register_method({
     name => 'index',
     path => '',
@@ -42,44 +47,6 @@ __PACKAGE__->register_method({
        return $result;
     }});
 
-__PACKAGE__->register_method({
-    name => 'get_rules',
-    path => 'rules',
-    method => 'GET',
-    description => "List host firewall rules.",
-    proxyto => 'node',
-    parameters => {
-       additionalProperties => 0,
-       properties => {
-           node => get_standard_option('pve-node'),
-       },
-    },
-    returns => {
-       type => 'array',
-       items => {
-           type => "object",
-           properties => {},
-       },
-    },
-    code => sub {
-       my ($param) = @_;
-
-       my $hostfw_conf = PVE::Firewall::load_hostfw_conf();
-
-       my $rules = $hostfw_conf->{rules} || [];
-
-       my $digest = $hostfw_conf->{digest};
-
-       my $res = [];
-
-       my $ind = 0;
-       foreach my $rule (@$rules) {
-           push @$res, PVE::Firewall::cleanup_fw_rule($rule, $digest, $ind++);
-       }
-
-       return $res;
-    }});
-
 __PACKAGE__->register_method({
     name => 'get_options',
     path => 'options',