prefix ipset chains with PVEFW-
[pve-firewall.git] / src / PVE / API2 / Firewall / Host.pm
CommitLineData
8b27beb9
DM
1package PVE::API2::Firewall::Host;
2
3use strict;
4use warnings;
5use PVE::JSONSchema qw(get_standard_option);
6
7use PVE::Firewall;
63c91681 8use PVE::API2::Firewall::Rules;
8b27beb9
DM
9
10use Data::Dumper; # fixme: remove
11
12use base qw(PVE::RESTHandler);
13
63c91681
DM
14__PACKAGE__->register_method ({
15 subclass => "PVE::API2::Firewall::HostRules",
16 path => 'rules',
17});
18
8b27beb9
DM
19__PACKAGE__->register_method({
20 name => 'index',
21 path => '',
22 method => 'GET',
23 permissions => { user => 'all' },
24 description => "Directory index.",
25 parameters => {
26 additionalProperties => 0,
27 properties => {
28 node => get_standard_option('pve-node'),
29 },
30 },
31 returns => {
32 type => 'array',
33 items => {
34 type => "object",
35 properties => {},
36 },
37 links => [ { rel => 'child', href => "{name}" } ],
38 },
39 code => sub {
40 my ($param) = @_;
41
42 my $result = [
43 { name => 'rules' },
44 { name => 'options' },
45 ];
46
47 return $result;
48 }});
49
8b27beb9
DM
50__PACKAGE__->register_method({
51 name => 'get_options',
52 path => 'options',
53 method => 'GET',
54 description => "Get host firewall options.",
55 proxyto => 'node',
56 parameters => {
57 additionalProperties => 0,
58 properties => {
59 node => get_standard_option('pve-node'),
60 },
61 },
62 returns => {
63 type => "object",
64 properties => {},
65 },
66 code => sub {
67 my ($param) = @_;
68
69 my $hostfw_conf = PVE::Firewall::load_hostfw_conf();
70
71 my $options = $hostfw_conf->{options} || {};
72
73 my $digest = $hostfw_conf->{digest};
74
75 $options->{digest} = $digest;
76
77 return $options;
78 }});
79
801;