From 2dd242f3f41ac0480027e6814817e4e3e1890691 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 14 Dec 2016 15:01:22 +0100 Subject: [PATCH] ovh-api --- bin/ovh-api | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/ovh-api b/bin/ovh-api index fa630ff1..142e85a5 100755 --- a/bin/ovh-api +++ b/bin/ovh-api @@ -69,12 +69,16 @@ help() unless @ARGV; my $o = OvhApi->new(type => OvhApi::OVH_API_EU, applicationKey => $KEY[0], applicationSecret => $KEY[1], consumerKey => $KEY[2]); my $URL = shift @ARGV or help(); +my $BODY = @ARGV ? shift @ARGV : ''; # NB 14.12.16 use LWP::Simple; # NB 14.12.16 if ($URL eq '/help') { # NB 14.12.16 die LWP::Simple::get('https://eu.api.ovh.com/console/'); # NB 14.12.16 } #my $URL = @ARGV == 1 ? shift @ARGV : join('/',map{uri_escape($_)} @ARGV); -my $response = $o->get(path=>$URL,method=>$Opt{method}); + +$BODY = -e $BODY ? JSON::decode_json(`cat $BODY`) : JSON::encode_json($BODY) if $BODY; +#use Data::Dumper; die Dumper($BODY); +my $response = $o->rawCall(path=>$URL,method=>$Opt{method},body=>$BODY); if (!$response) { die "$NAME: $URL failed!" @@ -190,7 +194,7 @@ Quick usage: =head1 OPTIONS option[activate=s] [KEY] Activate a key (first bit before ":" or KEY[0]) - option[method|m] Method (default: GET) + option[method|m=s] Method (default: GET) option[verbose|v+] Verbose mode: increase the verbosity level. option[debug+] Debug mode: increase the verbosity level. option[version|V] Print version (default: $VERSION) -- 2.47.3