API-Eulerian

 view release on metacpan or  search on metacpan

LICENSE  view on Meta::CPAN

    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) 19xx name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License.  Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here a sample; alter the names:

examples/edw/sql/sessions.sql  view on Meta::CPAN

    visitwchannel.session.last.pageview.userinfo.idcustomer,
    visitwchannel.session.first.pageview.device.deviceplatform.version,
    visitwchannel.session.first.pageview.device.deviceplatform.deviceplatformvendorname.deviceplatformvendor.vendor,
    visitwchannel.session.first.pageview.device.deviceplatform.deviceplatformvendorname.name,
    visitwchannel.session.first.pageview.device.devicebrowser.version,
    visitwchannel.session.first.pageview.device.devicebrowser.devicebrowservendorname.name,
    visitwchannel.session.first.pageview.device.devicebrowser.devicebrowservendorname.devicebrowservendor.vendor,
    visitwchannel.session.first.pageview.device.devicehardware.name,
    visitwchannel.session.first.pageview.device.devicehardware.devicehardwarevendor.vendor,
    visitwchannel.session.first.pageview.device.devicescreeninches,
    visitwchannel.session.first.pageview.device.devicetype.type
  }
  LIMIT 100
};

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

    . TIMERANGE : {
        begin : $start,
        end : $end,
      },
    . HEADERS   : {
string_end
  foreach my $column ( @$columns ) {
    if( ref( $column ) eq 'ARRAY' ) {
      $string .= "        $column->[ 0 ] : $column->[ 1 ],\n";
    } else {
      # Thin Peer doesnt return columns types
      $string .= "               UNKNOWN : $column,\n";
    }
  }
  $string .= "      },\n  }\n";
  print( $string );
  return $self;
}
#
# @brief Analysis reply rows on Row outputs analysis.
#

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

sub parse
{
  my ( $self, $status ) = @_;
  my $path = $status->{ path };
  my $parser;
  my $name;
  my %rc;

  my $pattern = '[0-9]*\.(json|csv|parquet)';

  # Parse file path, get file type
  if( ( $path =~ m/$pattern/ ) ) {
    # Lookup for parser matching file type
    if( ( $name = $PARSERS{ $1 } ) ) {
      # Create new instance of Parser
      if( ( $parser = $name->new( $path, $self->uuid() ) ) ) {
        # Parse reply file raise callback hook
        $parser->do( $self->hook() );
      } else {
        $status->error( 1 );
        $status->msg( "Failed to create Parser" );
        $status->code( 401 );
      }

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

#        their matching callback hook.
#
# @param $ws - Eulerian WebSocket.
# @param $buf - Received buffer.
#
sub dispatcher
{
  my ( $ws, $buf ) = @_;
  $buf = encode( 'utf-8', $buf );
  my $json = decode_json( $buf );
  my $type = $json->{ message };
  my $uuid = $json->{ uuid };
  my $self = $ws->{ _THIN };
  my $hook = $self->hook();
  my $rows = $json->{ rows };

  switch( $type ) {
    case 'add' {
      $hook->on_add( $json->{ uuid }, $json->{ rows } );
    }
    case 'replace' {
      $hook->on_replace( $json->{ uuid }, $json->{ rows } );
    }
    case 'headers' {
      #print Dumper( $json ) . "\n";
      $self->{ uuid } = $uuid;
      $hook->on_headers(

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

        $json->{ uuid }, $json->{ aes }, $json->{ status }->[ 1 ],
        $json->{ status }->[ 0 ], $json->{ status }->[ 2 ]
      );
    }
    else {}
  }

}
#
# @brief Join Websocket stream, raise callback hook accordingly to received
#        messages types.
#
# @param $self - API::Eulerian::EDW::Peer:Thin instance.
# @param $rc - Reply context of JOB creation.
#
# @return Reply context.
#
sub join
{
  my ( $self, $status ) = @_;
  my $json = API::Eulerian::EDW::Request->json( $status->{ response } );

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

#
# @param $class - API::Eulerian::EDW::HTTP class.
#
# @return HTTP Headers.
#
sub headers
{
  return HTTP::Headers->new();
}
#
# @brief Test if the content type of given HTTP response is a
#        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
{
  my ( $class, $response ) = @_;
  my $type;

  # Get content type value from HTTP response
  $type = $response->header( 'content-type' );
  if( defined( $type ) ) {
    # Split content type into an array.
    my @subtypes = split( '; ', $type );
    # Iterate on subtypes entries
    foreach my $subtype ( @subtypes ) {
      # Test if subtype is JSON format
      if( $subtype eq 'application/json' ) {
        return 1;
      }
    }
  }

  return 0;
}
#
# @brief Get JSON object from HTTP response.
#

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

  my ( $class, $url, $headers, $file ) = @_;
  return $class->_request( 'GET', $url, $headers, undef, undef, $file );
}
#
# @brief Do HTTP Post on given URL.
#
# @param $class - API::Eulerian::EDW::HTTP class.
# @param $url - Remote URL.
# @param $headers - HTTP::Headers.
# @param $what - Request Data.
# @param $type - Request Data Type.
#
# @return API::Eulerian::EDW::Status instance.
#
sub post
{
  my ( $class, $url, $headers, $what, $type ) = @_;
  return $class->_request( 'POST', $url, $headers, $what, $type );
}
#
# @brief Send HTTP request on given url.
#
# @param $class - API::Eulerian::EDW Request class.
# @param $method - HTTP method.
# @param $url - Remote URL.
# @param $headers - HTTP headers.
# @param $what - Data of POST request.
# @param $type - Data type of POST request
# @param $file - Local file path used to store HTTP reply.
#
# @return API::Eulerian::EDW::Status instance.
#
use Data::Dumper;
sub _request
{
  my ( $class, $method, $url, $headers, $what, $type, $file ) = @_;
  my $status = API::Eulerian::EDW::Status->new();
  my $endpoint;
  my $request;

  # Ensure default type
  $type = $type || 'application/json';

  # 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,
    cookie_jar => {},

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

=head3 input

=over 4

=item * url : Remote url.

=item * headers : HTTP headers.

=item * what : Content of POST request.

=item * type : Content type of POST request.

=back

=head3 output

=over 4

=item * API::Eulerian::EDW::Status. On success a new entry named 'response' is inserted into the status.

=back



( run in 0.818 second using v1.01-cache-2.11-cpan-f0ff5d10edf )