my $Api = OvhApi->new(type => OvhApi::OVH_API_EU, applicationKey => $KEY[0], applicationSecret => $KEY[1], consumerKey => $KEY[2]);
# Auth
-if (@KEY < 3) {
+auth() if @KEY < 3;
+
+# Query
+query();
+
+
+#################################################################################
+#
+# END
+#
+#################################################################################
+exit 0;
+
+#################################################################################
+#
+# Functions
+#
+#################################################################################
+sub auth {
my $Answer = $Api->requestCredentials(accessRules => [ {
method => 'ALL', path => '/*',
}]);
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 "New go to $validationUrl\n";
+ print "Go to $validationUrl\n";
print "Your consumerKey is $consumerKey\n";
print "Create ~/.ovh.api with permission 600 with\n".join(':',@KEY)."\n";
}
exit
}
-# Query
+sub query {
help() unless @ARGV;
my $URL = shift @ARGV or help();
my $BODY = @ARGV ? shift(@ARGV) : {};
$content = JSON::encode_json($content) if $content and ref($content) ne '';
#use Data::Dumper; die Dumper($content);
print "$content\n";
+}
-#################################################################################
-#
-# END
-#
-#################################################################################
-exit 0;
-
-#################################################################################
-#
-# Functions
-#
-#################################################################################
sub help {
#------------------------------------------------------------------------------
# Print help and exit
From https://api.ovh.com/console:
+ /ips
/domain/zone/<DOMAIN>/export
/dedicated/server
/dedicated/server/<SERVER>