]> git.proxmox.com Git - pmg-api.git/blob - PMG/API2.pm
add more ruledb classes
[pmg-api.git] / 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::pmgcfg;
12
13 use base qw(PVE::RESTHandler);
14
15 __PACKAGE__->register_method ({
16 subclass => "PMG::API2::Nodes",
17 path => 'nodes',
18 });
19
20 __PACKAGE__->register_method ({
21 subclass => "PMG::API2::AccessControl",
22 path => 'access',
23 });
24
25 __PACKAGE__->register_method ({
26 name => 'index',
27 path => '',
28 method => 'GET',
29 permissions => { user => 'all' },
30 description => "Directory index.",
31 parameters => {
32 additionalProperties => 0,
33 properties => {},
34 },
35 returns => {
36 type => 'array',
37 items => {
38 type => "object",
39 properties => {
40 subdir => { type => 'string' },
41 },
42 },
43 links => [ { rel => 'child', href => "{subdir}" } ],
44 },
45 code => sub {
46 my ($resp, $param) = @_;
47
48 my $res = [
49 { subdir => 'nodes' },
50 { subdir => 'version' },
51 ];
52
53 return $res;
54 }});
55
56
57 __PACKAGE__->register_method ({
58 name => 'version',
59 path => 'version',
60 method => 'GET',
61 permissions => { user => 'all' },
62 description => "API version details.",
63 parameters => {
64 additionalProperties => 0,
65 properties => {},
66 },
67 returns => {
68 type => "object",
69 properties => {
70 version => { type => 'string' },
71 release => { type => 'string' },
72 repoid => { type => 'string' },
73 },
74 },
75 code => sub {
76 my ($param) = @_;
77
78 return PMG::pmgcfg::version_info();
79 }});
80
81 1;