Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/activedbsoft/webapi-active-query-builder-perl

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/activedbsoft/webapi-active-query-builder-perl

  • v0.0.0-20171202235106-8e07049fe873
  • Source
  • Go
  • Socket score

Version published
Created
Source

NAME

SQL::QueryBuilder::WebApi::Role - a Moose role for the QueryBuilderApi

Active Query Builder Web API lets create, analyze and modify SQL queries for different database servers using RESTful HTTP requests to a cloud-based service. It requires SQL execution context (information about database schema and used database server) to be stored under the registered account at https://webapi.activequerybuilder.com/.

A note on Moose

This role is the only component of the library that uses Moose. See SQL::QueryBuilder::WebApi::ApiFactory for non-Moosey usage.

Structure of the library

The library consists of a set of API classes, one for each endpoint. These APIs implement the method calls available on each endpoint.

Additionally, there is a set of "object" classes, which represent the objects returned by and sent to the methods on the endpoints.

An API factory class is provided, which builds instances of each endpoint API.

This Moose role flattens all the methods from the endpoint APIs onto the consuming class. It also provides methods to retrieve the endpoint API objects, and the API factory object, should you need it.

For documentation of all these methods, see AUTOMATIC DOCUMENTATION below.

METHODS

base_url

The generated code has the base_url already set as a default value. This method returns (and optionally sets, but only if the API client has not been created yet) the current value of base_url.

api_factory

Returns an API factory object. You probably won't need to call this directly.

    $self->api_factory('Pet'); # returns a SQL::QueryBuilder::WebApi::PetApi instance
    
    $self->pet_api;            # the same

AUTOMATIC DOCUMENTATION

You can print out a summary of the generated API by running the included autodoc script in the bin directory of your generated library. A few output formats are supported:

      Usage: autodoc [OPTION]

-w           wide format (default)
-n           narrow format
-p           POD format 
-H           HTML format 
-m           Markdown format
-h           print this help message
-c           your application class

The -c option allows you to load and inspect your own application. A dummy namespace is used if you don't supply your own class.

LOAD THE MODULES

To load the API packages:

use SQL::QueryBuilder::WebApi::ActiveQueryBuilderApi;

To load the models:

use SQL::QueryBuilder::WebApi::Object::Condition;
use SQL::QueryBuilder::WebApi::Object::ConditionGroup;
use SQL::QueryBuilder::WebApi::Object::HiddenColumn;
use SQL::QueryBuilder::WebApi::Object::Pagination;
use SQL::QueryBuilder::WebApi::Object::QueryColumn;
use SQL::QueryBuilder::WebApi::Object::Sorting;
use SQL::QueryBuilder::WebApi::Object::SqlQuery;
use SQL::QueryBuilder::WebApi::Object::Totals;
use SQL::QueryBuilder::WebApi::Object::Transform;
use SQL::QueryBuilder::WebApi::Object::TransformResult;

GETTING STARTED

Put the Perl SDK under the 'lib' folder in your project directory, then run the following

#!/usr/bin/perl
use lib 'lib';
use strict;
use warnings;
# load the API package
use SQL::QueryBuilder::WebApi::ActiveQueryBuilderApi;

# load the models
use SQL::QueryBuilder::WebApi::Object::Condition;
use SQL::QueryBuilder::WebApi::Object::ConditionGroup;
use SQL::QueryBuilder::WebApi::Object::HiddenColumn;
use SQL::QueryBuilder::WebApi::Object::Pagination;
use SQL::QueryBuilder::WebApi::Object::QueryColumn;
use SQL::QueryBuilder::WebApi::Object::Sorting;
use SQL::QueryBuilder::WebApi::Object::SqlQuery;
use SQL::QueryBuilder::WebApi::Object::Totals;
use SQL::QueryBuilder::WebApi::Object::Transform;
use SQL::QueryBuilder::WebApi::Object::TransformResult;

# for displaying the API response data
use Data::Dumper;

my $api = SQL::QueryBuilder::WebApi::ActiveQueryBuilderApi->new();
my $metadataGuid = 'b3207f4f-b1f4-4dc2-979b-7724ed2d0221';
my $sql = 'Select customer_id, first_name From customer';

my $query = SQL::QueryBuilder::WebApi::Object::SqlQuery->new(); # SqlQuery | Information about SQL query and it's context.
$query->guid( $metadataGuid );
$query->text( $sql );

my $columns = $api->get_query_columns_post(query => $query);
print Dumper($columns);

my $transform = SQL::QueryBuilder::WebApi::Object::Transform->new();
$transform->guid( $metadataGuid );
$transform->sql( $sql );

my $filter = SQL::QueryBuilder::WebApi::Object::ConditionGroup->new();

my $condition = SQL::QueryBuilder::WebApi::Object::Condition->new();
$condition->field('customer_id');
$condition->condition_operator('Greater');
$condition->values( [ '10' ] );

$filter->conditions( [ $condition ] );

my $page = SQL::QueryBuilder::WebApi::Object::Pagination->new();
$page->skip(2);
$page->take(3);

my $order = SQL::QueryBuilder::WebApi::Object::Sorting->new();
$order->field('customer_id');
$order->order('desc');

$transform->filter($filter);
$transform->pagination($page);
$transform->sortings( [ $order ] );

my $result = $api->transform_sql_post(transform => $transform);
print Dumper($result);

DOCUMENTATION FOR API ENDPOINTS

All URIs are relative to https://webapi.activequerybuilder.com

ClassMethodHTTP requestDescription
ActiveQueryBuilderApiget_query_columns_postPOST /getQueryColumns
ActiveQueryBuilderApitransform_sql_postPOST /transformSQL

DOCUMENTATION FOR MODELS

DOCUMENTATION FOR AUTHORIATION

All endpoints do not require authorization.

Source code

Full source code of all clients for Active Query Builder Web API is available on GitHub. Get the source code of javascript here: https://github.com/ActiveDbSoft/webapi-active-query-builder-perl

FAQs

Package last updated on 02 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc