Storm Types

Storm Objects are used as view objects for manipulating data in the Storm Runtime and in the Cortex itself.

boolean

Implements the Storm API for a boolean instance.

bytes

Implements the Storm API for a Bytes object.

bunzip()

Decompress the bytes using bzip2.

Example:

Decompress bytes with bzip2:

$foo = $mybytez.bunzip()
Returns:

Decompressed bytes. The return type is bytes.

bzip()

Compress the bytes using bzip2 and return them.

Example:

Compress bytes with bzip:

$foo = $mybytez.bzip()
Returns:

The bzip2 compressed bytes. The return type is bytes.

decode(encoding=utf8)

Decode bytes to a string.

Args:

encoding (str): The encoding to use.

Returns:

The decoded string. The return type is str.

gunzip()

Decompress the bytes using gzip and return them.

Example:

Decompress bytes with bzip2:

$foo = $mybytez.gunzip()
Returns:

Decompressed bytes. The return type is bytes.

gzip()

Compress the bytes using gzip and return them.

Example:
Compress bytes with gzip::

$foo = $mybytez.gzip()

Returns:

The gzip compressed bytes. The return type is bytes.

json()

Load JSON data from bytes.

Notes:

The bytes must be UTF8, UTF16 or UTF32 encoded.

Example:
Load bytes to a object::

$foo = $mybytez.json()

Returns:

The deserialized object. The return type is prim.

slice(start, end=None)

Slice a subset of bytes from an existing bytes.

Examples:

Slice from index to 1 to 5:

$subbyts = $byts.slice(1,5)

Slice from index 3 to the end of the bytes:

$subbyts = $byts.slice(3)
Args:

start (int): The starting byte index.

end (int): The ending byte index. If not specified, slice to the end.

Returns:

The slice of bytes. The return type is bytes.

unpack(fmt, offset=0)

Unpack structures from bytes using python struct.unpack syntax.

Examples:

# unpack 3 unsigned 16 bit integers in little endian format ($x, $y, $z) = $byts.unpack(“<HHH”)

Args:

fmt (str): A python struck.pack format string.

offset (int): An offset to begin unpacking from.

Returns:

The unpacked primitive values. The return type is list.

dict

Implements the Storm API for a Dictionary object.

list

Implements the Storm API for a List instance.

append(valu)

Append a value to the list.

Args:

valu (any): The item to append to the list.

Returns:

The return type is null.

extend(valu)

Extend a list using another iterable.

Examples:

Populate a list by extending it with to other lists:

$list = $lib.list()

$foo = (f, o, o)
$bar = (b, a, r)

$list.extend($foo)
$list.extend($bar)

// $list is now (f, o, o, b, a, r)
Args:

valu (list): A list or other iterable.

Returns:

The return type is null.

has(valu)

Check it a value is in the list.

Args:

valu (any): The value to check.

Returns:

True if the item is in the list, false otherwise. The return type is boolean.

index(valu)

Return a single field from the list by index.

Args:

valu (int): The list index value.

Returns:

The item present in the list at the index position. The return type is any.

length()

Get the length of the list. This is deprecated; please use .size() instead.

Returns:

The size of the list. The return type is int.

pop()

Pop and return the last entry in the list.

Returns:

The last item from the list. The return type is any.

reverse()

Reverse the order of the list in place

Returns:

The return type is null.

size()

Return the length of the list.

Returns:

The size of the list. The return type is int.

slice(start, end=None)

Get a slice of the list.

Examples:

Slice from index to 1 to 5:

$x=(f, o, o, b, a, r)
$y=$x.slice(1,5)  // (o, o, b, a)

Slice from index 3 to the end of the list:

$y=$x.slice(3)  // (b, a, r)
Args:

start (int): The starting index.

end (int): The ending index. If not specified, slice to the end of the list.

Returns:

The slice of the list. The return type is list.

sort(reverse=False)

Sort the list in place.

Args:

reverse (bool): Sort the list in reverse order.

Returns:

The return type is null.

set

Implements the Storm API for a Set object.

add(*items)

Add a item to the set. Each argument is added to the set.

Args:

*items (any): The items to add to the set.

Returns:

The return type is null.

adds(*items)

Add the contents of a iterable items to the set.

Args:

*items (any): Iterables items to add to the set.

Returns:

The return type is null.

has(item)

Check if a item is a member of the set.

Args:

item (any): The item to check the set for membership.

Returns:

True if the item is in the set, false otherwise. The return type is boolean.

list()

Get a list of the current members of the set.

Returns:

A list containing the members of the set. The return type is list.

rem(*items)

Remove an item from the set.

Args:

*items (any): Items to be removed from the set.

Returns:

The return type is null.

rems(*items)

Remove the contents of a iterable object from the set.

Args:

*items (any): Iterables items to remove from the set.

Returns:

The return type is null.

size()

Get the size of the set.

Returns:

The size of the set. The return type is int.

storm:auth:gate

Implements the Storm API for an AuthGate.

iden

The iden of the AuthGate.

Returns:

The type is str.

roles

The role idens which are a member of the Authgate.

Returns:

The type is list.

type

The type of the AuthGate.

Returns:

The type is str.

users

The user idens which are a member of the Authgate.

Returns:

The type is list.

storm:auth:role

Implements the Storm API for a Role.

addRule(rule, gateiden=None)

Add a rule to the Role

Args:

rule (list): The rule tuple to added to the Role.

gateiden (str): The gate iden used for the rule.

Returns:

The return type is null.

delRule(rule, gateiden=None)

Remove a rule from the Role.

Args:

rule (list): The rule tuple to removed from the Role.

gateiden (str): The gate iden used for the rule.

Returns:

The return type is null.

get(name)

Get a arbitrary property from the Role definition.

Args:

name (str): The name of the property to return.

Returns:

The requested value. The return type is prim.

iden

The Role iden.

Returns:

The type is str.

name

A roles name. This can also be used to set the role name.

Example:

Change a roles name:

$role=$lib.auth.roles.byname(analyst) $role.name=superheroes
Returns:

The return type is str. When this is used to set the value, it does not have a return type.

