]>
Commit | Line | Data |
---|---|---|
aff192e6 DM |
1 | package PVE::API2; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | use Apache2::Const qw(:http); | |
7 | use PVE::RESTHandler; | |
8 | ||
9 | use base qw(PVE::RESTHandler); | |
10 | ||
11 | # preload classes | |
12 | use PVE::API2::Cluster; | |
13 | use PVE::API2::Nodes; | |
14 | use PVE::API2::AccessControl; | |
15 | use 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 | ||
75 | 1; |