]> git.proxmox.com Git - pve-manager.git/blob - PVE/API2.pm
update shipped appliance info index
[pve-manager.git] / PVE / API2.pm
1 package PVE::API2;
2
3 use strict;
4 use warnings;
5
6 use PVE::pvecfg;
7 use PVE::RESTHandler;
8 use PVE::JSONSchema;
9
10 use base qw(PVE::RESTHandler);
11
12 # preload classes
13 use PVE::API2::Cluster;
14 use PVE::API2::Nodes;
15 use PVE::API2::Pool;
16 use PVE::API2::AccessControl;
17 use PVE::API2::Storage::Config;
18
19 __PACKAGE__->register_method ({
20 subclass => "PVE::API2::Cluster",
21 path => 'cluster',
22 });
23
24 __PACKAGE__->register_method ({
25 subclass => "PVE::API2::Nodes",
26 path => 'nodes',
27 });
28
29 __PACKAGE__->register_method ({
30 subclass => "PVE::API2::Storage::Config",
31 path => 'storage',
32 });
33
34 __PACKAGE__->register_method ({
35 subclass => "PVE::API2::AccessControl",
36 path => 'access',
37 });
38
39 __PACKAGE__->register_method ({
40 subclass => "PVE::API2::Pool",
41 path => 'pools',
42 });
43
44 __PACKAGE__->register_method ({
45 name => 'index',
46 path => '',
47 method => 'GET',
48 permissions => { user => 'all' },
49 description => "Directory index.",
50 parameters => {
51 additionalProperties => 0,
52 properties => {},
53 },
54 returns => {
55 type => 'array',
56 items => {
57 type => "object",
58 properties => {
59 subdir => { type => 'string' },
60 },
61 },
62 links => [ { rel => 'child', href => "{subdir}" } ],
63 },
64 code => sub {
65 my ($resp, $param) = @_;
66
67 my $res = [ { subdir => 'version' } ];
68
69 my $ma = PVE::API2->method_attributes();
70
71 foreach my $info (@$ma) {
72 next if !$info->{subclass};
73
74 my $subpath = $info->{match_re}->[0];
75
76 push @$res, { subdir => $subpath };
77 }
78
79 return $res;
80 }});
81
82 __PACKAGE__->register_method ({
83 name => 'version',
84 path => 'version',
85 method => 'GET',
86 permissions => { user => 'all' },
87 description => "API version details. The result also includes the global datacenter confguration.",
88 parameters => {
89 additionalProperties => 0,
90 properties => {},
91 },
92 returns => {
93 type => "object",
94 properties => {
95 version => { type => 'string' },
96 release => { type => 'string' },
97 repoid => { type => 'string' },
98 },
99 },
100 code => sub {
101 my ($resp, $param) = @_;
102
103 my $res = PVE::Cluster::cfs_read_file('datacenter.cfg');
104
105 my $vi = PVE::pvecfg::version_info();
106 foreach my $k (qw(version release repoid)) {
107 $res->{$k} = $vi->{$k};
108 }
109
110 return $res;
111 }});
112
113 1;