]>
git.proxmox.com Git - pve-apiclient.git/blob - src/examples/example4.pl
3 # NOTE: you need to run this on a PVE host, or modify the source to
4 # provide username/password/hostname from somewhere else.
11 use PVE
::APIClient
::LWP
;
14 print STDERR
"usage: $0 <host> [<user>]\n";
16 print STDERR
"Pass password in PMX_CLIENT_PASSWORD env. variable\n";
17 print STDERR
"User is either CLI argument, PMX_CLIENT_USER env. variable or 'root\@pam'\n";
18 print STDERR
"Pass PMX_CLIENT_FINGERPRINT env. variable for self-signed certificates.";
22 my $host = shift || usage
();
23 my $user = shift || $ENV{'PMX_CLIENT_USER'} || 'root@pam';
24 my $pass = $ENV{'PMX_CLIENT_PASSWORD'} || usage
();
28 if (my $fp = $ENV{'PMX_CLIENT_FINGERPRINT'}) {
32 my $conn = PVE
::APIClient
::LWP-
>new(
36 cached_fingerprints
=> $fps,
39 my $res = $conn->get("api2/json/version", {});
40 print to_json
($res, { pretty
=> 1, canonical
=> 1, utf8
=> 1});