setRules(rules, gateiden=None)

Replace the rules on the Role with new rules.

Args:

rules (list): A list of rules to set on the Role.

gateiden (str): Ahe gate iden used for the rules.

Returns:

The return type is null.

storm:auth:user

Implements the Storm API for a User.

addRule(rule, gateiden=None)

Add a rule to the User.

Args:

rule (list): The rule tuple to add to the User.

gateiden (str): The gate iden used for the rule.

Returns:

The return type is null.

allowed(permname, gateiden=None, default=False)

Check if the user has a given permission.

Args:

permname (str): The permission string to check.

gateiden (str): The authgate iden.

default (boolean): The default value.

Returns:

True if the rule is allowed, False otherwise. The return type is boolean.

delRule(rule, gateiden=None)

Remove a rule from the User.

Args:

rule (list): The rule tuple to removed from the User.

gateiden (str): The gate iden used for the rule.

Returns:

The return type is null.

email

A users email. This can also be used to set the users email.

Example:

Change a users email address:

$user=$lib.auth.users.byname(bob) $user.email="[email protected]"
Returns:

The return type may be one of the following: str, null. When this is used to set the value, it does not have a return type.

get(name)

Get a arbitrary property from the User definition.

Args:

name (str): The name of the property to return.

Returns:

The requested value. The return type is prim.

grant(iden)

Grant a Role to the User.

Args:

iden (str): The iden of the Role.

Returns:

The return type is null.

iden

The User iden.

Returns:

The type is str.

name

A users name. This can also be used to set a users name.

Example:

Change a users name:

$user=$lib.auth.users.byname(bob) $user.name=robert
Returns:

The return type is str. When this is used to set the value, it does not have a return type.

notify(mesgtype, mesgdata)

Send an arbitrary user notification.

Args:

mesgtype (str): The notfication type.

mesgdata (dict): The notification data.

Returns:

The return type is null.

revoke(iden)

Remove a Role from the User

Args:

iden (str): The iden of the Role.

Returns:

The return type is null.

roles()

Get the Roles for the User.

Returns:

A list of storm:auth:roles with the user is a member of. The return type is list.

setAdmin(admin, gateiden=None)

Set the Admin flag for the user.

Args:

admin (boolean): True to make the User an admin, false to remove their admin status.

gateiden (str): The gate iden used for the operation.

Returns:

The return type is null.

setEmail(email)

Set the email address of the User.

Args:

email (str): The email address to set for the User.

Returns:

The return type is null.

setLocked(locked)

Set the locked status for a user.

Args:

locked (boolean): True to lock the user, false to unlock them.

Returns:

The return type is null.

setPasswd(passwd)

Set the Users password.

Args:

passwd (str): The new password for the user. This is best passed into the runtime as a variable.

Returns:

The return type is null.

setRoles(idens)

Replace all the Roles of the User with a new list of roles.

Notes:

The roleiden for the “all” role must be present in the new list of roles. This replaces all existing roles that the user has with the new roles.

Args:

idens (list): The idens to of the Role.

Returns:

The return type is null.

setRules(rules, gateiden=None)

Replace the rules on the User with new rules.

Args:

rules (list): A list of rule tuples.

gateiden (str): The gate iden used for the rules.

Returns:

The return type is null.

tell(text)

Send a tell notification to a user.

Args:

text (str): The text of the message to send.

Returns:

The return type is null.

storm:auth:user:json

Implements per-user JSON storage.

del(path, prop=None)

Delete a stored JSON object or object property for the user.

Args:

path (str|list): A path string or list of path parts.

prop (str|list): A property name or list of name parts.

Returns:

True if the del operation was successful. The return type is boolean.

get(path, prop=None)

Return a stored JSON object or object property for the user.

Args:

path (str|list): A path string or list of path parts.

prop (str|list): A property name or list of name parts.

Returns:

The previously stored value or $lib.null The return type is prim.

iter(path=None)

Yield (<path>, <valu>) tuples for the users JSON objects.

Args:

path (str|list): A path string or list of path parts.

Yields:

(<path>, <item>) tuples. The return type is list.

set(path, valu, prop=None)

Set a JSON object or object property for the user.

Args:

path (str|list): A path string or list of path elements.

valu (prim): The value to set as the JSON object or object property.

prop (str|list): A property name or list of name parts.

Returns:

True if the set operation was successful. The return type is boolean.

storm:cmdopts

A dictionary like object that holds a reference to a command options namespace. ( This allows late-evaluation of command arguments rather than forcing capture )

storm:cronjob

Implements the Storm api for a cronjob instance.

iden

The iden of the Cron Job.

Returns:

The type is str.

pack()

Get the Cronjob definition.

Returns:

The definition. The return type is dict.

pprint()

Get a dictionary containing user friendly strings for printing the CronJob.

Returns:

A dictionary containing structured data about a cronjob for display purposes. The return type is dict.

set(name, valu)

Set an editable field in the cron job definition.

Example:

Change the name of a cron job:

$lib.cron.get($iden).set(name, "foo bar cron job")
Args:

name (str): The name of the field being set

valu (any): The value to set on the definition.

Returns:

The storm:cronjob The return type is storm:cronjob.

storm:hive:dict

A Storm Primitive representing a HiveDict.

get(name, default=None)

Get the named value from the HiveDict.

Args:

name (str): The name of the value.

default (prim): The default value to return if the name is not set.

Returns:

The requested value. The return type is prim.

list()

List the keys and values in the HiveDict.

Returns:

A list of tuples containing key, value pairs. The return type is list.

pop(name, default=None)

Remove a value out of the HiveDict.

Args:

name (str): The name of the value.

default (prim): The default value to return if the name is not set.

Returns:

The requested value. The return type is prim.

set(name, valu)

Set a value in the HiveDict.

Args:

name (str): The name of the value to set

valu (prim): The value to store in the HiveDict

Returns:

Old value of the dictionary if the value was previously set, or none. The return type may be one of the following: null, prim.

storm:http:resp

Implements the Storm API for a HTTP response.

body

The raw HTTP response body as bytes.

Returns:

The type is bytes.

code

