]>
Commit | Line | Data |
---|---|---|
8f119284 DM |
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; | |
86791289 | 8 | use PVE::API2::Firewall::Rules; |
8f119284 DM |
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.", | |
8f119284 DM |
19 | parameters => { |
20 | additionalProperties => 0, | |
8f119284 DM |
21 | }, |
22 | returns => { | |
23 | type => 'array', | |
24 | items => { | |
25 | type => "object", | |
d1c53b3e DM |
26 | properties => { |
27 | name => { | |
28 | description => "Security group name.", | |
29 | type => 'string', | |
30 | }, | |
31 | }, | |
8f119284 DM |
32 | }, |
33 | links => [ { rel => 'child', href => "{name}" } ], | |
34 | }, | |
35 | code => sub { | |
36 | my ($param) = @_; | |
37 | ||
fca39c2c | 38 | my $cluster_conf = PVE::Firewall::load_clusterfw_conf(); |
8f119284 DM |
39 | |
40 | my $res = []; | |
c6f5cc88 DM |
41 | foreach my $group (keys %{$cluster_conf->{groups}}) { |
42 | push @$res, { name => $group, count => scalar(@{$cluster_conf->{groups}->{$group}}) }; | |
d1c53b3e DM |
43 | } |
44 | ||
45 | return $res; | |
46 | }}); | |
47 | ||
86791289 DM |
48 | __PACKAGE__->register_method ({ |
49 | subclass => "PVE::API2::Firewall::GroupRules", | |
d1c53b3e | 50 | path => '{group}', |
86791289 | 51 | }); |
9c7e0858 | 52 | |
8f119284 | 53 | 1; |