]> git.proxmox.com Git - pve-client.git/blame - PVE/APIClient/Commands/list.pm
fix copyright date
[pve-client.git] / PVE / APIClient / Commands / list.pm
CommitLineData
5b090843
RJ
1package PVE::APIClient::Commands::list;
2
3use strict;
4use warnings;
5use JSON;
6
c9138c03 7use PVE::APIClient::JSONSchema qw(get_standard_option);
5b090843 8
5101e472 9use PVE::APIClient::Helpers;
ef03892d
DM
10use PVE::APIClient::Config;
11use PVE::APIClient::CLIHandler;
12
c9138c03 13use base qw(PVE::APIClient::CLIHandler);
5b090843 14
5101e472
DM
15# define as array to keep ordering
16my $list_returns_properties = [
17 'vmid' => get_standard_option('pve-vmid'),
18 'node' => get_standard_option('pve-node'),
19 'type' => { type => 'string' },
20 'status' => { type => 'string' },
21 'name' => { type => 'string', optional => 1 },
22 ];
23
5b090843
RJ
24__PACKAGE__->register_method ({
25 name => 'list',
26 path => 'list',
27 method => 'GET',
4aba8d31 28 description => "List VMs and Containers.",
5b090843
RJ
29 parameters => {
30 additionalProperties => 0,
31 properties => {
32 remote => get_standard_option('pveclient-remote-name'),
5101e472
DM
33 },
34 },
35 returns => {
36 type => 'array',
37 items => {
38 type => 'object',
39 properties => { @$list_returns_properties },
5b090843
RJ
40 },
41 },
5b090843
RJ
42 code => sub {
43 my ($param) = @_;
44
45 my $config = PVE::APIClient::Config->load();
46 my $conn = PVE::APIClient::Config->remote_conn($config, $param->{remote});
5101e472
DM
47
48 return $conn->get('api2/json/cluster/resources', { type => 'vm' });
5b090843
RJ
49 }});
50
51
4aba8d31
DM
52our $cmddef = [ __PACKAGE__, 'list', ['remote'], {},
53 sub {
54 my ($data, $schema, $options) = @_;
55 PVE::APIClient::Helpers::print_ordered_result($list_returns_properties, $data, $schema, $options);
56 },
57 $PVE::APIClient::RESTHandler::standard_output_options,
58 ];
5b090843 59
ef03892d 601;