]> git.proxmox.com Git - pve-client.git/blame - extractapi.pl
Add spice command
[pve-client.git] / extractapi.pl
CommitLineData
8ef77d25
DM
1#!/usr/bin/perl
2
3use strict;
4use warnings;
ab79ce78 5use Storable;
8ef77d25
DM
6
7use PVE::RESTHandler;
8use PVE::API2;
8ef77d25 9
ab79ce78
DM
10sub 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
35my $tree = PVE::RESTHandler::api_dump('PVE::API2', undef, 1);
36
37remove_code_refs($tree);
38Storable::store_fd($tree, \*STDOUT);
8ef77d25
DM
39
40exit(0);