summaryrefslogtreecommitdiffstats
path: root/extensions/TryAutoLand/bin/TryAutoLand.updateStatus_json.pl
blob: f39b55229d3aac51a0d07b878b8978bf4497c37a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl -w

use JSON::RPC::Client;
use Data::Dumper;
use HTTP::Cookies;

###################################
# Need to login first             #
###################################

my $username = shift;
my $password = shift;

my $cookie_jar = HTTP::Cookies->new( file => "/tmp/lwp_cookies.dat" );

my $rpc = new JSON::RPC::Client;

$rpc->ua->ssl_opts(verify_hostname => 0);

my $uri = "http://fedora/726193/jsonrpc.cgi";

#$rpc->ua->cookie_jar($cookie_jar);

#my $result = $rpc->call($uri, { method => 'User.login', params => 
#    { login => $username, password => $password } });

#if ($result) {
#    if ($result->is_error) {                                                         
#        print "Error : ", $result->error_message;
#        exit;
#    }                                                                                                       
#    else {
#        print "Successfully logged in.\n";
#    }
#}
#else {
#    print $rpc->status_line;                                                                                                                                             
#}  

###################################
# Main call here                  #
###################################

my $attach_id = shift;
my $action    = shift;
my $status    = shift;

$result = $rpc->call($uri, { method => 'TryAutoLand.update', 
                             params => { attach_id         => $attach_id,
                                         action            => $action, 
                                         status            => $status, 
                                         Bugzilla_login    => $username, 
                                         Bugzilla_password => $password  } });

if ($result) {
    if ($result->is_error) {                                                         
        print "Error : ", $result->error_message;
        exit;
    }                                                                                                       
}
else {
    print $rpc->status_line;                                                                                                                                             
}  

print Dumper($result->result);