]> git.proxmox.com Git - pmg-api.git/blob - src/PMG/API2.pm
api: nodeconfig: validate acme config before writing
[pmg-api.git] / src / PMG / API2.pm
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;
11 use PMG::API2::Config;
12 use PMG::API2::Quarantine;
13 use PMG::API2::Statistics;
14 use PMG::pmgcfg;
15
16 use base qw(PVE::RESTHandler);
17
18 __PACKAGE__->register_method ({
19 subclass => "PMG::API2::Config",
20 path => 'config',
21 });
22
23 __PACKAGE__->register_method ({
24 subclass => "PMG::API2::Nodes",
25 path => 'nodes',
26 });
27
28 __PACKAGE__->register_method ({
29 subclass => "PMG::API2::AccessControl",
30 path => 'access',
31 });
32
33 __PACKAGE__->register_method ({
34 subclass => "PMG::API2::Quarantine",
35 path => 'quarantine',
36 });
37
38 __PACKAGE__->register_method ({
39 subclass => "PMG::API2::Statistics",
40 path => 'statistics',
41 });
42
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
66 my $res = [
67 { subdir => 'access' },
68 { subdir => 'config' },
69 { subdir => 'nodes' },
70 { subdir => 'version' },
71 { subdir => 'quarantine' },
72 { subdir => 'statistics' },
73 ];
74
75 return $res;
76 }});
77
78
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 => {
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 },
104 },
105 },
106 code => sub {
107 my ($param) = @_;
108
109 return PMG::pmgcfg::version_info();
110 }});
111
112 1;