]> git.proxmox.com Git - pve-manager.git/blame - lib/PVE/API2.pm
imported from svn 'pve-manager/pve2'
[pve-manager.git] / lib / PVE / API2.pm
CommitLineData
aff192e6
DM
1package PVE::API2;
2
3use strict;
4use warnings;
5
6use Apache2::Const qw(:http);
7use PVE::RESTHandler;
8
9use base qw(PVE::RESTHandler);
10
11# preload classes
12use PVE::API2::Cluster;
13use PVE::API2::Nodes;
14use PVE::API2::AccessControl;
15use PVE::API2::Storage::Config;
16
17__PACKAGE__->register_method ({
18 subclass => "PVE::API2::Cluster",
19 path => 'cluster',
20});
21
22__PACKAGE__->register_method ({
23 subclass => "PVE::API2::Nodes",
24 path => 'nodes',
25});
26
27__PACKAGE__->register_method ({
28 subclass => "PVE::API2::Storage::Config",
29 path => 'storage',
30});
31
32__PACKAGE__->register_method ({
33 subclass => "PVE::API2::AccessControl",
34 path => 'access',
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
60 my $res = [];
61
62 my $ma = PVE::API2->method_attributes();
63
64 foreach my $info (@$ma) {
65 next if !$info->{subclass};
66
67 my $subpath = $info->{match_re}->[0];
68
69 push @$res, { subdir => $subpath };
70 }
71
72 return $res;
73 }});
74
751;