The HTTP status code. It is -1 if an exception occurred.

Returns:

The type is int.

err

Tufo of the error type and information if an exception occurred.

Returns:

The type is list.

headers

The HTTP Response headers.

Returns:

The type is dict.

json()

Get the JSON deserialized response.

Returns:

The return type is prim.

msgpack()

Yield the msgpack deserialized objects.

Yields:

Unpacked values. The return type is prim.

storm:http:socket

Implements the Storm API for a Websocket.

rx(timeout=None)

Receive a message from the web socket.

Args:

timeout (int): The timeout to wait for

Returns:

An ($ok, $valu) tuple. The return type is list.

tx(mesg)

Transmit a message over the web socket.

Args:

mesg (dict): A JSON compatible message.

Returns:

An ($ok, $valu) tuple. The return type is list.

storm:imap:server

An IMAP server for retrieving email messages.

delete(uid_set)

Mark an RFC2060 UID message as deleted and expunge the mailbox.

The command uses the +FLAGS.SILENT command and applies the Deleted flag. The actual behavior of these commands are mailbox configuration dependent.

Examples:

Mark a single message as deleted and expunge:

($ok, $valu) = $server.delete("8182")

Mark ranges of messages as deleted and expunge:

($ok, $valu) = $server.delete("1:3,6:9")
Args:

uid_set (str): The UID message set to apply the flag to.

Returns:

An ($ok, $valu) tuple. The return type is list.

fetch(uid)

Fetch a message by UID in RFC822 format.

The message is saved to the Axon, and a file:bytes node is returned.

Examples:

Fetch a message, save to the Axon, and yield file:bytes node:

yield $server.fetch("8182")
Args:

uid (str): The single message UID.

Returns:

The file:bytes node representing the message. The return type is storm:node.

list(reference_name=””, pattern=*)

List mailbox names.

By default this method uses a reference_name and pattern to return all mailboxes from the root.

Args:

reference_name (str): The mailbox reference name.

pattern (str): The pattern to filter by.

Returns:

An ($ok, $valu) tuple where $valu is a list of names if $ok=True. The return type is list.

login(user, passwd)

Login to the IMAP server.

Args:

user (str): The username to login with.

passwd (str): The password to login with.

Returns:

An ($ok, $valu) tuple. The return type is list.

markSeen(uid_set)

Mark messages as seen by an RFC2060 UID message set.

The command uses the +FLAGS.SILENT command and applies the Seen flag.

Examples:

Mark a single messsage as seen:

($ok, $valu) = $server.markSeen("8182")

Mark ranges of messages as seen:

($ok, $valu) = $server.markSeen("1:3,6:9")
Args:

uid_set (str): The UID message set to apply the flag to.

Returns:

An ($ok, $valu) tuple. The return type is list.

search(*args)

Search for messages using RFC2060 syntax.

Examples:

Retrieve all messages:

($ok, $uids) = $server.search("ALL")

Search by FROM and SINCE:

($ok, $uids) = $server.search("FROM", "[email protected]", "SINCE", "01-Oct-2021")

Search by a subject substring:

($ok, $uids) = $search.search("HEADER", "Subject", "An email subject")
Args:

*args (str): A set of search criteria to use.

Returns:

An ($ok, $valu) tuple, where $valu is a list of UIDs if $ok=True. The return type is list.

select(mailbox=INBOX)

Select a mailbox to use in subsequent commands.

Args:

mailbox (str): The mailbox name to select.

Returns:

An ($ok, $valu) tuple. The return type is list.

storm:json:schema

A JsonSchema validation object for use in validating data structures in Storm.

schema()

The schema belonging to this object.

Returns:

A copy of the schema used for this object. The return type is dict.

validate(item)

Validate a structure against the Json Schema

Args:

item (prim): A JSON structure to validate (dict, list, etc…)

Returns:

An ($ok, $valu) tuple. If $ok is True, then $valu should be used as the validated data structure. If $ok is False, $valu is a dictionary with a “mesg” key. The return type is list.

storm:layer

Implements the Storm api for a layer instance.

addPull(url, offs=0)

Configure the layer to pull edits from a remote layer/feed.

Args:

url (str): The telepath URL to a layer/feed.

offs (int): The offset to begin from.

Returns:

Dictionary containing the pull definition. The return type is dict.

addPush(url, offs=0)

Configure the layer to push edits to a remote layer/feed.

Args:

url (str): A telepath URL of the target layer/feed.

offs (int): The local layer offset to begin pushing from

Returns:

Dictionary containing the push definition. The return type is dict.

delPull(iden)

Remove a pull config from the layer.

Args:

iden (str): The iden of the push config to remove.

Returns:

The return type is null.

delPush(iden)

Remove a push config from the layer.

Args:

iden (str): The iden of the push config to remove.

Returns:

The return type is null.

edits(offs=0, wait=True, size=None)

Yield (offs, nodeedits) tuples from the given offset.

Args:

offs (int): Offset to start getting nodeedits from the layer at.

wait (boolean): If true, wait for new edits, otherwise exit the generator when there are no more edits.

size (int): The maximum number of nodeedits to yield.

Yields:

Yields offset, nodeedit tuples from a given offset. The return type is list.

get(name, defv=None)

Get a arbitrary value in the Layer definition.

Args:

name (str): Name of the value to get.

defv (prim): The default value returned if the name is not set in the Layer.

Returns:

The value requested or the default value. The return type is prim.

getFormCounts()

Get the formcounts for the Layer.

Example:

Get the formcounts for the current Layer:

$counts = $lib.layer.get().getFormCounts()
Returns:

Dictionary containing form names and the count of the nodes in the Layer. The return type is dict.

getMirrorStatus()

Return a dictionary of the mirror synchronization status for the layer.

Returns:

An info dictionary describing mirror sync status. The return type is dict.

getPropCount(propname, maxsize=None)

Get the number of property rows in the layer for the given full form or property name.

Args:

propname (str): The property or form name to look up.

maxsize (int): The maximum number of rows to look up.

Returns:

The count of rows. The return type is int.

getStorNode(nodeid)

Retrieve the raw storage node for the specified node id.

Args:

nodeid (str): The hex string of the node id.

Returns:

The storage node dictionary. The return type is dict.

getStorNodes()

Get buid, sode tuples representing the data stored in the layer.

Notes:

The storage nodes represent only the data stored in the layer and may not represent whole nodes.

Yields:

Tuple of buid, sode values. The return type is list.

getTagCount(tagname, formname=None)

Return the number of tag rows in the layer for the given tag and optional form.

Examples:

Get the number of inet:ipv4 nodes with the $foo.bar tag:

$count = $lib.layer.get().getTagCount(foo.bar, formname=inet:ipv4)
Args:

tagname (str): The name of the tag to look up.

formname (str): The form to constrain the look up by.

Returns:

The count of tag rows. The return type is int.

iden

The iden of the Layer.

Returns:

The type is str.

liftByProp(propname, propvalu=None, propcmpr==)

Lift and yield nodes with the property and optional value set within the layer.

Example:

Yield all nodes with the property ou:org:name set in the top layer:

yield $lib.layer.get().liftByProp(ou:org:name)

Yield all nodes with the property ou:org:name=woot in the top layer:

yield $lib.layer.get().liftByProp(ou:org:name, woot)

Yield all nodes with the property ou:org:name^=woot in the top layer:

yield $lib.layer.get().liftByProp(ou:org:name, woot, "^=")
Args:

propname (str): The full property name to lift by.

propvalu (obj): The value for the property.

propcmpr (str): The comparison operation to use on the value.

Yields:

Yields nodes. The return type is storm:node.

liftByTag(tagname, formname=None)

Lift and yield nodes with the tag set within the layer.

Example:

Yield all nodes with the tag #foo set in the layer:

yield $lib.layer.get().liftByTag(foo)

Yield all inet:fqdn with the tag #foo set in the layer:

yield $lib.layer.get().liftByTag(foo, inet:fqdn)
Args:

tagname (str): The tag name to lift by.

formname (str): The optional form to lift.

Yields:

Yields nodes. The return type is storm:node.

pack()

Get the Layer definition.

Returns:

Dictionary containing the Layer definition. The return type is dict.

repr()

Get a string representation of the Layer.

Returns:

A string that can be printed, representing a Layer. The return type is str.

set(name, valu)

Set a arbitrary value in the Layer definition.

Args:

name (str): The name to set.

valu (any): The value to set.

Returns:

The return type is null.

verify(config=None)

Verify consistency between the node storage and indexes in the given layer.

Example:

Get all messages about consistency issues in the default layer:

for $mesg in $lib.layer.get().verify() {
    $lib.print($mesg)
}
Notes:

The config format argument and message format yielded by this API is considered BETA and may be subject to change! The formats will be documented when the convention stabilizes.

Args:

config (dict): The scan config to use (default all enabled).

Yields:

Yields messages describing any index inconsistencies. The return type is list.

storm:model:form

Implements the Storm API for a Form.

name

The name of the Form

Returns:

The type is str.

prop(name)

Get a Property on the Form

Args:

name (str): The property to retrieve.

Returns:

The storm:model:property instance if the property if present on the form or null. The return type may be one of the following: storm:model:property, null.

type

Get the Type for the form.

Returns:

The return type is storm:model:type.

storm:model:property

Implements the Storm API for a Property.

form

Get the Form for the Property.

Returns:

The return type may be one of the following: storm:model:form, null.

full

The full name of the Property.

Returns:

The type is str.

name

The short name of the Property.

Returns:

The type is str.

type

Get the Type for the Property.

Returns:

The return type is storm:model:type.

storm:model:tagprop

Implements the Storm API for a Tag Property.

name

The name of the Tag Property.

Returns:

The type is str.

type

Get the Type for the Tag Property.

Returns:

The return type is storm:model:type.

storm:model:type

A Storm types wrapper around a lib.types.Type

name

The name of the Type.

Returns:

The type is str.

norm(valu)

Get the norm and info for the Type.

Args:

valu (any): The value to norm.

Returns:

A tuple of the normed value and its information dictionary. The return type is list.

repr(valu)

Get the repr of a value for the Type.

Args:

valu (any): The value to get the repr of.

Returns:

The string form of the value as represented by the type. The return type is str.

stortype

The storetype of the Type.

Returns:

The type is int.

storm:node

Implements the Storm api for a node instance.

addEdge(verb, iden)

Add a light-weight edge.

Args:

verb (str): The edge verb to add.

iden (str): The node id of the destination node.

Returns:

The return type is null.

delEdge(verb, iden)

Remove a light-weight edge.

Args:

verb (str): The edge verb to remove.

iden (str): The node id of the destination node to remove.

Returns:

The return type is null.

edges(verb=None, reverse=False)

Yields the (verb, iden) tuples for this nodes edges.

Args:

verb (str): If provided, only return edges with this verb.

reverse (boolean): If true, yield edges with this node as the dest rather than source.

Yields:

A tuple of (verb, iden) values for this nodes edges. The return type is list.

form()

Get the form of the Node.

Returns:

The form of the Node. The return type is str.

getByLayer()

Return a dict you can use to lookup which props/tags came from which layers.

Returns:

property / tag lookup dictionary. The return type is dict.

getStorNodes()

Return a list of “storage nodes” which were fused from the layers to make this node.

Returns:

List of storage node objects. The return type is list.

globtags(glob)

Get a list of the tag components from a Node which match a tag glob expression.

Args:

glob (str): The glob expression to match.

Returns:

The components of tags which match the wildcard component of a glob expression. The return type is list.

iden()

Get the iden of the Node.

Returns:

The nodes iden. The return type is str.

isform(name)

Check if a Node is a given form.

Args:

name (str): The form to compare the Node against.

Returns:

True if the form matches, false otherwise. The return type is boolean.

ndef()

Get the form and primary property of the Node.

Returns:

A tuple of the form and primary property. The return type is list.

pack(dorepr=False)

Return the serializable/packed version of the Node.

Args:

dorepr (boolean): Include repr information for human readable versions of properties.

Returns:

A tuple containing the ndef and property bag of the node. The return type is list.

