]> git.nbdom.net Git - nb.git/commitdiff
ovh-api
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 14 Dec 2016 14:01:22 +0000 (15:01 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 14 Dec 2016 14:01:22 +0000 (15:01 +0100)
bin/ovh-api

index fa630ff18b7b0fcd0f42f1f990359d0795314b1a..142e85a5a46edd942c1027e02f089852a82b6b89 100755 (executable)
@@ -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)