]>
Commit | Line | Data |
---|---|---|
8b27beb9 DM |
1 | package PVE::API2::Firewall::Host; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | use PVE::JSONSchema qw(get_standard_option); | |
6 | ||
7 | use PVE::Firewall; | |
63c91681 | 8 | use PVE::API2::Firewall::Rules; |
8b27beb9 DM |
9 | |
10 | use Data::Dumper; # fixme: remove | |
11 | ||
12 | use 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 | ||
80 | 1; |