repr(name=None, defv=None)

Get the repr for the primary property or secondary property of a Node.

Args:

name (str): The name of the secondary property to get the repr for.

defv (str): The default value to return if the secondary property does not exist

Returns:

The string representation of the requested value. The return type is str.

tags(glob=None, leaf=False)

Get a list of the tags on the Node.

Notes:

When providing a glob argument, the following rules are used. A single asterisk(*) will replace exactly one dot-delimited component of a tag. A double asterisk(**) will replace one or more of any character.

Args:

glob (str): A tag glob expression. If this is provided, only tags which match the expression are returned.

leaf (bool): If true, only leaf tags are included in the returned tags.

Returns:

A list of tags on the node. If a glob match is provided, only matching tags are returned. The return type is list.

value()

Get the value of the primary property of the Node.

Returns:

The primary property. The return type is prim.

storm:node:data

A Storm Primitive representing the NodeData stored for a Node.

cacheget(name, asof=now)

Retrieve data stored with cacheset() if it was stored more recently than the asof argument.

Args:

name (str): The name of the data to load.

asof (time): The max cache age.

Returns:

The cached value or null. The return type is prim.

cacheset(name, valu)

Set a node data value with an envelope that tracks time for cache use.

Args:

name (str): The name of the data to set.

valu (prim): The data to store.

Returns:

The return type is null.

get(name)

Get the Node data for a given name for the Node.

Args:

name (str): Name of the data to get.

Returns:

The stored node data. The return type is prim.

has(name)

Check if the Node data has the given key set on it

Args:

name (str): Name of the data to check for.

Returns:

True if the key is found, otherwise false. The return type is boolean.

list()

Get a list of the Node data names on the Node.

Returns:

List of the names of values stored on the node. The return type is list.

load(name)

Load the Node data onto the Node so that the Node data is packed and returned by the runtime.

Args:

name (str): The name of the data to load.

Returns:

The return type is null.

pop(name)

Pop (remove) a the Node data from the Node.

Args:

name (str): The name of the data to remove from the node.

Returns:

The data removed. The return type is prim.

set(name, valu)

Set the Node data for a given name on the Node.

Args:

name (str): The name of the data.

valu (prim): The data to store.

Returns:

The return type is null.

storm:node:path:meta

Put the storm deref/setitem/iter convention on top of path meta information.

storm:node:path:vars

Put the storm deref/setitem/iter convention on top of path variables.

storm:node:props

A Storm Primitive representing the properties on a Node.

get(name)

Get a specific property value by name.

Args:

name (str): The name of the property to return.

Returns:

The requested value. The return type is prim.

list()

List the properties and their values from the $node.

Returns:

A list of (name, value) tuples. The return type is list.

set(prop, valu)

Set a specific property value by name.

Args:

prop (str): The name of the property to set.

valu (prim): The value to set the property to.

Returns:

The set value. The return type is prim.

storm:oauth:v1:client

A client for doing OAuth Authentication from Storm.

sign(baseurl, method=GET, headers=None, params=None, body=None)

,

Sign an OAuth request to a particular URL.

Args:

baseurl (str): The base url to sign and query.

method (dict): The HTTP Method to use as part of signing.

headers (dict): Optional headers used for signing. Can override the “Content-Type” header if the signature type is set to SIG_BODY

params (dict): Optional query parameters to pass to url construction and/or signing.

body (bytes): Optional HTTP body to pass to request signing.

Returns:

A 3-element tuple of ($url, $headers, $body). The OAuth signature elements will be embedded in the element specified when constructing the client. The return type is list.

storm:path

Implements the Storm API for the Path object.

idens()

The list of Node idens which this Path has been forked from during pivot operations.

Returns:

A list of node idens. The return type is list.

listvars()

List variables available in the path of a storm query.

Returns:

List of tuples containing the name and value of path variables. The return type is list.

meta

The PathMeta object for the Path.

Returns:

The type is storm:node:path:meta.

vars

The PathVars object for the Path.

Returns:

The type is storm:node:path:vars.

storm:pipe

A Storm Pipe provides fast ephemeral queues.

put(item)

Add a single item to the Pipe.

Args:

item (any): An object to add to the Pipe.

Returns:

The return type is null.

puts(items)

Add a list of items to the Pipe.

Args:

items (list): A list of items to add.

Returns:

The return type is null.

size()

Retrieve the number of items in the Pipe.

Returns:

The number of items in the Pipe. The return type is int.

slice(size=1000)

Return a list of up to size items from the Pipe.

Args:

size (int): The max number of items to return.

Returns:

A list of at least 1 item from the Pipe. The return type is list.

slices(size=1000)

Yield lists of up to size items from the Pipe.

Notes:

The loop will exit when the Pipe is closed and empty.

Examples:

Operation on slices from a pipe one at a time:

for $slice in $pipe.slices(1000) {
    for $item in $slice { $dostuff($item) }
}

Operate on slices from a pipe in bulk:

for $slice in $pipe.slices(1000) {
    $dostuff_batch($slice)
}
Args:

size (int): The max number of items to yield per slice.

Yields:

Yields objects from the Pipe. The return type is any.

storm:project

Implements the Storm API for Project objects, which are used for managing a scrum style project in the Cortex

epics

A storm:project:epics object that contains the epics associated with the given project.

Returns:

The return type is storm:project:epics.

name

The name of the project. This can also be used to set the name of the project.

Returns:

The return type may be one of the following: str, null. When this is used to set the value, it does not have a return type.

sprints

A storm:project:sprints object that contains the sprints associated with the given project.

Returns:

The return type is storm:project:sprints.

tickets

A storm:project:tickets object that contains the tickets associated with the given project.

Returns:

The return type is storm:project:tickets.

storm:project:epic

Implements the Storm API for a ProjectEpic

name

The name of the Epic. This can be used to set the name as well.

Returns:

The return type may be one of the following: str, null. When this is used to set the value, it does not have a return type.

storm:project:epics

Implements the Storm API for ProjectEpics objects, which are collections of ProjectEpic objects associated with a particular Project

add(name)

Add an epic.

