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