2011-08-23 07:40:22 +02:00
package PVE::API2 ;
use strict ;
use warnings ;
2011-12-20 07:04:39 +01:00
use PVE::pvecfg ;
2011-08-23 07:40:22 +02:00
use PVE::RESTHandler ;
2014-04-30 15:28:30 +02:00
use PVE::JSONSchema ;
2011-08-23 07:40:22 +02:00
use base qw( PVE::RESTHandler ) ;
# preload classes
use PVE::API2::Cluster ;
use PVE::API2::Nodes ;
2012-01-27 08:39:46 +01:00
use PVE::API2::Pool ;
2011-08-23 07:40:22 +02:00
use PVE::API2::AccessControl ;
use PVE::API2::Storage::Config ;
__PACKAGE__ - > register_method ( {
subclass = > "PVE::API2::Cluster" ,
path = > 'cluster' ,
} ) ;
__PACKAGE__ - > register_method ( {
subclass = > "PVE::API2::Nodes" ,
path = > 'nodes' ,
} ) ;
__PACKAGE__ - > register_method ( {
subclass = > "PVE::API2::Storage::Config" ,
path = > 'storage' ,
} ) ;
__PACKAGE__ - > register_method ( {
subclass = > "PVE::API2::AccessControl" ,
path = > 'access' ,
} ) ;
2012-01-27 08:39:46 +01:00
__PACKAGE__ - > register_method ( {
subclass = > "PVE::API2::Pool" ,
path = > 'pools' ,
} ) ;
2011-08-23 07:40:22 +02:00
__PACKAGE__ - > register_method ( {
name = > 'index' ,
path = > '' ,
method = > 'GET' ,
permissions = > { user = > 'all' } ,
description = > "Directory index." ,
parameters = > {
additionalProperties = > 0 ,
properties = > { } ,
} ,
returns = > {
type = > 'array' ,
items = > {
type = > "object" ,
properties = > {
subdir = > { type = > 'string' } ,
} ,
} ,
links = > [ { rel = > 'child' , href = > "{subdir}" } ] ,
} ,
code = > sub {
my ( $ resp , $ param ) = @ _ ;
2011-12-20 07:04:39 +01:00
my $ res = [ { subdir = > 'version' } ] ;
2011-08-23 07:40:22 +02:00
my $ ma = PVE::API2 - > method_attributes ( ) ;
foreach my $ info ( @$ ma ) {
next if ! $ info - > { subclass } ;
my $ subpath = $ info - > { match_re } - > [ 0 ] ;
push @$ res , { subdir = > $ subpath } ;
}
return $ res ;
} } ) ;
2011-12-20 07:04:39 +01:00
__PACKAGE__ - > register_method ( {
name = > 'version' ,
path = > 'version' ,
method = > 'GET' ,
permissions = > { user = > 'all' } ,
2013-12-10 07:33:09 +01:00
description = > "API version details. The result also includes the global datacenter confguration." ,
2011-12-20 07:04:39 +01:00
parameters = > {
additionalProperties = > 0 ,
properties = > { } ,
} ,
returns = > {
type = > "object" ,
properties = > {
version = > { type = > 'string' } ,
release = > { type = > 'string' } ,
repoid = > { type = > 'string' } ,
} ,
} ,
code = > sub {
my ( $ resp , $ param ) = @ _ ;
2013-12-10 07:33:09 +01:00
my $ res = PVE::Cluster:: cfs_read_file ( 'datacenter.cfg' ) ;
my $ vi = PVE::pvecfg:: version_info ( ) ;
foreach my $ k ( qw( version release repoid ) ) {
$ res - > { $ k } = $ vi - > { $ k } ;
}
2015-06-16 12:27:35 +02:00
2013-12-10 07:33:09 +01:00
return $ res ;
2011-12-20 07:04:39 +01:00
} } ) ;
2014-04-30 15:28:30 +02:00
2011-08-23 07:40:22 +02:00
1 ;