]> git.proxmox.com Git - pve-manager.git/blame - PVE/API2.pm
update shipped appliance info index
[pve-manager.git] / PVE / API2.pm
CommitLineData
aff192e6
DM
1package PVE::API2;
2
3use strict;
4use warnings;
5
8747a9ec 6use PVE::pvecfg;
3ac3653e 7use PVE::DataCenterConfig;
1f6d7f7f 8use PVE::GuestHelpers;
aff192e6 9use PVE::RESTHandler;
3ed61033 10use PVE::JSONSchema;
aff192e6
DM
11
12use base qw(PVE::RESTHandler);
13
14# preload classes
15use PVE::API2::Cluster;
16use PVE::API2::Nodes;
f16eb02d 17use PVE::API2::Pool;
aff192e6
DM
18use PVE::API2::AccessControl;
19use PVE::API2::Storage::Config;
20
21__PACKAGE__->register_method ({
94d7d5ac 22 subclass => "PVE::API2::Cluster",
aff192e6
DM
23 path => 'cluster',
24});
25
26__PACKAGE__->register_method ({
94d7d5ac 27 subclass => "PVE::API2::Nodes",
aff192e6
DM
28 path => 'nodes',
29});
30
31__PACKAGE__->register_method ({
94d7d5ac 32 subclass => "PVE::API2::Storage::Config",
aff192e6
DM
33 path => 'storage',
34});
35
36__PACKAGE__->register_method ({
94d7d5ac 37 subclass => "PVE::API2::AccessControl",
aff192e6
DM
38 path => 'access',
39});
40
f16eb02d 41__PACKAGE__->register_method ({
94d7d5ac 42 subclass => "PVE::API2::Pool",
f16eb02d
DM
43 path => 'pools',
44});
45
aff192e6 46__PACKAGE__->register_method ({
94d7d5ac 47 name => 'index',
aff192e6
DM
48 path => '',
49 method => 'GET',
50 permissions => { user => 'all' },
51 description => "Directory index.",
52 parameters => {
53 additionalProperties => 0,
54 properties => {},
55 },
56 returns => {
57 type => 'array',
58 items => {
59 type => "object",
60 properties => {
61 subdir => { type => 'string' },
62 },
63 },
64 links => [ { rel => 'child', href => "{subdir}" } ],
65 },
66 code => sub {
94d7d5ac
TL
67 my ($param) = @_;
68
8747a9ec 69 my $res = [ { subdir => 'version' } ];
aff192e6
DM
70
71 my $ma = PVE::API2->method_attributes();
72
73 foreach my $info (@$ma) {
74 next if !$info->{subclass};
75
76 my $subpath = $info->{match_re}->[0];
77
78 push @$res, { subdir => $subpath };
79 }
80
81 return $res;
82 }});
83
8747a9ec 84__PACKAGE__->register_method ({
94d7d5ac 85 name => 'version',
8747a9ec
DM
86 path => 'version',
87 method => 'GET',
88 permissions => { user => 'all' },
b2eec1b6 89 description => "API version details, including some parts of the global datacenter config.",
8747a9ec
DM
90 parameters => {
91 additionalProperties => 0,
92 properties => {},
93 },
94 returns => {
95 type => "object",
96 properties => {
3ce05d40
TL
97 version => {
98 type => 'string',
99 description => 'The full pve-manager package version of this node.',
100 },
101 release => {
102 type => 'string',
103 description => 'The current Proxmox VE point release in `x.y` format.',
104 },
105 repoid => {
106 type => 'string',
0e77456f
TL
107 # length 8 is old (< 8.0) short-id, 16 is new short id, 40 is sha1 and 64 is sha256
108 pattern => '[0-9a-fA-F]{8,64}',
3ce05d40
TL
109 description => 'The short git revision from which this version was build.',
110 },
111 console => {
112 type => 'string',
113 enum => ['applet', 'vv', 'html5', 'xtermjs'],
114 optional => 1,
115 description => 'The default console viewer to use.',
116 },
8747a9ec
DM
117 },
118 },
119 code => sub {
94d7d5ac
TL
120 my ($param) = @_;
121
b2eec1b6 122 my $res = {};
2d802f8c 123
1f6d7f7f 124 # TODO remove with next major release
b2eec1b6
TL
125 my $datacenter_confg = eval { PVE::Cluster::cfs_read_file('datacenter.cfg') } // {};
126 for my $k (qw(console)) {
127 $res->{$k} = $datacenter_confg->{$k} if exists $datacenter_confg->{$k};
2d802f8c 128 }
94d7d5ac 129
b2eec1b6
TL
130 my $version_info = PVE::pvecfg::version_info();
131 # force set all version keys independent of their definedness
132 $res->{$_} = $version_info->{$_} for qw(version release repoid);
133
2d802f8c 134 return $res;
8747a9ec 135 }});
aff192e6 1361;