API-Eulerian
view release on metacpan or search on metacpan
examples/edw/Rest.pl view on Meta::CPAN
my %h_setup = (
grid => $grid,
ip => $ip,
token => $token,
site => $site,
query => $query
);
# get local IP
if ( !defined $h_setup{ip} || !length $h_setup{ip} ) {
my $response = HTTP::Tiny->new->get('http://monip.org/');
unless ( $response->{success} ) {
print STDERR "\tunable to reach external network to get IP address.\n";
exit(1);
}
($h_setup{ip}) = ($response->{content} =~ /IP\s:\s(\d+\.\d+\.\d+\.\d+)/gm);
}
foreach my $p ( qw/ grid ip token site query / ) {
if ( !defined $h_setup{$p} || !length $h_setup{$p} ) {
print STDERR "\tmissing $p parameter, check help.\n";
exit(1);
}
}
delete $h_setup{$_} for ( qw/ site query / );
# get query to send
my $qfile = './examples/edw/sql/'.$query.'.sql';
if ( !-e $qfile ) {
print STDERR "\trequested query $query does not exists.\n";
examples/edw/get_csv_file.pl view on Meta::CPAN
my %h_setup = (
grid => $grid,
ip => $ip,
token => $token,
site => $site,
query => $query
);
# get local IP
if ( !defined $h_setup{ip} || !length $h_setup{ip} ) {
my $response = HTTP::Tiny->new->get('http://monip.org/');
unless ( $response->{success} ) {
print STDERR "\tunable to reach external network to get IP address.\n";
exit(1);
}
($h_setup{ip}) = ($response->{content} =~ /IP\s:\s(\d+\.\d+\.\d+\.\d+)/gm);
}
foreach my $p ( qw/ grid ip token site query / ) {
if ( !defined $h_setup{$p} || !length $h_setup{$p} ) {
print STDERR "\tmissing $p parameter, check help.\n";
exit(1);
}
}
delete $h_setup{$_} for ( qw/ site query / );
# get query to send
my $qfile = './examples/edw/sql/'.$query.'.sql';
if ( !-e $qfile ) {
print STDERR "\trequested query $query does not exists.\n";
lib/API/Eulerian/EDW/Authority.pm view on Meta::CPAN
#
# @return API::Eulerian::EDW::Status
#
sub _url
{
my ( $class, $kind, $platform, $grid, $ip, $token ) = @_;
my $domain;
#
# Sanity check mandatories arguments
#
if( ! ( defined( $grid ) && length( $grid ) > 0 ) ) {
return $class->_error(
406, "Mandatory argument 'grid' is missing or invalid"
);
} elsif( ! ( defined( $ip ) && length( $ip ) > 0 ) ) {
return $class->_error(
406, "Mandatory argument 'ip' is missing"
);
} elsif( ! ( defined( $token ) && length( $token ) > 0 ) ) {
return $class->_error(
406, "Mandatory argument 'token' is missing"
);
}
#
# URL formats are :
#
# Start :
#
# https://<grid>.<domain>/ea/v2/<token>/er/account/
lib/API/Eulerian/EDW/Request.pm view on Meta::CPAN
#
sub json
{
my ( $class, $response ) = @_;
my $data = undef;
if( $class->is_json( $response ) ) {
$data = $response->decoded_content;
if( defined( $data ) ) {
chomp( $data );
if( length( $data ) > 0 ) {
$data = encode( 'utf-8', $data );
$data = decode_json( $data );
} else {
$data = undef;
}
}
}
return $data;
}
lib/API/Eulerian/EDW/Request.pm view on Meta::CPAN
# Sanity check POST arguments
if( $method eq 'POST' ) {
if( ! ( defined( $what ) && defined( $type ) ) ) {
$status->error( 1 );
$status->msg( "Mandatory argument to post request is/are missing" );
$status->code( 400 );
return $status;
} else {
# Setup Content_Length and Content_Type
$headers->push_header( Content_Length => length( $what ) );
$headers->push_header( Content_Type => $type );
}
}
# Create HTTP Request
$request = HTTP::Request->new( $method, $url, $headers, $what );
# Create End Point used to communicate with remote server
$endpoint = LWP::UserAgent->new(
keep_alive => 0,
( run in 0.406 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )