start API
[pve-firewall.git] / src / PVE / API2 / Firewall / Groups.pm
1 package PVE::API2::Firewall::Groups;
2
3 use strict;
4 use warnings;
5 use PVE::JSONSchema qw(get_standard_option);
6
7 use PVE::Firewall;
8
9
10 use Data::Dumper; # fixme: remove
11
12 use base qw(PVE::RESTHandler);
13
14 __PACKAGE__->register_method({
15 name => 'list',
16 path => '',
17 method => 'GET',
18 description => "List security groups.",
19 proxyto => 'node',
20 parameters => {
21 additionalProperties => 0,
22 properties => {
23 node => get_standard_option('pve-node'),
24 },
25 },
26 returns => {
27 type => 'array',
28 items => {
29 type => "object",
30 properties => {},
31 },
32 links => [ { rel => 'child', href => "{name}" } ],
33 },
34 code => sub {
35 my ($param) = @_;
36
37 my $groups_conf = PVE::Firewall::load_security_groups();
38
39 my $res = [];
40 foreach my $group (keys %{$groups_conf->{rules}}) {
41 push @$res, { name => $group };
42 }
43
44 return $res;
45 }});
46
47 1;