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