###############################################################
#
# @file Json.pm
#
# @brief Eulerian Data Warehouse REST Json Parser Module definition.
#
# @author Thorillon Xavier:x.thorillon@euleri
EDW::Parser::JSON;
#
# Enforce compilor rules
#
use strict; use warnings;
#
# Inherited interface from API::Eulerian::EDW::Parser
#
use parent 'API::Eulerian::EDW::Parser';
#
#
#
use JSON::Streaming::
class.
# @param $path - File Path.
# @param $uuid - Request UUID.
#
# @return API::Eulerian::EDW::Json Parser.
#
sub new
{
my ( $class, $path, $uuid ) = @_;
my $self;
my $fd;
# Setup base cla
class.
# @param $path - File Path.
# @param $uuid - Request uuid.
#
# @return API::Eulerian::EDW::Json Parser.
#
sub new
{
my ( $class, $path, $uuid ) = @_;
my $self;
my $file;
my $fd;
if(
nd.
#
my %KINDS = (
'session' => '/er/account/get_dw_session_token.json?ip=',
'access' => '/er/account/get_dw_access_token.json?ip=',
);
#
# @brief Get valid HTTP Authorization bearer used to ac
tform, $platform_auth, $grid, $ip, $token ) = @_;
my $response;
my $status;
my $code;
my $json;
# Get URL used to request API::Eulerian::EDW Authority for Token.
$status = $class->_url( $
expect JSON reply data
$json = API::Eulerian::EDW::Request->json( $response );
if( $json && ( $code == 200 ) ) {
$status = $json->{ error } ?
$class->_error( $code, $json->{ err
rian::EDW::Bench
#
use API::Eulerian::EDW::Bench;
#
# Import Switch
#
use Switch;
#
# Import JSON
#
use JSON;
#
#
#
use API::Eulerian::EDW::Authority();
#
#
#
use Encode;
#
#
#
our @ISA = qw/ API::Eul
);
if( ! $status->error() ) {
my $json = API::Eulerian::EDW::Request->json( $status->{ response } );
if( defined( $json ) && $json->{ status }->[ 1 ] != 0 ) {
$status = AP
:EDW::Status->new();
$status->error( 1 );
$status->msg( $json->{ status }->[ 0 ] );
$status->code( $json->{ status }->[ 1 ] );
}
}
}
return $status;
}
#
# @brief
###############
#
# Setup module name
#
package API::Eulerian::EDW::Peer::Rest;
use strict;
use JSON();
use POSIX();
use Sys::Hostname();
use API::Eulerian::EDW::Peer();
use API::Eulerian::EDW::Fil
PI::Eulerian::EDW::Status();
use API::Eulerian::EDW::Authority();
use API::Eulerian::EDW::Parser::JSON();
use API::Eulerian::EDW::Parser::CSV();
our @ISA = qw/ API::Eulerian::EDW::Peer /;
#
# Define
an.ca'
);
#
# Defines Parser class name matching format.
#
my %PARSERS = (
'json' => 'API::Eulerian::EDW::Parser::JSON',
'csv' => 'API::Eulerian::EDW::Parser::CSV',
);
#
# @brief Allocate and in
;
#
# Import HTTP::Status
#
use HTTP::Status qw( :constants :is status_message );
#
# Import JSON
#
use JSON;
#
# Import Encode
#
use Encode;
#
# @brief Create new HTTP Headers.
#
# @param $class - AP
JSON format.
#
# @param $class - API::Eulerian::EDW::Request Class.
# @param $response - HTTP response.
#
# @return 1 - Content type is JSON.
# @return 0 - Content type isnt JSON.
#
sub is_json
{
types ) {
# Test if subtype is JSON format
if( $subtype eq 'application/json' ) {
return 1;
}
}
}
return 0;
}
#
# @brief Get JSON object from HTTP response.
#
# @par