mirror of
				https://git.proxmox.com/git/pmg-docs
				synced 2025-11-04 03:05:43 +00:00 
			
		
		
		
	build-depends on the new proxmox-widget-toolkit-dev package Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
		
			
				
	
	
		
			48 lines
		
	
	
		
			880 B
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			880 B
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/perl
 | 
						|
 | 
						|
use strict;
 | 
						|
use warnings;
 | 
						|
use JSON;
 | 
						|
 | 
						|
use PVE::RESTHandler;
 | 
						|
 | 
						|
use PMG::API2;
 | 
						|
 | 
						|
sub cleanup_tree {
 | 
						|
    my ($h) = @_;
 | 
						|
 | 
						|
    my $class = ref($h);
 | 
						|
    return $h if !$class;
 | 
						|
 | 
						|
    if ($class eq 'ARRAY') {
 | 
						|
	my $res = [];
 | 
						|
	foreach my $el (@$h) {
 | 
						|
	    push @$res, cleanup_tree($el);
 | 
						|
	}
 | 
						|
	return $res;
 | 
						|
    } elsif ($class eq 'HASH') {
 | 
						|
	my $res = {};
 | 
						|
	foreach my $k (keys %$h) {
 | 
						|
	    if (my $class = ref($h->{$k})) {
 | 
						|
		if ($class eq 'CODE') {
 | 
						|
		    next if $k eq 'completion';
 | 
						|
		}
 | 
						|
		$res->{$k} = cleanup_tree($h->{$k});
 | 
						|
	    } else {
 | 
						|
		$res->{$k} = $h->{$k};
 | 
						|
	    }
 | 
						|
	}
 | 
						|
	return $res;
 | 
						|
    } elsif ($class eq 'Regexp') {
 | 
						|
	return "$h"; # return string representation
 | 
						|
    } else {
 | 
						|
	die "unknown class '$class'\n";
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
my $tree = cleanup_tree(PVE::RESTHandler::api_dump('PMG::API2'));
 | 
						|
 | 
						|
print "var apiSchema = " . to_json($tree, {pretty => 1, canonical => 1}) . ";\n\n";
 | 
						|
 | 
						|
exit(0);
 |