]> git.proxmox.com Git - pmg-api.git/blame - src/PMG/API2.pm
adapt to new pmgcfg version/release semantic
[pmg-api.git] / src / PMG / API2.pm
CommitLineData
1360e6f0
DM
1package PMG::API2;
2
3use strict;
4use warnings;
5
6use PVE::RESTHandler;
7use PVE::JSONSchema;
8
9use PMG::API2::AccessControl;
10use PMG::API2::Nodes;
a643bba6 11use PMG::API2::Config;
b66faa68 12use PMG::API2::Quarantine;
d67b777f 13use PMG::API2::Statistics;
0678d564 14use PMG::pmgcfg;
1360e6f0
DM
15
16use 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 1121;