]> git.proxmox.com Git - pmg-api.git/blob - PMG/API2/Who.pm
api apt/versions: add some missing packages
[pmg-api.git] / PMG / API2 / Who.pm
1 package PMG::API2::Who;
2
3 use strict;
4 use warnings;
5 use Data::Dumper;
6
7 use PVE::SafeSyslog;
8 use PVE::Tools qw(extract_param);
9 use HTTP::Status qw(:constants);
10 use PVE::JSONSchema qw(get_standard_option);
11 use PVE::RESTHandler;
12 use PVE::INotify;
13
14 use PMG::Config;
15
16 use PMG::RuleDB::WhoRegex;
17 use PMG::RuleDB::EMail;
18 use PMG::RuleDB::IPAddress;
19 use PMG::RuleDB::IPNet;
20 use PMG::RuleDB::Domain;
21 use PMG::RuleDB::LDAP;
22 use PMG::RuleDB::LDAPUser;
23 use PMG::RuleDB;
24
25 use base qw(PVE::RESTHandler);
26
27 __PACKAGE__->register_method ({
28 name => 'index',
29 path => '',
30 method => 'GET',
31 description => "Directory index.",
32 permissions => { check => [ 'admin', 'audit' ] },
33 parameters => {
34 additionalProperties => 0,
35 properties => {
36 ogroup => {
37 description => "Object Group ID.",
38 type => 'integer',
39 },
40 },
41 },
42 returns => {
43 type => 'array',
44 items => {
45 type => "object",
46 properties => {
47 subdir => { type => 'string'},
48 },
49 },
50 links => [ { rel => 'child', href => "{subdir}" } ],
51 },
52 code => sub {
53 my ($param) = @_;
54
55 return [
56 { subdir => 'config' },
57 { subdir => 'objects' },
58 { subdir => 'email' },
59 { subdir => 'domain' },
60 { subdir => 'regex' },
61 { subdir => 'ip' },
62 { subdir => 'network' },
63 { subdir => 'ldap' },
64 ];
65
66 }});
67
68 PMG::API2::ObjectGroupHelpers::register_delete_object_group_api(__PACKAGE__, 'who', '');
69 PMG::API2::ObjectGroupHelpers::register_object_group_config_api(__PACKAGE__, 'who', 'config');
70 PMG::API2::ObjectGroupHelpers::register_objects_api(__PACKAGE__, 'who', 'objects');
71
72 PMG::RuleDB::EMail->register_api(__PACKAGE__, 'email');
73 PMG::RuleDB::Domain->register_api(__PACKAGE__, 'domain');
74 PMG::RuleDB::WhoRegex->register_api(__PACKAGE__, 'regex');
75 PMG::RuleDB::IPAddress->register_api(__PACKAGE__, 'ip');
76 PMG::RuleDB::IPNet->register_api(__PACKAGE__, 'network');
77 PMG::RuleDB::LDAP->register_api(__PACKAGE__, 'ldap');
78 PMG::RuleDB::LDAPUser->register_api(__PACKAGE__, 'ldapuser');
79
80 1;