mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-27 04:54:22 +00:00
api_dump: add $raw_dump options
Allow to return the original tree with all refs. We use this with our new pveclient which needs the full api definition. Keeping refs makes it possible to store the tree more efficiently. Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
parent
5082a17b81
commit
1e5ecf7bf8
@ -58,7 +58,7 @@ sub api_clone_schema {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub api_dump_full {
|
sub api_dump_full {
|
||||||
my ($tree, $index, $class, $prefix) = @_;
|
my ($tree, $index, $class, $prefix, $raw_dump) = @_;
|
||||||
|
|
||||||
$prefix = '' if !$prefix;
|
$prefix = '' if !$prefix;
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ sub api_dump_full {
|
|||||||
$path =~ s/\/+$//;
|
$path =~ s/\/+$//;
|
||||||
|
|
||||||
if ($info->{subclass}) {
|
if ($info->{subclass}) {
|
||||||
api_dump_full($tree, $index, $info->{subclass}, $path);
|
api_dump_full($tree, $index, $info->{subclass}, $path, $raw_dump);
|
||||||
} else {
|
} else {
|
||||||
next if !$path;
|
next if !$path;
|
||||||
|
|
||||||
@ -111,13 +111,16 @@ sub api_dump_full {
|
|||||||
|
|
||||||
my $d = $info->{$k};
|
my $d = $info->{$k};
|
||||||
|
|
||||||
|
if ($raw_dump) {
|
||||||
|
$data->{$k} = $d;
|
||||||
|
} else {
|
||||||
if ($k eq 'parameters') {
|
if ($k eq 'parameters') {
|
||||||
$data->{$k} = api_clone_schema($d);
|
$data->{$k} = api_clone_schema($d);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$data->{$k} = ref($d) ? clone($d) : $d;
|
$data->{$k} = ref($d) ? clone($d) : $d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$res->{info}->{$info->{method}} = $data;
|
$res->{info}->{$info->{method}} = $data;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -173,12 +176,12 @@ sub api_dump_remove_refs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub api_dump {
|
sub api_dump {
|
||||||
my ($class, $prefix) = @_;
|
my ($class, $prefix, $raw_dump) = @_;
|
||||||
|
|
||||||
my $tree = [];
|
my $tree = [];
|
||||||
|
|
||||||
my $index = {};
|
my $index = {};
|
||||||
api_dump_full($tree, $index, $class);
|
api_dump_full($tree, $index, $class, $prefix, $raw_dump);
|
||||||
api_dump_cleanup_tree($tree);
|
api_dump_cleanup_tree($tree);
|
||||||
return $tree;
|
return $tree;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user