]>
Commit | Line | Data |
---|---|---|
1360e6f0 DM |
1 | package PMG::API2; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | use PVE::RESTHandler; | |
7 | use PVE::JSONSchema; | |
8 | ||
9 | use PMG::API2::AccessControl; | |
10 | use PMG::API2::Nodes; | |
a643bba6 | 11 | use PMG::API2::Config; |
b66faa68 | 12 | use PMG::API2::Quarantine; |
d67b777f | 13 | use PMG::API2::Statistics; |
0678d564 | 14 | use PMG::pmgcfg; |
1360e6f0 DM |
15 | |
16 | use base qw(PVE::RESTHandler); | |
17 | ||
a643bba6 DM |
18 | __PACKAGE__->register_method ({ |
19 | subclass => "PMG::API2::Config", | |
20 | path => 'config', | |
21 | }); | |
22 | ||
1360e6f0 | 23 | __PACKAGE__->register_method ({ |
0678d564 | 24 | subclass => "PMG::API2::Nodes", |
1360e6f0 DM |
25 | path => 'nodes', |
26 | }); | |
27 | ||
28 | __PACKAGE__->register_method ({ | |
0678d564 | 29 | subclass => "PMG::API2::AccessControl", |
1360e6f0 | 30 | path => 'access', |
b66faa68 DM |
31 | }); |
32 | ||
33 | __PACKAGE__->register_method ({ | |
34 | subclass => "PMG::API2::Quarantine", | |
35 | path => 'quarantine', | |
1360e6f0 DM |
36 | }); |
37 | ||
d67b777f DM |
38 | __PACKAGE__->register_method ({ |
39 | subclass => "PMG::API2::Statistics", | |
40 | path => 'statistics', | |
41 | }); | |
42 | ||
1360e6f0 DM |
43 | __PACKAGE__->register_method ({ |
44 | name => 'index', | |
45 | path => '', | |
46 | method => 'GET', | |
47 | permissions => { user => 'all' }, | |
48 | description => "Directory index.", | |
49 | parameters => { | |
50 | additionalProperties => 0, | |
51 | properties => {}, | |
52 | }, | |
53 | returns => { | |
54 | type => 'array', | |
55 | items => { | |
56 | type => "object", | |
57 | properties => { | |
58 | subdir => { type => 'string' }, | |
59 | }, | |
60 | }, | |
61 | links => [ { rel => 'child', href => "{subdir}" } ], | |
62 | }, | |
63 | code => sub { | |
64 | my ($resp, $param) = @_; | |
65 | ||
0678d564 | 66 | my $res = [ |
b66faa68 | 67 | { subdir => 'access' }, |
a643bba6 | 68 | { subdir => 'config' }, |
0678d564 DM |
69 | { subdir => 'nodes' }, |
70 | { subdir => 'version' }, | |
b66faa68 | 71 | { subdir => 'quarantine' }, |
d67b777f | 72 | { subdir => 'statistics' }, |
0678d564 | 73 | ]; |
1360e6f0 DM |
74 | |
75 | return $res; | |
76 | }}); | |
77 | ||
78 | ||
0678d564 DM |
79 | __PACKAGE__->register_method ({ |
80 | name => 'version', | |
81 | path => 'version', | |
82 | method => 'GET', | |
83 | permissions => { user => 'all' }, | |
84 | description => "API version details.", | |
85 | parameters => { | |
86 | additionalProperties => 0, | |
87 | properties => {}, | |
88 | }, | |
89 | returns => { | |
90 | type => "object", | |
91 | properties => { | |
1c15ce0f TL |
92 | version => { |
93 | type => 'string', | |
94 | description => 'The current installed pmg-api package version', | |
95 | }, | |
96 | release => { | |
97 | type => 'string', | |
98 | description => 'The current installed Proxmox Mailgateway Release', | |
99 | }, | |
100 | repoid => { | |
101 | type => 'string', | |
102 | description => 'The short git commit hash ID from which this version was build', | |
103 | }, | |
0678d564 DM |
104 | }, |
105 | }, | |
106 | code => sub { | |
107 | my ($param) = @_; | |
108 | ||
109 | return PMG::pmgcfg::version_info(); | |
110 | }}); | |
111 | ||
1360e6f0 | 112 | 1; |