]>
Commit | Line | Data |
---|---|---|
2499333b DM |
1 | package PMG::API2::When; |
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::TimeFrame; | |
17 | use PMG::RuleDB; | |
18 | ||
19 | use base qw(PVE::RESTHandler); | |
20 | ||
21 | __PACKAGE__->register_method ({ | |
22 | name => 'index', | |
23 | path => '', | |
24 | method => 'GET', | |
25 | description => "Directory index.", | |
b07f4d68 | 26 | permissions => { check => [ 'admin', 'audit' ] }, |
2499333b DM |
27 | parameters => { |
28 | additionalProperties => 0, | |
29 | properties => { | |
30 | ogroup => { | |
31 | description => "Object Group ID.", | |
32 | type => 'integer', | |
33 | }, | |
34 | }, | |
35 | }, | |
36 | returns => { | |
37 | type => 'array', | |
38 | items => { | |
39 | type => "object", | |
40 | properties => { | |
41 | subdir => { type => 'string'}, | |
42 | }, | |
43 | }, | |
44 | links => [ { rel => 'child', href => "{subdir}" } ], | |
45 | }, | |
46 | code => sub { | |
47 | my ($param) = @_; | |
48 | ||
49 | return [ | |
50 | { subdir => 'config' }, | |
51 | { subdir => 'objects' }, | |
52 | { subdir => 'timeframe' }, | |
53 | ]; | |
54 | ||
55 | }}); | |
56 | ||
57 | PMG::API2::ObjectGroupHelpers::register_delete_object_group_api(__PACKAGE__, 'when', ''); | |
58 | PMG::API2::ObjectGroupHelpers::register_object_group_config_api(__PACKAGE__, 'when', 'config'); | |
59 | PMG::API2::ObjectGroupHelpers::register_objects_api(__PACKAGE__, 'when', 'objects'); | |
60 | ||
61 | PMG::RuleDB::TimeFrame->register_api(__PACKAGE__, 'timeframe'); | |
62 | ||
63 | 1; |