...
The format of the Sky Cloud API is as follows:
The schema is can be either http
or https
. or https depending on the configuration of the server hosting the picos.
The domain name depends on is the domain name of the pico-engine hosting the picos processing the events.
...
/sky/cloud/<eci>/<rid>/<function>?name0=value0&...&namennameN=valuenvalueN
Where
<eci>
- The ECI of the pico<rid>
- The ruleset ID or alias of the module. If the module is not installed on the pico, a JSON object is returned with anerror
field and an error message containing<rid>
.<function>
- The name of the function in the module- name0, value0 - The parameters to the function. The names must match the parameters names in the module definition. Order is not important.
...
Performing an HTTP GET request on a Sky Cloud URL formatted as previously shown will return a string with the JSON result of calling <function>
in the module named <rid>
with the given parameters. The content type of the return is application/json
.
Warning | ||
---|---|---|
| ||
The sections below have not been updated yet from the classic engine documentation |
Authorization an Event Channel
The API has to be run against an event channel that ties it to a specific personal cloud or pico.
OAuth is required for using Sky Cloud API. The details of setting up OAuth for use with a personal cloud are documented here.
As part of the OAuth interaction you will receive and ECI. You should have stored this in your system since the ECI will be used for Sky Cloud API calls.
The preferred way to use the ECI is to put it in the Kobj-Session
header when making the GET request. Here's an example doing that with the Rest Console:
If you cannot place the ECI in a header due to limitation on the calling side, it can be placed in the _eci
parameter in the URL query string. The _eci
parameter can be placed anywhere in the query parameters. The following shows this pattern:
...
.
...
All Sky Cloud API requests should be made over SSL to protect the credentials.
Preparing a Module for Use with Sky Cloud
Any module can be used with the Sky Cloud API. In order to use a module with Sky Cloud, the sharing
shares
pragma in the meta section of the ruleset must be "on"list the names of the functions that are shared (and thus callable but Sky Cloud).
Code Block | ||
---|---|---|
| ||
meta { name "thermostat module" providesshares mode, get_temperature sharing on } |
Any function (and only functions) in the provides shares
list of the module can be called using Sky Cloud.
Note that you can only run functions. So if you want to return a constant, you have to can wrap it in a parameterless function.
...
Code Block | ||||
---|---|---|---|---|
| ||||
ruleset a16x55 { meta { name "thermostat module" providesshares get_mode, get_temperature sharing on } global { get_mode = function() { ... } get_temperature(room) { ... } } |
...