);
get_options(\%Opt);
# NB 04.02.17 # Auth
-# NB 04.02.17 if ($_ = $Opt{activate}) {
-# NB 04.02.17 my @keys = /:/ ? split(':',$_) : ($_,'');
-# NB 04.02.17 my $Api = OvhApi->new(type => OvhApi::OVH_API_EU, applicationKey => $keys[0], applicationSecret => $keys[1]);
-# NB 04.02.17 my $Answer = $Api->requestCredentials(accessRules => [ {
-# NB 04.02.17 method => 'ALL', path => '/*',
-# NB 04.02.17 method => 'GET', path => '/*',
-# NB 04.02.17 method => 'POST', path => '/*',
-# NB 04.02.17 method => 'PUT', path => '/*',
-# NB 04.02.17 method => 'DELETE', path => '/*',
-# NB 04.02.17 }]);
-# NB 04.02.17
-# NB 04.02.17 if ($Answer) {
-# NB 04.02.17 #my ($consumerKey, $validationUrl) = @{ $Answer->content}{qw{ consumerKey validationUrl }};
-# NB 04.02.17 print map {"$_\n"} @{ $Answer->content}{qw{ consumerKey validationUrl }};
-# NB 04.02.17 # $consumerKey contains the newly created Consumer Key
-# NB 04.02.17 # $validationUrl contains a link to OVH website in order to login an OVH account and link it to the credential
-# NB 04.02.17 }
-# NB 04.02.17 exit;
# NB 04.02.17 exec qq|curl -s -XPOST -H"X-Ovh-Application: $_" -H "Content-type: application/json" --data '{"accessRules":[{"method":"GET","path":"/*"},{"method":"POST","path":"/*"},{"method":"PUT","path":"/*"},{"method":"DELETE","path":"/*"}]}' https://api.ovh.com/1.0/auth/credential|;
# NB 04.02.17 exit 0;
# NB 04.02.17 }
die "Error" unless $Answer;
if ($Answer) {
my ($consumerKey, $validationUrl) = @{ $Answer->content}{qw{ consumerKey validationUrl }};
+ # $validationUrl contains a link to OVH website in order to login an OVH account and link it to the credential
push @KEY, $consumerKey;
print "Your consumerKey is $consumerKey\n";
print "You need to validate in your browser at $validationUrl\n";
- print "Create ~/.ovh.api with this content ".join(':',@KEY)."\n";
- #print map {"$_\n"} @{ $Answer->content}{qw{ consumerKey validationUrl }};
- # $consumerKey contains the newly created Consumer Key
- # $validationUrl contains a link to OVH website in order to login an OVH account and link it to the credential
+ print "Create ~/.ovh.api with permission 600 with\n".join(':',@KEY)."\n";
}
exit
}
help() unless @ARGV;
my $URL = shift @ARGV or help();
my $BODY = @ARGV ? shift(@ARGV) : {};
-#use Data::Dumper; die Dumper(JSON::encode_json($BODY));
-# 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);
if ( -e $BODY ) {
$BODY = JSON::decode_json(`cat $BODY`);
} elsif (ref($BODY) eq '') {
$BODY = JSON::encode_json($BODY);
}
-#$BODY = -e $BODY ? JSON::decode_json(`cat $BODY`) : JSON::encode_json($BODY);# if $BODY;
-#use Data::Dumper; die Dumper($BODY);
my $response = $Api->rawCall(path=>$URL,method=>$Opt{method},body=>$BODY);
if ($response->isFailure()) {