API-Eulerian

 view release on metacpan or  search on metacpan

examples/edw/Rest.pl  view on Meta::CPAN

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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

105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#
# @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 :
  #

lib/API/Eulerian/EDW/Request.pm  view on Meta::CPAN

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#
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

179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# 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 )