Args:

name (str): The name for the new ProjectEpic.

Returns:

The newly created storm:project:epic object The return type is storm:project:epic.

del(name)

Delete an epic by name.

Args:

name (str): The name of the ProjectEpic to delete.

Returns:

True if the ProjectEpic can be found and deleted, otherwise False The return type is boolean.

get(name)

Get an epic by name.

Args:

name (str): The name (or iden) of the ProjectEpic to get.

Returns:

The storm:project:epic object The return type is storm:project:epic.

storm:project:sprint

Implements the Storm API for a ProjectSprint

desc

A description of the sprint. This can also be used to set the description.

Returns:

The return type may be one of the following: str, null. When this is used to set the value, it does not have a return type.

name

The name of the sprint. This can also be used to set the name.

Returns:

The return type may be one of the following: str, null. When this is used to set the value, it does not have a return type.

status

The status of the sprint. This can also be used to set the status.

Returns:

The return type may be one of the following: int, null. When this is used to set the value, it does not have a return type.

tickets

Yields out the tickets associated with the given sprint (no call needed).

Returns:

The return type is generator.

storm:project:sprints

Implements the Storm API for ProjectSprints objects, which are collections of sprints associated with a single project

add(name, period=None)

Add a sprint.

Args:

name (str): The name for the new ProjectSprint.

period (ival): The time interval the ProjectSprint runs for

Returns:

The newly created storm:project:sprint object The return type is storm:project:sprint.

del(name)

Delete a sprint by name.

Args:

name (str): The name of the Sprint to delete.

Returns:

True if the ProjectSprint can be found and deleted, otherwise False The return type is boolean.

get(name)

Get a sprint by name.

Args:

name (str): The name (or iden) of the ProjectSprint to get.

Returns:

The storm:project:sprint object The return type is storm:project:sprint.

storm:project:ticket

Implements the Storm API for a ProjectTicket.

assignee

The user the ticket is assigned to. This can be used to set the assignee of the ticket.

Returns:

The return type may be one of the following: int, null. When this is used to set the value, it does not have a return type.

comments

A storm:project:ticket:comments object that contains comments associated with the given ticket.

Returns:

The return type is storm:project:ticket:comments.

desc

A description of the ticket. This can be used to set the description.

Returns:

The return type may be one of the following: str, null. When this is used to set the value, it does not have a return type.

epic

The epic associated with the ticket. This can be used to set the epic.

Returns:

The return type may be one of the following: str, null. When this is used to set the value, it does not have a return type.

name

The name of the ticket. This can be used to set the name of the ticket.

Returns:

The return type may be one of the following: str, null. When this is used to set the value, it does not have a return type.

priority

An integer value from the enums [0, 10, 20, 30, 40, 50] of the priority of the ticket. This can be used to set the priority of the ticket.

Returns:

The return type may be one of the following: int, null. When this is used to set the value, it does not have a return type.

sprint

The sprint the ticket is in. This can be used to set the sprint this ticket is in.

Returns:

The return type may be one of the following: int, null. When this is used to set the value, it does not have a return type.

status

The status of the ticket. This can be used to set the status of the ticket.

Returns:

The return type may be one of the following: int, null. When this is used to set the value, it does not have a return type.

storm:project:ticket:comment

Implements the Storm API for a ProjectTicketComment

del()

Delete the comment.

Returns:

True if the ProjectTicketComment was deleted The return type is boolean.

text

The comment text. This can be used to set the text as well.

Returns:

The return type may be one of the following: str, null. When this is used to set the value, it does not have a return type.

storm:project:ticket:comments

Implements the Storm API for ProjectTicketComments objects, which are collections of comments associated with a ticket.

add(text)

Add a comment to the ticket.

Args:

text (str): The text for the new ProjectTicketComment.

Returns:

The newly created storm:project:ticketcomment object The return type is storm:project:ticket:comment.

get(guid)

Get a ticket comment by guid.

Args:

guid (str): The guid of the ProjectTicketComment to get.

Returns:

The storm:project:ticket:comment object The return type is storm:project:ticket:comment.

storm:project:tickets

Implements the Storm API for ProjectTickets objects, which are collections of tickets associated with a project

add(name, desc=)

Add a ticket.

Args:

name (str): The name for the new ProjectTicket.

desc (str): A description of the new ticket

Returns:

The newly created storm:project:ticket object The return type is storm:project:ticket.

del(name)

Delete a sprint by name.

Args:

name (str): The name of the ProjectTicket to delete.

Returns:

True if the ProjectTicket can be found and deleted, otherwise False The return type is boolean.

get(name)

Get a ticket by name.

Args:

name (str): The name (or iden) of the ProjectTicket to get.

Returns:

The storm:project:ticket object The return type is storm:project:ticket.

storm:proxy

Implements the Storm API for a Telepath proxy.

These can be created via $lib.telepath.open(). Storm Service objects are also Telepath proxy objects.

Methods called off of these objects are executed like regular Telepath RMI calls.

An example of calling a method which returns data:

$prox = $lib.telepath.open($url)
$result = $prox.doWork($data)
return ( $result )

An example of calling a method which is a generator:

$prox = $lib.telepath.open($url)
for $item in = $prox.genrStuff($data) {
    $doStuff($item)
}

storm:query

A storm primitive representing an embedded query.

exec()

Execute the Query in a sub-runtime.

Notes:

The .exec() method can return a value if the Storm query contains a return( ... ) statement in it.

Returns:

A value specified with a return statement, or none. The return type may be one of the following: null, any.

size(limit=1000)

Execute the Query in a sub-runtime and return the number of nodes yielded.

Args:

limit (int): Limit the maximum number of nodes produced by the query.

Returns:

The number of nodes yielded by the query. The return type is int.

storm:queue

A StormLib API instance of a named channel in the Cortex multiqueue.

cull(offs)

Remove items from the queue up to, and including, the offset.

Args:

offs (int): The offset which to cull records from the queue.

Returns:

The return type is null.

get(offs=0, cull=True, wait=True)

Get a particular item from the Queue.

Args:

offs (int): The offset to retrieve an item from.

