use get_options from PVE::JSONSchema
[pve-client.git] / pveclient
CommitLineData
29505e2c
DM
1#!/usr/bin/perl
2
3use strict;
4use warnings;
565bbc73 5use lib '/usr/share/pve-client';
29505e2c
DM
6use Data::Dumper;
7
a04fd959 8use PVE::JSONSchema;
565bbc73
DM
9use PVE::CLIHandler;
10
29505e2c
DM
11use PVE::APIClient::LWP;
12use PVE::APIClient::Helpers;
565bbc73
DM
13use PVE::APIClient::Commands::remote;
14
29505e2c
DM
15use JSON;
16
17sub print_usage {
18
19 die "Usage: implement me";
20 exit(-1);
21}
22
23sub 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);
a04fd959 29 my $param = PVE::JSONSchema::get_options($info->{parameters}, $args);
29505e2c
DM
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
53my $cmd = shift || print_usage();
54
55if ($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";
565bbc73
DM
69} elsif ($cmd eq 'remote') {
70 PVE::APIClient::Commands::remote->run_cli_handler();
29505e2c
DM
71} else {
72 print_usage();
73}
74
565bbc73 75exit(0);