]> git.proxmox.com Git - pve-manager.git/blob - bin/test/example2.pl
73682428fb0ae18d1ee23d9b45c8755b0de23783
[pve-manager.git] / bin / test / example2.pl
1 #!/usr/bin/perl -w
2
3
4 use strict;
5 use PVE::API2Client;
6 use PVE::AccessControl;
7 use PVE::INotify;
8
9 use Data::Dumper;
10
11 my $hostname = PVE::INotify::read_file("hostname");
12
13 # normally you use username/password,
14 # but we can simply create a ticket and CRSF token if we are root
15 my $ticket = PVE::AccessControl::assemble_ticket('root@pam');
16 my $csrftoken = PVE::AccessControl::assemble_csrf_prevention_token('root@pam');
17
18 my $conn = PVE::API2Client->new(
19 #username => 'root@pam',
20 #password => 'yourpassword',
21 ticket => $ticket,
22 csrftoken => $csrftoken,
23 host => $hostname,
24 );
25
26 my $res = $conn->get("api2/json/access/domains", {});
27 print "TEST: " . Dumper($res);