cull (boolean): Culls items up to, but not including, the specified offset.

wait (boolean): Wait for the offset to be available before returning the item.

Returns:

A tuple of the offset and the item from the queue. If wait is false and the offset is not present, null is returned. The return type is list.

gets(offs=0, wait=True, cull=False, size=None)

Get multiple items from the Queue as a iterator.

Args:

offs (int): The offset to retrieve an items from.

wait (boolean): Wait for the offset to be available before returning the item.

cull (boolean): Culls items up to, but not including, the specified offset.

size (int): The maximum number of items to yield

Yields:

Yields tuples of the offset and item. The return type is list.

name

The name of the Queue.

Returns:

The type is str.

pop(offs=None, wait=False)

Pop a item from the Queue at a specific offset.

Args:

offs (int): Offset to pop the item from. If not specified, the first item in the queue will be popped.

wait (boolean): Wait for an item to be available to pop.

Returns:

The offset and item popped from the queue. If there is no item at the offset or the queue is empty and wait is false, it returns null. The return type is list.

put(item)

Put an item into the queue.

Args:

item (prim): The item being put into the queue.

Returns:

The return type is null.

puts(items)

Put multiple items into the Queue.

Args:

items (list): The items to put into the Queue.

Returns:

The return type is null.

size()

Get the number of items in the Queue.

Returns:

The number of items in the Queue. The return type is int.

storm:smtp:message

An SMTP message to compose and send.

headers

A dictionary of email header values.

Returns:

The type is dict.

html

The HTML body of the email message. This can also be used to set an HTML body in the message.

Returns:

The return type is str. When this is used to set the value, it does not have a return type.

recipients

An array of RCPT TO email addresses.

Returns:

The type is list.

send(host, port=25, user=None, passwd=None, usetls=False, starttls=False, timeout=60)

Transmit a message over the web socket.

Args:

host (str): The hostname or IP address of the SMTP server.

port (int): The port that the SMTP server is listening on.

user (str): The user name to use authenticating to the SMTP server.

passwd (str): The password to use authenticating to the SMTP server.

usetls (bool): Initiate a TLS connection to the SMTP server.

starttls (bool): Use the STARTTLS directive with the SMTP server.

timeout (int): The timeout (in seconds) to wait for message delivery.

Returns:

An ($ok, $valu) tuple. The return type is list.

sender

The inet:email to use in the MAIL FROM request. This can also be used to set the sender for the message.

Returns:

The return type is str. When this is used to set the value, it does not have a return type.

text

The text body of the email message. This can also be used to set the body of the message.

Returns:

The return type is str. When this is used to set the value, it does not have a return type.

storm:stat:tally

A tally object.

An example of using it:

$tally = $lib.stats.tally()

$tally.inc(foo)

for $name, $total in $tally {
    $doStuff($name, $total)
}

get(name)

Get the value of a given counter.

Args:

name (str): The name of the counter to get.

Returns:

The value of the counter, or 0 if the counter does not exist. The return type is int.

inc(name, valu=1)

Increment a given counter.

Args:

name (str): The name of the counter to increment.

valu (int): The value to increment the counter by.

Returns:

The return type is null.

storm:stix:bundle

Implements the Storm API for creating and packing a STIX bundle for v2.1

add(node, stixtype=None)

Make one or more STIX objects from a node, and add it to the bundle.

Examples:

Example Storm which would be called remotely via the callStorm() API:

init { $bundle = $lib.stix.bundle() }
#aka.feye.thr.apt1
$bundle.add($node)
fini { return($bundle) }
Args:

node (node): The node to make a STIX object from.

stixtype (str): The explicit name of the STIX type to map the node to. This will override the default mapping.

Returns:

The stable STIX id of the added object. The return type is str.

pack()

Return the bundle as a STIX JSON object.

Returns:

The return type is dict.

storm:text

A mutable text type for simple text construction.

add(text, **kwargs)

Add text to the Text object.

Args:

text (str): The text to add.

**kwargs (any): Keyword arguments used to format the text.

Returns:

The return type is null.

str()

Get the text content as a string.

Returns:

The current string of the text object. The return type is str.

storm:trigger

Implements the Storm API for a Trigger.

iden

The Trigger iden.

Returns:

The type is str.

move(viewiden)

Modify the Trigger to run in a different View.

Args:

viewiden (str): The iden of the new View for the Trigger to run in.

Returns:

The return type is null.

pack()

Get the trigger definition.

Returns:

The definition. The return type is dict.

set(name, valu)

Set information in the Trigger.

Args:

name (str): Name of the key to set.

valu (prim): The data to set

Returns:

The return type is null.

storm:view

Implements the Storm api for a View instance.

addNode(form, valu, props=None)

Transactionally add a single node and all it’s properties. If any validation fails, no changes are made.

Args:

form (str): The form name.

valu (prim): The primary property value.

props (dict): An optional dictionary of props.

Returns:

The node which may have been just constructed. The return type is storm:node.

addNodeEdits(edits)

Add NodeEdits to the view.

Args:

edits (list): A list of nodeedits.

Returns:

The return type is null.

fork(name=None)

Fork a View in the Cortex.

Args:

name (str): The name of the new view.

Returns:

The storm:view object for the new View. The return type is storm:view.

get(name, defv=None)

Get a view configuration option.

Args:

name (str): Name of the value to get.

defv (prim): The default value returned if the name is not set in the View.

Returns:

The value requested or the default value. The return type is prim.

getEdgeVerbs()

Get the Edge verbs which exist in the View.

Yields:

Yields the edge verbs used by Layers which make up the View. The return type is str.

getEdges(verb=None)

Get node information for Edges in the View.

Args:

verb (str): The name of the Edges verb to iterate over.

Yields:

Yields tuples containing the source iden, verb, and destination iden. The return type is list.

getFormCounts()

Get the formcounts for the View.

Example:

Get the formcounts for the current View:

$counts = $lib.view.get().getFormCounts()
Returns:

Dictionary containing form names and the count of the nodes in the View’s Layers. The return type is dict.

iden

The iden of the View.

Returns:

The type is str.

layers

