]> git.proxmox.com Git - pve-client.git/blob - pveclient
8ea109d042ed7683a59681f85babad86f34a2e7d
[pve-client.git] / pveclient
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5 use lib '/usr/share/pve-client';
6 use Data::Dumper;
7
8 use PVE::CLIHandler;
9
10 use PVE::APIClient::LWP;
11 use PVE::APIClient::Helpers;
12 use PVE::APIClient::Commands::remote;
13
14 use JSON;
15
16 sub print_usage {
17
18 die "Usage: implement me";
19 exit(-1);
20 }
21
22 sub call_method {
23 my ($path, $method, $args) = @_;
24
25 die "missing API path\n" if !defined($path);
26
27 my $info = PVE::APIClient::Helpers::lookup_api_method($path, $method);
28 my $param = PVE::APIClient::Helpers::get_options($info->{parameters}, $args);
29 print Dumper($param);
30
31 die "implement me";
32 }
33
34 # NOTE: This binary is just a placeholer - nothing implemented so far!
35
36 #my $hostname = 'localhost';
37 #my $username = 'root@pam';
38 #
39 #my $conn = PVE::APIClient::LWP->new(
40 # username => $username,
41 # #password => 'yourpassword',
42 # #ticket => $ticket,
43 # #csrftoken => $csrftoken,
44 # host => $hostname,
45 # # allow manual fingerprint verification
46 # manual_verification => 1,
47 # );
48
49 #my $res = $conn->get("/", {});
50 #print to_json($res, { pretty => 1, canonical => 1});
51
52 my $cmd = shift || print_usage();
53
54 if ($cmd eq 'get') {
55 my $method = 'GET';
56 my $path;
57 if (scalar(@ARGV) && $ARGV[0] !~ m/^\-/) {
58 $path = shift @ARGV;
59 }
60 my $res = call_method($path, $method, \@ARGV);
61 die "implement me";
62 } elsif ($cmd eq 'set') {
63 die "implement me";
64 } elsif ($cmd eq 'create') {
65 die "implement me";
66 } elsif ($cmd eq 'delete') {
67 die "implement me";
68 } elsif ($cmd eq 'remote') {
69 PVE::APIClient::Commands::remote->run_cli_handler();
70 } else {
71 print_usage();
72 }
73
74 exit(0);