]> git.proxmox.com Git - pve-common.git/commitdiff
api_dump: add $raw_dump options
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 11 Jun 2018 09:23:19 +0000 (11:23 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 12 Jun 2018 09:01:31 +0000 (11:01 +0200)
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>
src/PVE/RESTHandler.pm

index 5e70503d81d8965f081b2cae9cfee773201cfe8e..50c37c2b2bd9f44caa499ed58eeeff052b5efbb8 100644 (file)
@@ -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/\/+$//;
 
        if ($info->{subclass}) {
        $path =~ s/\/+$//;
 
        if ($info->{subclass}) {
-           api_dump_full($tree, $index, $info->{subclass}, $path);
+           api_dump_full($tree, $index, $info->{subclass}, $path, $raw_dump);
        } else {
            next if !$path;
 
        } else {
            next if !$path;
 
@@ -110,12 +110,15 @@ sub api_dump_full {
                        $k eq "path";
 
                    my $d = $info->{$k};
                        $k eq "path";
 
                    my $d = $info->{$k};
-                   
-                   if ($k eq 'parameters') {
-                       $data->{$k} = api_clone_schema($d);
-                   } else {
 
 
-                       $data->{$k} = ref($d) ? clone($d) : $d;
+                   if ($raw_dump) {
+                       $data->{$k} = $d;
+                   } else {
+                       if ($k eq 'parameters') {
+                           $data->{$k} = api_clone_schema($d);
+                       } else {
+                           $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 $index = {};
 
     my $tree = [];
 
     my $index = {};
-    api_dump_full($tree, $index, $class);
+    api_dump_full($tree, $index, $class, $prefix, $raw_dump);
     api_dump_cleanup_tree($tree);
     return $tree;
 };
     api_dump_cleanup_tree($tree);
     return $tree;
 };