The storm:layer objects associated with the storm:view.

Returns:

The type is list.

merge(force=False)

Merge a forked View back into its parent View.

Args:

force (boolean): Force the view to merge if possible.

Returns:

The return type is null.

pack()

Get the View definition.

Returns:

Dictionary continaing the View definition. The return type is dict.

parent

The parent View. Will be $lib.null if the view is not a fork.

Returns:

The type is str.

repr()

Get a string representation of the View.

Returns:

A list of lines that can be printed, representing a View. The return type is list.

set(name, valu)

Set a view configuration option.

Current runtime updatable view options include:

name (str)

A terse name for the View.

desc (str)

A description of the View.

parent (str)

The parent View iden.

nomerge (bool)

Setting to $lib.true will prevent the layer from being merged.

layers (list(str))

Set the list of layer idens for a non-forked view. Layers are specified in precedence order with the first layer in the list being the write layer.

To maintain consistency with the view.fork() semantics, setting the “parent” option on a view has a few limitations:

  • The view must not already have a parent

  • The view must not have more than 1 layer

Args:

name (str): The name of the value to set.

valu (prim): The value to set.

Returns:

The return type is null.

triggers

The storm:trigger objects associated with the storm:view.

Returns:

The type is list.

wipeLayer()

Delete all nodes and nodedata from the write layer. Triggers will be run.

Returns:

The return type is null.

str

Implements the Storm API for a String object.

encode(encoding=utf8)

Encoding a string value to bytes.

Args:

encoding (str): Encoding to use. Defaults to utf8.

Returns:

The encoded string. The return type is bytes.

endswith(text)

Check if a string ends with text.

Args:

text (str): The text to check.

Returns:

True if the text ends with the string, false otherwise. The return type is boolean.

find(valu)

Find the offset of a given string within another.

Examples:

Find values in the string asdf:

$x = asdf
$x.find(d) // returns 2
$x.find(v) // returns null
Args:

valu (str): The substring to find.

Returns:

The first offset of subsgring or null. The return type is int.

ljust(size)

Left justify the string.

Args:

size (int): The length of character to left justify.

Returns:

The left justified string. The return type is str.

lower()

Get a lowercased copy the of the string.

Examples:

Printing a lowercased string:

$foo="Duck"
$lib.print($foo.lower())
Returns:

The lowercased string. The return type is str.

lstrip(chars=None)

Remove leading characters from a string.

Examples:

Removing whitespace and specific characters:

$strippedFoo = $foo.lstrip()
$strippedBar = $bar.lstrip(w)
Args:

chars (str): A list of characters to remove. If not specified, whitespace is stripped.

Returns:

The stripped string. The return type is str.

replace(oldv, newv, maxv=None)

Replace occurrences of a string with a new string, optionally restricting the number of replacements.

Example:

Replace instances of the string “bar” with the string “baz”:

$foo.replace('bar', 'baz')
Args:

oldv (str): The value to replace.

newv (str): The value to add into the string.

maxv (int): The maximum number of occurances to replace.

Returns:

The new string with replaced instances. The return type is str.

reverse()

Get a reversed copy of the string.

Examples:

Printing a reversed string:

$foo="foobar"
$lib.print($foo.reverse())
Returns:

The reversed string. The return type is str.

rjust(size)

Right justify the string.

Args:

size (int): The length of character to right justify.

Returns:

The right justified string. The return type is str.

rsplit(text, maxsplit=-1)

Split the string into multiple parts, from the right, based on a separator.

Example:

Split a string on the colon character:

($foo, $bar) = $baz.rsplit(":", maxsplit=1)
Args:

text (str): The text to split the string up with.

maxsplit (int): The max number of splits.

Returns:

A list of parts representing the split string. The return type is list.

rstrip(chars=None)

Remove trailing characters from a string.

Examples:

Removing whitespace and specific characters:

$strippedFoo = $foo.rstrip()
$strippedBar = $bar.rstrip(asdf)
Args:

chars (str): A list of characters to remove. If not specified, whitespace is stripped.

Returns:

The stripped string. The return type is str.

size()

Return the length of the string.

Returns:

The size of the string. The return type is int.

slice(start, end=None)

Get a substring slice of the string.

Examples:

Slice from index to 1 to 5:

$x="foobar"
$y=$x.slice(1,5)  // "ooba"

Slice from index 3 to the end of the string:

$y=$x.slice(3)  // "bar"
Args:

start (int): The starting character index.

end (int): The ending character index. If not specified, slice to the end of the string

Returns:

The slice substring. The return type is str.

split(text, maxsplit=-1)

Split the string into multiple parts based on a separator.

Example:

Split a string on the colon character:

($foo, $bar) = $baz.split(":")
Args:

text (str): The text to split the string up with.

maxsplit (int): The max number of splits.

Returns:

A list of parts representing the split string. The return type is list.

startswith(text)

Check if a string starts with text.

Args:

text (str): The text to check.

Returns:

True if the text starts with the string, false otherwise. The return type is boolean.

strip(chars=None)

Remove leading and trailing characters from a string.

Examples:

Removing whitespace and specific characters:

$strippedFoo = $foo.strip()
$strippedBar = $bar.strip(asdf)
Args:

chars (str): A list of characters to remove. If not specified, whitespace is stripped.

Returns:

The stripped string. The return type is str.

upper()

Get a uppercased copy the of the string.

Examples:

Printing a uppercased string:

$foo="Duck"
$lib.print($foo.upper())
Returns:

The uppercased string. The return type is str.

xml:element

A Storm object for dealing with elements in an XML tree.

attrs

The element attributes list.

Returns:

The type is dict.

find(name, nested=True)

Find all nested elements with the specified tag name.

Args:

name (str): The name of the XML tag.

nested (bool): Set to $lib.false to only find direct children.

Returns:

A generator which yields xml:elements. The return type is generator.

get(name)

Get a single child element by XML tag name.

Args:

name (str): The name of the child XML element tag.

Returns:

The child XML element or $lib.null The return type is xml:element.

name

The element tag name.

Returns:

The type is str.

text

The element text body.

Returns:

The type is str.