Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Functions

All parameters (if any) are passed into any given engine method as a map. The parameters given in the tables are the keys in the map that will represent the given values.

newPico

Creates a new pico and returns its id. No parameters are given.

ParameterDatatypeRequired
-------------------------------------------
newPico
response = engine:newPico().klog("Response Structure: ")
/*
  Response Structure:
	{
		"id" : <new_pico_id>
	}
*/

Note: newPico does not provide an eci. This function is used in conjunction with engine:createChannel to create a pico with both an id and eci. See wranglerNPE.krl for an example of how to fully create a pico according to a given prototype.


removePico

Disclaimer

removePico does not accept a map, but a single id value as its parameter.

ParameterDatatypeRequired
<id><string>YES
removePico
response = engine:removePico(id).klog("engine:removePico Response Structure: ")//id is just a string variable
/*
 Response Structure:
	undefined
 //engine:removePico(id) does not return anything
*/



newChannel

Creates a new channel for a pico (identified to the engine by the pico_id parameter).

ParameterDatatypeRequired
<pico_id><string>YES
<name><string>YES
<type><string>YES


newChannel
response = engine:newChannel({ "name": "channel_name", "type": "channel_type", "pico_id": id }).klog("Response Structure: ")
/*
 Response Structure:
	{
		"id" : id,
		"name": "channel_name",
		"type": "channel_type"
 	}
*/




removeChannel

Removes a channel whose eci matches the provided eci. This comparison and deletion takes place on the pico with the provided id.

ParameterDatatypeRequired
<pico_id><string>YES
<eci><string>YES
removeChannel
response = engine:removeChannel({"pico_id": id, "eci": eci_of_channel}).klog("Response Structure: ")
/*
 Response Structure:
	undefined
 //engine:removeChannel({"pico_id": id, "eci": eci_of_channel}) does not return anything
*/


registerRuleset

ParameterDatatypeRequired
<url><string>YES
<base><string>YES

The "base" key will have a value that contains the domain name where your krl file is located. ex:  "http://raw.githubusercontent.com"

The "url" key will complete the path appended to the base. ex: "/username/repository1/file.txt"

If the "pico_id" and "rid" keys are provided like in engine:installRuleset, the following directive error is given: {"error" : "registerRuleset expects, pico_id and rid or url+base"}.

Attempting to register a ruleset that is already in existence will pull the ruleset from the given base/url and act as an update action, overwriting the current file with the one from the remote repository.

registerRuleset
response = engine:registerRuleset({"url": url, "base": base}).klog("Response Structure: ")
/*
 Response Structure:
	"myRuleset"
 Simply returns the rulesetID as a string. The rulesetID is the ruleset's name. 
*/


unregisterRuleset(rid)

Disclaimer

unregisterRuleset does not accept a map, but a single ruleset ID (rid) value as its parameter.


Unregisters the ruleset given by the rid. It will throw an error if the ruleset is installed on any picos, or depended on by another ruleset.

ParameterDatatypeRequired
<rid><string>YES

If your filename is myRuleset.krl, then the ruleset id will be "myRuleset".

unregisterRuleset
response = engine:unregisterRuleset("myRuleset").klog("Response Structure: ")
/*
 Response Structure:
	undefined
 //engine:unregisterRuleset("myRuleset") does not return anything
*/


installRuleset( )

Installs ruleset(s) into a pico.  


ParameterDatatypeRequired
<pico_id><string> YES
<rid>string | array

NO

<base><string>NO
<url><string>NO

The "base" key will have a value that contains the domain name where your krl file is located. ex:  "http://raw.githubusercontent.com"

The "url" key will complete the path appended to the base. ex: "/repository1/file.txt"

There are three options provided for a successful install with these parameters:
1) You may provide the "rid" (excluding the "base" and "url" keys) if you know that the ruleset is already registered with the engine.
2) Provide the base and url in their respective parts as described above.
3) Just provide the full url (in the "url" key) where your ruleset is located, leaving the "base" undefined or as an empty string.

Do not provide the "rid" key if you want to retrieve the krl file from a remote repository (just provide the "base" and "url" keys). If you provide the "rid" key at all, this function will assume the ruleset is already registered with the engine and will simply throw an error if it is not found, ignoring the "base" and "url" as if they were not submitted. If the "base" and "url" are provided, then the krl file will be registered to the engine (if not already) and then installed on the pico with the given "pico_id".

intall ruleset
response = engine:installRuleset( { "pico_id": ent:id, "rid": "wrangler" } );
response = engine:installRuleset( { "pico_id": ent:id, "rid": ["wrangler","Pds"] } );
response = engine:installRuleset( { "pico_id": ent:id, "base": <base>, "url": <url> } );
/*
 Response Structure:
	"myRuleset"
 Simply returns the rulesetID as a string. The rulesetID is the ruleset's name. 
*/


engine:uninstallRuleset( ) - Not Implemented yet.

  • No labels