]> git.proxmox.com Git - pve-manager.git/blobdiff - PVE/API2.pm
api: backup: update: turn delete into a hash
[pve-manager.git] / PVE / API2.pm
index 7da769b458ec2e02eb0f34a301101f93b81097a2..42941fd2a967cff5cee39d479f1678cba34eb0a2 100644 (file)
@@ -4,6 +4,8 @@ use strict;
 use warnings;
 
 use PVE::pvecfg;
+use PVE::DataCenterConfig;
+use PVE::GuestHelpers;
 use PVE::RESTHandler;
 use PVE::JSONSchema;
 
@@ -17,32 +19,32 @@ use PVE::API2::AccessControl;
 use PVE::API2::Storage::Config;
 
 __PACKAGE__->register_method ({
-    subclass => "PVE::API2::Cluster",  
+    subclass => "PVE::API2::Cluster",
     path => 'cluster',
 });
 
 __PACKAGE__->register_method ({
-    subclass => "PVE::API2::Nodes",  
+    subclass => "PVE::API2::Nodes",
     path => 'nodes',
 });
 
 __PACKAGE__->register_method ({
-    subclass => "PVE::API2::Storage::Config",  
+    subclass => "PVE::API2::Storage::Config",
     path => 'storage',
 });
 
 __PACKAGE__->register_method ({
-    subclass => "PVE::API2::AccessControl",  
+    subclass => "PVE::API2::AccessControl",
     path => 'access',
 });
 
 __PACKAGE__->register_method ({
-    subclass => "PVE::API2::Pool",  
+    subclass => "PVE::API2::Pool",
     path => 'pools',
 });
 
 __PACKAGE__->register_method ({
-    name => 'index', 
+    name => 'index',
     path => '',
     method => 'GET',
     permissions => { user => 'all' },
@@ -62,8 +64,8 @@ __PACKAGE__->register_method ({
        links => [ { rel => 'child', href => "{subdir}" } ],
     },
     code => sub {
-       my ($resp, $param) = @_;
-    
+       my ($param) = @_;
+
        my $res = [ { subdir => 'version' } ];
 
        my $ma = PVE::API2->method_attributes();
@@ -80,11 +82,11 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
-    name => 'version', 
+    name => 'version',
     path => 'version',
     method => 'GET',
     permissions => { user => 'all' },
-    description => "API version details. The result also includes the global datacenter confguration.",
+    description => "API version details, including some parts of the global datacenter config.",
     parameters => {
        additionalProperties => 0,
        properties => {},
@@ -92,22 +94,43 @@ __PACKAGE__->register_method ({
     returns => {
        type => "object",
        properties => {
-           version => { type => 'string' },
-           release => { type => 'string' },
-           repoid => { type => 'string' },
+           version => {
+               type => 'string',
+               description => 'The full pve-manager package version of this node.',
+           },
+           release => {
+               type => 'string',
+               description => 'The current Proxmox VE point release in `x.y` format.',
+           },
+           repoid => {
+               type => 'string',
+               # length 8 is old (< 8.0) short-id, 16 is new short id, 40 is sha1 and 64 is sha256
+               pattern => '[0-9a-fA-F]{8,64}',
+               description => 'The short git revision from which this version was build.',
+           },
+           console => {
+               type => 'string',
+               enum => ['applet', 'vv', 'html5', 'xtermjs'],
+               optional => 1,
+               description => 'The default console viewer to use.',
+           },
        },
     },
     code => sub {
-       my ($resp, $param) = @_;
-    
-       my $res = PVE::Cluster::cfs_read_file('datacenter.cfg');
+       my ($param) = @_;
+
+       my $res = {};
 
-       my $vi = PVE::pvecfg::version_info();
-       foreach my $k (qw(version release repoid)) {
-           $res->{$k} = $vi->{$k};
+       # TODO remove with next major release
+       my $datacenter_confg = eval { PVE::Cluster::cfs_read_file('datacenter.cfg') } // {};
+       for my $k (qw(console)) {
+           $res->{$k} = $datacenter_confg->{$k} if exists $datacenter_confg->{$k};
        }
 
+       my $version_info = PVE::pvecfg::version_info();
+       # force set all version keys independent of their definedness
+       $res->{$_} = $version_info->{$_} for qw(version release repoid);
+
        return $res;
     }});
-
 1;