Developer API¶
This doc covers the interfaces of pyonep.
OnepV1 API¶
-
class
pyonep.OnepV1(host='m2.exosite.com', port='443', url='/onep:v1/rpc/process', https=True, httptimeout=10, agent=None, reuseconnection=False, logrequests=False, curldebug=False, startid=0)¶ -
activate(auth, codetype, code, defer=False)¶ Given an activation code, activate an entity for the client specified in <ResourceID>.
- Args:
- auth: <cik> codetype: Type of code being activated. code: Code to activate.
-
close()¶ Closes any open connection. This should only need to be called if reuseconnection is set to True. Once it’s closed, the connection may be reopened by making another API called.
-
create(auth, type, desc, defer=False)¶ Create something in Exosite.
- Args:
- auth: <cik> type: What thing to create. desc: Information about thing.
-
createDataport(auth, desc, defer=False)¶ Create a dataport resource. “format” and “retention” are required
- {
“format”: “float” | “integer” | “string”, “meta”: string = “”, “name”: string = “”, “preprocess”: list = [], “public”: boolean = false, “retention”: {
“count”: number | “infinity”, “duration”: number | “infinity”}, “subscribe”: <ResourceID> | null = null
}
-
drop(auth, resource, defer=False)¶ Deletes the specified resource.
- Args:
- auth: <cik> resource: <ResourceID>
-
flush(auth, resource, options=None, defer=False)¶ Empties the specified resource of data per specified constraints.
- Args:
- auth: <cik> resource: resource to empty. options: Time limits.
-
grant(auth, resource, permissions, ttl=None, defer=False)¶ Grant resources with specific permissions and return a token.
- Args:
- auth: <cik> resource: Alias or ID of resource. permissions: permissions of resources. ttl: Time To Live.
-
info(auth, resource, options={}, defer=False)¶ Request creation and usage information of specified resource according to the specified options.
- Args:
- auth: <cik> resource: Alias or ID of resource options: Options to define what info you would like returned.
-
listing(auth, types, options=None, resource=None, defer=False)¶ This provides backward compatibility with two previous variants of listing. To use the non-deprecated API, pass both options and resource.
-
loggedrequests()¶ Returns a list of request bodies made by this instance of OnepV1
-
lookup(auth, type, mapping, defer=False)¶ Look up a Resource ID by alias, owned Resource ID, or share activation code under the client specified in <ClientID>.
- Args:
- auth: <cik> type: Type of resource to lookup (alias | owner | shared) mapping: Based on resource type defined above.
-
map(auth, resource, alias, defer=False)¶ Creates an alias for a resource.
- Args:
- auth: <cik> resource: <ResourceID> alias: alias to create (map)
-
move(auth, resource, destinationresource, options={'aliases': True}, defer=False)¶ Moves a resource from one parent client to another.
- Args:
- auth: <cik> resource: Identifed resource to be moved. destinationresource: resource of client resource is being moved to.
-
read(auth, resource, options, defer=False)¶ Read value(s) from a dataport.
Calls a function that builds a request to read the dataport specified by an alias or rid and returns timeseries data as defined by the options.
- Args:
- auth: Takes the device cik resource: Takes the dataport alias or rid. options: Takes a list of options for what to return.
-
record(auth, resource, entries, options={}, defer=False)¶ Records a list of historical entries to the resource specified.
Note: This API is depricated, use recordbatch instead.
Calls a function that bulids a request that writes a list of historical entries to the specified resource.
- Args:
- auth: Takes the device cik resource: Takes the dataport alias or rid. entries: A list of entries to write to the resource. options: Currently unused.
-
recordbatch(auth, resource, entries, defer=False)¶ Records a list of historical entries to the resource specified.
Calls a function that bulids a request that writes a list of historical entries to the specified resource.
- Args:
- auth: Takes the device cik resource: Takes the dataport alias or rid. entries: A list of entries to write to the resource.
-
revoke(auth, codetype, code, defer=False)¶ Given an activation code, the associated entity is revoked after which the activation code can no longer be used.
- Args:
- auth: Takes the owner’s cik codetype: The type of code to revoke (client | share) code: Code specified by <codetype> (cik | share-activation-code)
-
send_deferred(auth)¶ Send all deferred requests for a particular CIK/auth.
Generates a share code for the given resource.
- Args:
- auth: <cik> resource: The identifier of the resource. options: Dictonary of options.
-
update(auth, resource, desc={}, defer=False)¶ Updates the description of the resource.
- Args:
- auth: <cik> for authentication resource: Resource to be updated desc: A Dictionary containing the update for the resource.
-
usage(auth, resource, metric, starttime, endtime, defer=False)¶ Returns metric usage for client and its subhierarchy.
- Args:
- auth: <cik> for authentication resource: ResourceID metrics: Metric to measure (as string), it may be an entity or consumable. starttime: Start time of window to measure useage (format is ___). endtime: End time of window to measure useage (format is ___).
-
wait(auth, resource, options, defer=False)¶ This is a HTTP Long Polling API which allows a user to wait on specific resources to be updated.
- Args:
- auth: <cik> for authentication resource: <ResourceID> to specify what resource to wait on. options: Options for the wait including a timeout (in ms), (max 5min) and start time (null acts as when request is recieved)
-
write(auth, resource, value, options={}, defer=False)¶ Writes a single value to the resource specified.
- Args:
- auth: cik for authentication. resource: resource to write to. value: value to write options: options.
-
writegroup(auth, entries, defer=False)¶ Writes the given values for the respective resources in the list, all writes have same timestamp.
- Args:
- auth: cik for authentication. entries: List of key, value lists. eg. [[key, value], [k,v],,,]
-
Provisioning API¶
-
class
pyonep.Provision(host='m2.exosite.com', port='80', manage_by_cik=True, verbose=False, httptimeout=5, https=False, reuseconnection=False, raise_api_exceptions=False, curldebug=False, manage_by_sharecode=False)¶ A connection manager for dealing with the provisioning API, given as set of options.
- Args:
host: A string for the hostname of the provisioning server. Defaults to m2.exosite.com. port: A string for the server port. Defaults to ‘80’. manage_by_cik: A boolean noting if devices managed by CIKs or tokens. Defaults to True. verbose: Unused. httptimeout: An integer number of seconds before timing out. Defaults to 5. https: Whether or not to use HTTPS. Defaults to False. reuseconnection: Whether or not to reuse connections. Defaults to False. raise_api_exceptions: Whether or not to raise 4XX and 5XX responses as errors. Defaults to
False.- curldebug: Whether or not to log requests as equivalent curl commands at the debug level.
- Defaults to False.
- manage_by_sharecode: When provisioning default device setups via template, whether or not
- the template is referenced by shared code or by resource ID. Defaults to False.
-
close()¶ Closes any open connections.
This should only need to be called if reuseconnection is set to True. Once closed, the connection may be reopened by making another API call.
-
content_create(key, model, contentid, meta, protected=False)¶ Creates a content entity bucket with the given contentid.
This method maps to https://github.com/exosite/docs/tree/master/provision#post—create-content-entity.
- Args:
- key: The CIK or Token for the device model: contentid: The ID used to name the entity bucket meta: protected: Whether or not this is restricted to certain device serial numbers only.
-
content_download(cik, vendor, model, contentid)¶ (Speculation) Fetches content information for a given vendor, model, and ID as chunks.
This method might map to: https://github.com/exosite/docs/tree/master/provision#get—get-content-blob-1, but seems to be missing serial number.
- Args:
- cik: The CIK for the device vendor: The name of the vendor model: contentid: The ID used to name the entity bucket
-
content_info(key, model, contentid, vendor=None)¶ (Speculation) Fetches content information for a given vendor, model, and ID.
This method might map to: https://github.com/exosite/docs/tree/master/provision#get—get-content-info-1, but seems to be missing serial number.
- Args:
- key: The CIK or Token for the device model: contentid: The ID used to name the entity bucket vendor: The name of the vendor
-
content_list(key, model)¶ Returns the list of content IDs for a given model.
This method maps to https://github.com/exosite/docs/tree/master/provision#get—list-content-ids
- Args:
- key: The CIK or Token for the device model:
-
content_remove(key, model, contentid)¶ Deletes the information for the given contentid under the given model.
This method maps to https://github.com/exosite/docs/tree/master/provision#delete—delete-content
- Args:
- key: The CIK or Token for the device model:
-
content_upload(key, model, contentid, data, mimetype)¶ Store the given data as a result of a query for content id given the model.
This method maps to https://github.com/exosite/docs/tree/master/provision#post—upload-content
- Args:
- key: The CIK or Token for the device model: contentid: The ID used to name the entity bucket data: The data blob to save mimetype: The Content-Type to use when serving the blob later