]> git.proxmox.com Git - pve-firewall.git/blame - src/PVE/API2/Firewall/Groups.pm
define standard option for security group names
[pve-firewall.git] / src / PVE / API2 / Firewall / Groups.pm
CommitLineData
8f119284
DM
1package PVE::API2::Firewall::Groups;
2
3use strict;
4use warnings;
5use PVE::JSONSchema qw(get_standard_option);
6
7use PVE::Firewall;
86791289 8use PVE::API2::Firewall::Rules;
8f119284
DM
9
10use Data::Dumper; # fixme: remove
11
12use 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 26 properties => {
387d0ffc 27 name => get_standard_option('pve-security-group-name'),
d1c53b3e 28 },
8f119284
DM
29 },
30 links => [ { rel => 'child', href => "{name}" } ],
31 },
32 code => sub {
33 my ($param) = @_;
34
fca39c2c 35 my $cluster_conf = PVE::Firewall::load_clusterfw_conf();
8f119284
DM
36
37 my $res = [];
c6f5cc88
DM
38 foreach my $group (keys %{$cluster_conf->{groups}}) {
39 push @$res, { name => $group, count => scalar(@{$cluster_conf->{groups}->{$group}}) };
d1c53b3e
DM
40 }
41
42 return $res;
43 }});
44
387d0ffc 45
86791289
DM
46__PACKAGE__->register_method ({
47 subclass => "PVE::API2::Firewall::GroupRules",
d1c53b3e 48 path => '{group}',
86791289 49});
9c7e0858 50
8f119284 511;