# Query
query();
-
-#################################################################################
-#
# END
-#
-#################################################################################
exit 0;
#################################################################################
}
sub query {
-help() unless @ARGV;
-my $URL = shift @ARGV or help();
-my $BODY = @ARGV ? shift(@ARGV) : {};
-
-if ( -e $BODY ) {
- $BODY = JSON::decode_json(`cat $BODY`);
-} elsif (ref($BODY) eq '') {
- $BODY = JSON::encode_json($BODY);
-}
-my $response = $Api->rawCall(path=>$URL,method=>$Opt{method},body=>$BODY);
+ help() unless @ARGV;
-if ($response->isFailure()) {
- die "$NAME: ERR: ".$response->error()."\n";
-}
+ my $URL = shift @ARGV or help();
+ my $BODY = @ARGV ? shift(@ARGV) : {};
+
+ if ( -e $BODY ) {
+ $BODY = JSON::decode_json(`cat $BODY`);
+ } elsif (ref($BODY) eq '') {
+ $BODY = JSON::encode_json($BODY);
+ }
+
+ my $response = $Api->rawCall(path=>$URL,method=>$Opt{method},body=>$BODY);
+ die "$NAME: ERR: ".$response->error()."\n" if $response->isFailure();
+
+ my $content = $response->content;
+ return unless defined $content;
+
+ if ($Opt{rows}) {
+ for my $id (@$content) {
+ $response = $Api->rawCall(path=>$URL.'/'.$id,method=>$Opt{method},body=>{});
+ die "$NAME: ERR: ".$response->error()."\n" if $response->isFailure();
+ print JSON::encode_json($response->content)."\n";
+ }
+ return
+ }
-my $content = $response->content;
-exit unless defined $content;
-$content = JSON::encode_json($content) if $content and ref($content) ne '';
-#use Data::Dumper; die Dumper($content);
-print "$content\n";
+ $content = JSON::encode_json($content) if $content and ref($content) ne '';
+ #use Data::Dumper; die Dumper($content);
+ print "$content\n";
}
sub help {
=head1 OPTIONS
+ option[rows|r] Print each rows of a table (eg /ip, /server, ...)
option[method|m=s] Method (default: GET)
option[verbose|v+] Verbose mode: increase the verbosity level.
option[debug+] Debug mode: increase the verbosity level.