API-Eulerian
view release on metacpan or search on metacpan
examples/edw/Rest.pl view on Meta::CPAN
39404142434445464748495051525354555657585960616263646566676869my
%h_setup
= (
grid
=>
$grid
,
ip
=>
$ip
,
token
=>
$token
,
site
=>
$site
,
query
=>
$query
);
# get local IP
if
( !
defined
$h_setup
{ip} || !
length
$h_setup
{ip} ) {
unless
(
$response
->{success} ) {
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
} ) {
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
) {
STDERR
"\trequested query $query does not exists.\n"
;
examples/edw/get_csv_file.pl view on Meta::CPAN
38394041424344454647484950515253545556575859606162636465666768my
%h_setup
= (
grid
=>
$grid
,
ip
=>
$ip
,
token
=>
$token
,
site
=>
$site
,
query
=>
$query
);
# get local IP
if
( !
defined
$h_setup
{ip} || !
length
$h_setup
{ip} ) {
unless
(
$response
->{success} ) {
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
} ) {
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
) {
STDERR
"\trequested query $query does not exists.\n"
;
lib/API/Eulerian/EDW/Authority.pm view on Meta::CPAN
105106107108109110111112113114115116117118119120121122123124125126127128129130131132133#
# @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
104105106107108109110111112113114115116117118119120121122123124#
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
179180181182183184185186187188189190191192193194195196197198199# 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.306 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )