Home Manual Reference Source Test Repository

Instalation Guide

Instalation Guide

You must follow the next steps:

  • Donwload the project sources: git clone http://gitlab.amplia.es/opengate-ux/opengate-javascript-api.git
  • Donwload dependencies: npm install
  • Run web to localhost: gulp

You could be installed some packages before run gulp command.

You will execute the next commands to install the minimal add-ons:

  • npm install -g gulp-cli

The node version what we are using is: v4.4.7 The npm version what we are using is: 3.10.3

We hope that you will enjoy our opengateJS api.

Development Guide

Gulp tasks available

  • clean: Remove dist folder
  • clean-doc: Remove documentation folder
  • generate-doc: Generate javascript documentation by esdoc plugin
  • npm: Invoke clean task and after that compile sources as nodejs dependency
  • bower:Invoke clean task and after that compile sources as browser dependency
  • bower:min:Invoke clean task and after that compile and minimize sources as browser dependency
  • compile: Invoke clean task and after that compile sources as nodejs and browser dependency
  • build: Invoke compile and generate-doc tasks.
  • default: Invoke watch-src
  • watch-src: Listen to any src/ and execute compile** task
  • watch-test-client: Listen to any test/client/ and execute test-client** task
  • test-client: Execute any client test defined into test/client by mocha and phantomJS plugin
  • cucumber: Execute any server test defined into features/*.feature by cucumber plugin

Examples about how to use our OpengateJS

Examples about how to use our OpengateJS

Search into entities data

Search provision devices info

The first that you need obtain is a new Builder instance:

    ogapi.
    devicesSearchBuilder()

If you need information about collected data:

    ogapi.
    devicesSearchBuilder().
    onCollected().....

Or you need information about provisioned data:

    ogapi.
    devicesSearchBuilder().
    onProvisioned().....

Uhmm, If you need all information, provisioned and collected, because you want to be enlightened:

    ogapi.
    devicesSearchBuilder().
    onProvisioned().
    onCollected()....

Well, Now you only want summary information:

// Collected Data
    ogapi.
    devicesSearchBuilder().
    onProvisioned().
    summary()....
// Provisioned Data
    ogapi.
    devicesSearchBuilder().
    onProvisioned().
    summary()....
// Provisioned and Collected Data
    ogapi.
    devicesSearchBuilder().
    onProvisioned().
    summary()....

Now, we can only make the invoke to build method and catch the response

    var builder = 
    ogapi.
    devicesSearchBuilder().
    onProvisioned();
    var search;
    try{
        search = builder.build();
    }catch(builderError){
        console.log(builderError);
    }
    search.
    execute().
    then(function(response,statusCode){
        //Here you could search all you want into response object
    }).
    catch(function(error){
        alert(error);
    })

Search provision subscribers info

Is the same that device info, You only change this:

    ogapi.
    devicesSearchBuilder().

To this:

    ogapi.
    subscribersSearchBuilder().

Search provision subscriptions info

Is the same that device info, You only change this:

    ogapi.
    devicesSearchBuilder().

To this:

    ogapi.
    subscriptionsSearchBuilder().

Search into executions data of a operation

The first that you need obtain is a new Builder instance:

    ogapi.
    executionsSearchBuilder()

If you need select the source about executions data of a operation :

    ogapi.
    executionsSearchBuilder().
    onDevices().....
    // Or
    ogapi.
    executionsSearchBuilder().
    onSubscribers().....
    // Or
    ogapi.
    executionsSearchBuilder().
    onSubscriptions().....
    // Or
    ogapi.
    executionsSearchBuilder().
    onCommunicationsModules().....

Important, You only can select one of this resources. If you select more than one, a exception will be thrown when you invoke build method.

If you need summary information:

    ogapi.
    executionsSearchBuilder().
    onCommunicationsModules().
    summary()...

Now, we can only make the invoke to build method and catch the response

    var builder = 
    ogapi.
    executionsSearchBuilder().
    onCommunicationsModules();
    var search;
    try{
        search = builder.build();
    }catch(builderError){
        console.log(builderError);
    }
    search.
    execute().
    then(function(response,statusCode){
        //Here you could search all you want into response object
    }).
    catch(function(error){
        alert(error);
    })

Search into alarms data

Is the same that execution info of a operation, You only change this:

    ogapi.
    executionsSearchBuilder().

To this:

    ogapi.
    alarmsSearchBuilder().

Search into iot data

Search into datastreams and profiles collections

The first that you need obtain is a new Builder instance:

    var builder = ogapi.
    datastreamsSearchBuilder()

or

    var builder = ogapi.
    profilesSearchBuilder()

If you want you can create a filter to restrict the response much as you want.

    builder.filter(ogapi.newFilterBuilder().and(ogapi.EX.eq('myparam','myvalue')))

Now, we can only make the invoke to build method and catch the response

    var builder = 
    ogapi.
    profilesSearchBuilder().
    .filter(ogapi.newFilterBuilder().and(ogapi.EX.eq('myparam','myvalue')))
    var search;
    try{
        search = builder.build();
    }catch(builderError){
        console.log(builderError);
    }
    search.
    execute().
    then(function(response,statusCode){
        //Here you could search all you want into response object
    }).
    catch(function(error){
        alert(error);
    })

Search into datapoints collections

The first that you need obtain is a new Builder instance:

    var builder = ogapi.
    datapointsSearchBuilder()

If you want you can create a filter to restrict the response much as you want.

    builder.filter(ogapi.newFilterBuilder().and(ogapi.EX.eq('myparam','myvalue')))

or you can use the way filter fluent to make a filter more straightforward

    builder.betweenDates(new Date(),new Date()).withFeed('myFeed').withDeviceId('myDevice')....

Now, we can only make the invoke to build method and catch the response

    var builder = 
    ogapi.
    datapointsSearchBuilder().
    .betweenDates(new Date(),new Date()).withFeed('myFeed').withDeviceId('myDevice');
    var search;
    try{
        search = builder.build();
    }catch(builderError){
        console.log(builderError);
    }
    search.
    execute().
    then(function(response,statusCode){
        //Here you could search all you want into response object
    }).
    catch(function(error){
        alert(error);
    })

Setting timeout in all searches

We can configure the request timeout in all request. How can i do it ?

It is very simple, we must only invoke a withTimeout method. Here there is a example:

    ogapi.
    devicesSearchBuilder().
    withTimeout(2000).....

Then, if timeout is exceeded. The promise throw an exception with a message like this: "Timeout exceeded"

Execute an operation

Here ogapi.operations is where you can find all you need to execute an operation.

At this point ogapi.operations, you have access to:

  • builderByOperationName(operation_name) -> It will return a promise and into then callback you will have the builder as a function argument but if anything gone wrong the catch callback would tell you what happens by error
  • getOperationList() -> It will return an array with available operations

OK I have an operation builder but now. What could i do ?

Might be two kinds of builder:

  • Attend or close alarms
  • Operations defined into user catalog

It is a builder factory, Here will have all operations that the user have available

Examples:

  • ogapi.operations.builderByOperationName('ALARM_CLOSE')
  • ogapi.operations.builderByOperationName('ADMINISTRATIVE_STATUS_CHANGE')

Methods available to attend or close alarms:

  • withNotes()
  • addAlarmId()
  • build()

Methods available to others operations:

  • withNotes()
  • withCallback()
  • withAckTimeout()
  • withDelayedStop()
  • withDelayedStart()
  • withScatteringMaxSpread()
  • withScatteringStrategy()
  • executeImmediately()
  • executeIDLE()
  • executeLater()
  • withTimeout()
  • withRetriesDelay()
  • withRetries()
  • appendEntitiesBy.filter(newFilterBuilder().build())
  • appendEntitiesBy.list()
  • appendEntitiesBy.tag()

How can i add a specific parameter ?

Access:

            var builder = ogapi.operations.builderFactory.newSetClockEquipmentBuilder();
            //Acceso a los parámetros de esta operación
            builder.paramBuilderFactory

The paramBuilderFactory element will have an catalog and it will have inside a list about allowed parameters.
This parameters can be as a simple type, array type, array of simple type, a complex type, etc. Every parameter will have their own builder.

Examples:

  • Simple type with default value builder.paramBuilderFactory.newAdministrativeStatusParamBuilder().buildAndAppend()
  • This parameter have defined an enumeration with allowed values builder.paramBuilderFactory.newChannelParamBuilder().withChannel('channelName'). If channelName is not defined into enumeration, the builder throw an error
  • Array of complex object builder.paramBuilderFactory.newVariableListParamBuilder().addVariableList({'variableName':'nombre','variableValue':'valor'}).addVariableList({'variableName':'nombre','variableValue':'valor'})
  • String array builder.paramBuilderFactory.newApnParamBuilder().addApn('apn1').addApn('apn2').buildAndAppend()

Execute actions on the executions

When you create an operation, it creates a "run" that groups each of the operations per entity that are generated. ogapi.newExecutionActions(execution_id) offers a series of actions to activate, paused and cancel these executions:

Active

ogapi.newExecutionActions(execution_id).active();

We can activate a execution that is in the IDLE or PAUSED state. Once the execution is activated it will go to one of the following states:

  • SCHEDULE if the previous state was IDLE
  • IN_PROGRESS if the previous state was PAUSED or IDLE (if the timing forces the start)

Pause

ogapi.newExecutionActions(execution_id).pause();

We can pause an execution. Once the execution is paused it will go to one of the following states:

  • IDLE if the previous state was SCHEDULE
  • PAUSED if the previous state was IN_PROGRESS

Cancel

ogapi.newExecutionActions(execution_id).cancel();

We can cancel an execution at any time. The status of execution passes through two states: CANCELLING and CANCELLED

References

References

Class Summary

Static Public Class Summary
public

Defined a search over operational status catalogs

public

Defines the builder to execute alarm actions

public

This class contains all alarms actions builders

public

Defines the builder to execute alarm attend operation

public

Defines the builder to execute alarm close operation

public

Defined a search over Alarms

public

Defined a search over mobile phone provider catalog

public

Util used into BaseOperationBuilder to append entities the three different ways.

public

This class allow make get request to area resource into Opengate North API.

public

This is a base object that contains all you can do about Areas.

public

Defined a search over Areas

public

Subscription builder.

public

This extends Search and allow make request to any available resource into Opengate North API.

public

Defined a search over Assets

public

Defines the builder to execute an operation that is into catalog

public

This class generate a builder by a dynamic content about specific parameter to an operation.

public

This is an abstract class, it must be extended to another class that defines the different actions of a specific provision.

public

This is a abstract class, it must be extended to another class that defined the specific search.

public

This is a abstract class, it must be extended to another class that defined the specific search.

public

This class allow set simple values.

public

This builder give you the necessary tools to create a bulk executions using our OpenGate REST

public

This class allow make get request to bulk executions resource into Opengate North API.

public

Searching over all the created bulk process, which are already done or still in progress.

public

This class allow make get request to bulk resource into Opengate North API.

public

Defined a search over bulk entities operations

public

This class allow make get request to certificate resource into Opengate North API.

public

This is a base object that contains all you can do about Bundles.

public

Defined a search over Bundles

public
public
public
public
public

Defines the builder to configure a category of a datamodel.

public

This class allow make get request to certificate resource into Opengate North API.

public

This is a base object that contains all you can do about Certificates.

public

Defined a search over Bundles

public

This class allow make get request to channel resource into Opengate North API.

public

This is a base object that contains all you can do about Bundles.

public

Defined a search over Channels

public

This is a base object that allows the user to create a CommsModule.

public

Defined a search over operational status catalogs

public

This class extends SimpleBuilder to allow set complex values.

public

This is a base object than contains all you can about connector functions catalog

public

This is a base object that contains all you can do about ConnectorFunctions.

public

This class allow make get request to connector functions catalog resource into Opengate North API.

public

This class allow make get request to a connector functions catalog resource into Opengate North API.

public

This class allow make get request to ConnectorFunctions resource into Opengate North API.

public

This class allow make get request to RuleConfigurationsHelper resource into Opengate North API.

public

This class allow make get request to countries catalog resource into Opengate North API.

public

Defined a search over operational status catalogs

public

Csv builder.

public

This is a base object for create a IoT Datamodel

public

This class allow make get request to organization resource into Opengate North API.

public

This is a base object for update and delete a IoT Datamodel

public

Defined a search over Datamodels

public

This is a base object that allows the user to create a Datapoint.

public

Defined a search over Datastreams

public

Defined a search over Executions

public

Defined a search over Executions

public

This is a base object that contains all you can do about Datasets.

public

Defined a search over Areas

public

This is a base object that allows the user to create a Datastream.

public

Defines the builder to configure a datastream of IoT datamodel.

public

Defined a search over Datastreams

public

This is a base object that contains all you can do about Deployment Element.

public

Device builder.

public

This class allow make get request to device provisioned resource into Opengate North API.

public

This is a base object contains methods to send unstructured IoT information to be processed & collected by the platform.

public

This extends Search and allow make request to any available resource into Opengate North API.

public

Defined a search over DevicePlansSearchBuilder

public

Defined a search over Devices

public

This class allow make get request to certificate resource into Opengate North API.

public

This is a base object that contains all you can do about Bundles.

public

Defined a search over Domains

public

Defined a search over Executions

public

This is a base object that contains all you can do about Devices.

public
  • This class allow make get request to entity provisioned resource into Opengate North API.
public

This extends Search and it allow make request to any available resource into /entities resource at Opengate North API

public

This is a base object that allows the user to create a Event.

public

Defines the builder to configure a period of operation.

public

Defines the builder to configure a period of operation.

public

Defined a search over Executions

public

Defined a search over Executions

public
public

Defined a search over Feeds

public

Defined a search over operational status catalogs

public
public

This is a abstract class.

public

This class allow make get request to user resource into Opengate North API.

public

This is a base object that contains all you can do about geocluster.

public

This class allow make get request to user resource into Opengate North API.

public

This is a base object that allows the user to create a Datapoint.

public

This class allow make get request to planner resource into Opengate North API.

public

This is a base object that contains all you can do about Bundles.

public

This class allow make get request to planner resource into Opengate North API.

public

This is a abstract class, it must be extended to another class that defined the backend, it will be used on request to Opengate North API by browser or nodejs server

public

Defined a search over mobile phone provider catalog

public

Defined a search over mobile phone provider catalog

public

Defined a search over mobile phone provider catalog

public

Json builder.

public

Json builder.

public

This is a base object that allows the user to create a Datapoint.

public

This class allow make get request to hardware manufacturers resource into Opengate North API.

public

This class allow make get request to hardware manufacturers resource into Opengate North API.

public

This is a base object that contains all you can do about ManufacturerMedia.

public

This is a base object that contains all you can do about Manufacturers.

public

This is a base object that contains all you can do about Manufacturers.

public

This is a base object that allows the user to create a Datapoint.

public

Defined a search over mobile phone provider catalog

public

This class allow make get request to hardware models resource into Opengate North API.

public

This class allow make get request to hardware models resource into Opengate North API.

public

This is a base object that contains all you can do about ModelMedia.

public

This is a base object that contains all you can do about Models.

public

This is a base object that contains all you can do about Models.

public

This is a wrapper of a Rest api javascript

public

This class allow make get request to planner resource into Opengate North API.

public

This is a base object that contains all you can do about Bundles.

public

This is a base object that contains all you can do about Bundles.

public

This is a abstract class, it must be extended to another class that defined the specific search.

public

This is a abstract class, it must be extended to another class that defined the specific search.

public
public

This class allow make get request to operation resource into Opengate North API.

public

This is a base object that contains all you can do about OperationType.

public

This class allow make get request to OperationType resource into Opengate North API.

public

Defined a search over operationTypes

public

This class allow make get request to OperationType resource into Opengate North API.

public

Defined a search over operational status catalogs

public

This class generates all operations builders by a response to search into catalog/operations

public

Defined a search over executions´s opreations

public

This class allow make get request to organization resource into Opengate North API.

public

This is a base object that contains all you can do about Organizations.

public

Defined a search over organizations

public

This class generates all operation parameters builders by "parameters" attribute that there is into config operation json

public
public
public

This is a base object that contains all you can do about Bundles.

public

This class allow make get request to planner resource into Opengate North API.

public

Defined a search over PlansSearchBuilder

public

This is a base object that allows the user to create a Datapoint.

public

This is a abstract class.

public

This class allow make get request to user resource into Opengate North API.

public

This is a base object that contains all you can do about Provision Processors.

public

Defines the builder to configure a qurating of datastream of IoT datamodel.

public

Defined a search over custom resource and custom filter

public

Defined a search over mobile phone provider catalog

public

This is a base object that contains all you can do about Bundles.

public

This class allow make get request to planner resource into Opengate North API.

public

Defined a search over ruleConfigurationSeverity catalog

public

This is a base object that contains all you can do about RulesConfigurations.

public
public

This class allow make get request to RuleConfigurations resource into Opengate North API.

public

This class allow make get request to RuleConfigurations resource into Opengate North API.

public

This class allow make get request to RuleConfigurationsHelper resource into Opengate North API.

public

Defined a search over ruleMode catalog

public

Defined a search over ruleType catalog

public

Defined a search over Rulse

public

This class allow make get request to planner resource into Opengate North API.

public

This class allow make get request to planner resource into Opengate North API.

public

This extends BaseSearch and allow make request to any available resource into Opengate North API.

public

This is a abstract class.

public

This defined a specific Error that it will be thrown on build method at SearchBuilders

public

This is a abstract class.

public

This extends BaseSearch and allow make request to any available resource into Opengate North API.

public

This extends BaseProvision and contains all you can do about Security.

public
public
public

Defined a search over service group catalogs

public

This class allow set simple values.

public

This is a base object that allows the user to create a Datapoint.

public

This class allow make get request to hardware softwares resource into Opengate North API.

public

This is a base object that contains all you can do about Softwares.

public

Defined a search over Datastreams

public
public

This extends Search and it allow make request to any available resource into static resources for Opengate North API

public

This is a base object that allows the user to create a Datapoint.

public

This is a base object that allows the user to create a Subscription.

public

Subscriber builder.

public

This class allow make get request to subscribers provisioned resource into Opengate North API.

public

Defined a search over Subscribers

public

This is a base object that allows the user to create a Subscription.

public

Subscription builder.

public

This class allow make get request to subscription provisioned resource into Opengate North API.

public

Defined a search over Subscriptions

public

Defined a search over periodic executions´s operations

public

This is a base object that allows the user to create a Datapoint.

public

Subscription builder.

public

This class allow make get request to ticket provisioned resource into Opengate North API.

public

Defined a search over ticket priority catalog

public

Defined a search over ticket severity catalog

public

Defined a search over ticket status catalog

public

Defined a search over Devices

public

Defined a search over timeseries

public

Defined a search over timeseries

public

Defined a search over timeseries

public

This is a base object that contains all you can do about Timeseries.

public

This class allow make get request to TimeseriesFinder resource into Opengate North API.

public

This is a base object that contains all you can do about TimeseriesFunction.

public

This class allow make get request to TimeseriesFunction resource into Opengate North API.

public

This class allow make get request to newTimeseriesFunctionsHelper resource into Opengate North API.

public

Defined a search over operational status catalogs

public

This is a base object that allows the user to create a Datapoint.

public

This class allow make get request to user resource into Opengate North API.

public

This class allow make get request to user resource into Opengate North API.

public

Defined a search over operational status catalogs

public

Defined a search over operational status catalogs

public

Defined a search over Users

public

This extends BaseSearch and allow make request to any available resource into Opengate North API.

public

This class allow make get request to workgroup resource into Opengate North API.

public

This is a base object that contains all you can do about workgroups.

public

This class allow make get request to workgroup relation resource into Opengate North API.

public

This is a base object that contains all you can do about workgroups.

public

Defined a search over Workgroups

public

This class allow make get request to ProvisionProcessors Finder resource into Opengate North API.

Variable Summary

Static Public Variable Summary
public

ACTION values allowed

public

ADDRESS_TYPE_ENUM values allowed

public

ADMINISTRATIVE_STATE_ENUM values allowed

public

ANTENNA_STATUS_ENUM values allowed

public
public
public
public
public
public

BATTERY_CHARGE_LEVEL_STATUS_ENUM values allowed

public

BATTERY_CHARGE_STATUS_ENUM values allowed

public

CONNECTOR_FUNCTION_OPERATIONAL_STATUS values allowed

public

CONNECTOR_FUNCTION_PAYLOAD_TYPES values allowed

public

CONNECTOR_FUNCTION_SOUTH_PROTOCOLS values allowed

public

CONNECTOR_FUNCTION_TYPES values allowed

public
public
public

Global date format.

public

Days values allowed

public

GENERATED_FIELDS: {"ENTITY_OPERATION_HISTORY": *, "ENTITY_OPERATION": *, "MODEL": *, "JOB": *, "SOFTWARE_VERSION": *, "UPDATE_BUNDLE_VERSION": *, "CERTIFICATE": *}

public

IOT_FIELDS: {"DATAPOINTS": *, "DATAMODELS": *, "DATASTREAMS": *, "DEVICE_PART_DEVICE": *, "USER": *, "DOMAIN": *, "AREAS": *, "TASKS": *, "LEGACY_BULK": *, "BULK": *, "RULE": *, "ENTITY_ALARM": *, "GENERAL": *, "EMPTY": *, "OPERATORS": *, "PLANS": *}

public

LEVEL_TREND_ENUM values allowed

public
public
public
public

MIME_TYPES values allowed

public
public
public

MODE_VALIDATORS values allowed.

public

Months values allowed

public

OPERATION values allowed

public

OPTION values allowed

public
public

POWER_SUPPLY_SOURCE_ENUM values allowed

public
public
public
public
public
public
public
public

SOFTWARE_TYPES_ENUM values allowed

public

SOFTWARE_TYPE_ENUM values allowed

public
public
public

TEMPERATURE_STATUS values allowed

public

Global time format.

public
public
public
public
public

TYPES: {"xls": string, "xlsx": string}

public

TYPE values allowed

public

TYPE values allowed

public

TYPE_VALIDATORS values allowed

public
public
public
public

USAGES_ENUM values allowed

public

TYPES_ENUM values allowed

public
public
public