From: Nicolas Boisselier Date: Mon, 21 Mar 2016 12:13:01 +0000 (+0100) Subject: ovi-api X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=bd95b6f80403259878b46e71d461c199e0f3643f;p=nb.git ovi-api --- diff --git a/bin/ovh-api b/bin/ovh-api index be4efbea..eade10a9 100755 --- a/bin/ovh-api +++ b/bin/ovh-api @@ -37,9 +37,20 @@ $main::_DATA_ = undef; # ################################################################################# #use Data::Dumper; -@_ = split(":",$ARGV[0]); -my $o = OvhApi->new(type => OvhApi::OVH_API_EU, applicationKey => $_[0], applicationSecret => $_[1], consumerKey => $_[2]); -print JSON::encode_json($o->get(path=>$ARGV[1])->content); +my @KEY = split(":",shift @ARGV); +my $URL = shift @ARGV; +my $METHOD = @ARGV ? shift(@ARGV) : 'GET'; + +my $o = OvhApi->new(type => OvhApi::OVH_API_EU, applicationKey => $KEY[0], applicationSecret => $KEY[1], consumerKey => $KEY[2]); + +my $response = $o->get(path=>$URL,method=>$METHOD); + +if (!$response) { + die "$NAME: $ARGV[1] failed!" +} + +my $content = $response->content; +print ref($content) eq '' ? $content : JSON::encode_json($content); ################################################################################# # @@ -174,6 +185,10 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY See . +=head1 SEE ALSO + +OvhApi + =head1 AUTHOR Nicolas Boisselier nicolas.boisselier@gmail.com