]>
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; |
0678d564 | 13 | use PMG::pmgcfg; |
1360e6f0 DM |
14 | |
15 | use base qw(PVE::RESTHandler); | |
16 | ||
a643bba6 DM |
17 | __PACKAGE__->register_method ({ |
18 | subclass => "PMG::API2::Config", | |
19 | path => 'config', | |
20 | }); | |
21 | ||
1360e6f0 | 22 | __PACKAGE__->register_method ({ |
0678d564 | 23 | subclass => "PMG::API2::Nodes", |
1360e6f0 DM |
24 | path => 'nodes', |
25 | }); | |
26 | ||
27 | __PACKAGE__->register_method ({ | |
0678d564 | 28 | subclass => "PMG::API2::AccessControl", |
1360e6f0 | 29 | path => 'access', |
b66faa68 DM |
30 | }); |
31 | ||
32 | __PACKAGE__->register_method ({ | |
33 | subclass => "PMG::API2::Quarantine", | |
34 | path => 'quarantine', | |
1360e6f0 DM |
35 | }); |
36 | ||
37 | __PACKAGE__->register_method ({ | |
38 | name => 'index', | |
39 | path => '', | |
40 | method => 'GET', | |
41 | permissions => { user => 'all' }, | |
42 | description => "Directory index.", | |
43 | parameters => { | |
44 | additionalProperties => 0, | |
45 | properties => {}, | |
46 | }, | |
47 | returns => { | |
48 | type => 'array', | |
49 | items => { | |
50 | type => "object", | |
51 | properties => { | |
52 | subdir => { type => 'string' }, | |
53 | }, | |
54 | }, | |
55 | links => [ { rel => 'child', href => "{subdir}" } ], | |
56 | }, | |
57 | code => sub { | |
58 | my ($resp, $param) = @_; | |
59 | ||
0678d564 | 60 | my $res = [ |
b66faa68 | 61 | { subdir => 'access' }, |
a643bba6 | 62 | { subdir => 'config' }, |
0678d564 DM |
63 | { subdir => 'nodes' }, |
64 | { subdir => 'version' }, | |
b66faa68 | 65 | { subdir => 'quarantine' }, |
0678d564 | 66 | ]; |
1360e6f0 DM |
67 | |
68 | return $res; | |
69 | }}); | |
70 | ||
71 | ||
0678d564 DM |
72 | __PACKAGE__->register_method ({ |
73 | name => 'version', | |
74 | path => 'version', | |
75 | method => 'GET', | |
76 | permissions => { user => 'all' }, | |
77 | description => "API version details.", | |
78 | parameters => { | |
79 | additionalProperties => 0, | |
80 | properties => {}, | |
81 | }, | |
82 | returns => { | |
83 | type => "object", | |
84 | properties => { | |
85 | version => { type => 'string' }, | |
86 | release => { type => 'string' }, | |
87 | repoid => { type => 'string' }, | |
88 | }, | |
89 | }, | |
90 | code => sub { | |
91 | my ($param) = @_; | |
92 | ||
93 | return PMG::pmgcfg::version_info(); | |
94 | }}); | |
95 | ||
1360e6f0 | 96 | 1; |