mirror of
https://git.proxmox.com/git/pve-client
synced 2025-10-04 20:37:13 +00:00
pve-api-definition.dat: add root index method
This commit is contained in:
parent
826591e032
commit
2ecf9b57e8
@ -51,31 +51,30 @@ sub print_result {
|
|||||||
# TODO: implement different output formats ($format)
|
# TODO: implement different output formats ($format)
|
||||||
|
|
||||||
if ($format eq 'json') {
|
if ($format eq 'json') {
|
||||||
print to_json($data, {utf8 => 1, allow_nonref => 1, canonical => 1, pretty => 1 });
|
print to_json($data, {utf8 => 1, allow_nonref => 1, canonical => 1, pretty => 1 });
|
||||||
} elsif ($format eq 'text') {
|
} elsif ($format eq 'text') {
|
||||||
my $type = $result_schema->{type};
|
my $type = $result_schema->{type};
|
||||||
if ($type eq 'object') {
|
if ($type eq 'object') {
|
||||||
die "implement me";
|
die "implement me";
|
||||||
} elsif ($type eq 'array') {
|
} elsif ($type eq 'array') {
|
||||||
my $item_type = $result_schema->{items}->{type};
|
my $item_type = $result_schema->{items}->{type};
|
||||||
if ($item_type eq 'object') {
|
if ($item_type eq 'object') {
|
||||||
die "implement me";
|
die "implement me";
|
||||||
} elsif ($item_type eq 'array') {
|
} elsif ($item_type eq 'array') {
|
||||||
die "implement me";
|
die "implement me";
|
||||||
} else {
|
} else {
|
||||||
foreach my $el (@$data) {
|
foreach my $el (@$data) {
|
||||||
print "$el\n"
|
print "$el\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print "$data\n";
|
print "$data\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
die "internal error: unknown output format"; # should not happen
|
die "internal error: unknown output format"; # should not happen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my $__real_remove_formats; $__real_remove_formats = sub {
|
my $__real_remove_formats; $__real_remove_formats = sub {
|
||||||
my ($properties) = @_;
|
my ($properties) = @_;
|
||||||
|
|
||||||
@ -164,7 +163,9 @@ sub find_method_info {
|
|||||||
|
|
||||||
my $stack = [ grep { length($_) > 0 } split('\/+' , $path)]; # skip empty fragments
|
my $stack = [ grep { length($_) > 0 } split('\/+' , $path)]; # skip empty fragments
|
||||||
|
|
||||||
my $child = $map_path_to_info->(get_api_definition(), $stack, $uri_param);
|
my $api = get_api_definition();
|
||||||
|
|
||||||
|
my $child = scalar(@$stack) ? $map_path_to_info->($api->{children}, $stack, $uri_param) : $api;
|
||||||
|
|
||||||
if (!($child && $child->{info} && $child->{info}->{$method})) {
|
if (!($child && $child->{info} && $child->{info}->{$method})) {
|
||||||
return undef if $noerr;
|
return undef if $noerr;
|
||||||
@ -229,7 +230,7 @@ sub merge_api_definition_properties {
|
|||||||
sub complete_api_path {
|
sub complete_api_path {
|
||||||
my ($text) = @_;
|
my ($text) = @_;
|
||||||
|
|
||||||
get_api_definition(); # make sure API data is loaded
|
my $api = get_api_definition(); # make sure API data is loaded
|
||||||
|
|
||||||
$text =~ s!^/!!;
|
$text =~ s!^/!!;
|
||||||
|
|
||||||
@ -238,10 +239,10 @@ sub complete_api_path {
|
|||||||
my $info;
|
my $info;
|
||||||
if (!defined($dir)) {
|
if (!defined($dir)) {
|
||||||
$dir = '';
|
$dir = '';
|
||||||
$info = { children => $pve_api_definition };
|
$info = $api;
|
||||||
} else {
|
} else {
|
||||||
my $stack = [ grep { length($_) > 0 } split('\/+' , $dir)]; # skip empty fragments
|
my $stack = [ grep { length($_) > 0 } split('\/+' , $dir)]; # skip empty fragments
|
||||||
$info = $map_path_to_info->($pve_api_definition, $stack, {});
|
$info = $map_path_to_info->($api->{children}, $stack, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
my $res = [];
|
my $res = [];
|
||||||
|
@ -32,9 +32,16 @@ sub remove_code_refs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $tree = PVE::RESTHandler::api_dump('PVE::API2', undef, 1);
|
my $root = {
|
||||||
|
path => '/',
|
||||||
|
text => '',
|
||||||
|
children => PVE::RESTHandler::api_dump('PVE::API2', undef, 1),
|
||||||
|
info => {
|
||||||
|
GET => PVE::API2->map_method_by_name('index'),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
remove_code_refs($tree);
|
remove_code_refs($root);
|
||||||
Storable::store_fd($tree, \*STDOUT);
|
Storable::store_fd($root, \*STDOUT);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user