]>
Commit | Line | Data |
---|---|---|
8ef77d25 DM |
1 | #!/usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
ab79ce78 | 5 | use Storable; |
8ef77d25 DM |
6 | |
7 | use PVE::RESTHandler; | |
8 | use PVE::API2; | |
8ef77d25 | 9 | |
ab79ce78 DM |
10 | sub remove_code_refs { |
11 | my ($tree) = @_; | |
12 | ||
13 | my $class = ref($tree); | |
14 | return if !$class; | |
15 | ||
16 | if ($class eq 'ARRAY') { | |
17 | foreach my $el (@$tree) { | |
18 | remove_code_refs($el); | |
19 | } | |
20 | } elsif ($class eq 'HASH') { | |
21 | foreach my $k (keys %$tree) { | |
22 | if (my $itemclass = ref($tree->{$k})) { | |
23 | if ($itemclass eq 'CODE') { | |
24 | undef $tree->{$k}; | |
25 | } elsif ($itemclass eq 'Regexp') { | |
26 | $tree->{$k} = "$tree"; # return string representation | |
27 | } else { | |
28 | remove_code_refs($tree->{$k}); | |
29 | } | |
30 | } | |
31 | } | |
32 | } | |
33 | } | |
34 | ||
2ecf9b57 DM |
35 | my $root = { |
36 | path => '/', | |
37 | text => '', | |
38 | children => PVE::RESTHandler::api_dump('PVE::API2', undef, 1), | |
39 | info => { | |
40 | GET => PVE::API2->map_method_by_name('index'), | |
41 | }, | |
42 | }; | |
43 | ||
44 | remove_code_refs($root); | |
45 | Storable::store_fd($root, \*STDOUT); | |
8ef77d25 DM |
46 | |
47 | exit(0); |