Class for handling remote requests with CloudPlugs server. More...
Public Member Functions | |
int | execEnrollController (String body, RestCallback cb) |
int | execEnrollController (String model, String ctrl, String pass, String hwid, String name, JSONObject props, RestCallback cb) |
int | execEnrollProduct (String body, RestCallback cb) |
int | execEnrollProduct (String model, String hwid, String pass, JSONObject props, RestCallback cb) |
int | execEnrollPrototype (String body, RestCallback cb) |
int | execEnrollPrototype (String pass, String name, String hwid, JSONObject perm, JSONObject props, RestCallback cb) |
int | execUnenroll (RestCallback cb) |
int | execUnenroll (String idPlug, RestCallback cb) |
int | execUnenroll (String[] idPlugs, RestCallback cb) |
int | execControlDevice (String body, RestCallback cb) |
int | execControlDevice (String model, String ctrl, String pass, RestCallback cb) |
int | execUncontrolDevice (String idPlug, RestCallback cb) |
int | execUncontrolDevice (String[] idPlugs, RestCallback cb) |
int | execGetDevice (String idPlug, RestCallback cb) |
int | execGetDevice (RestCallback cb) |
int | execSetDevice (String body, RestCallback cb) |
int | execSetDevice (String idPlug, String body, RestCallback cb) |
int | execSetDevice (String name, JSONObject props, RestCallback cb) |
int | execSetDevice (String idPlug, String name, JSONObject props, String status, JSONObject perm, RestCallback cb) |
int | execGetDeviceProp (String prop, RestCallback cb) |
int | execGetDeviceProp (String idPlug, String prop, RestCallback cb) |
int | execSetDeviceProp (String prop, String value, RestCallback cb) |
int | execSetDeviceProp (String idPlug, String prop, String value, RestCallback cb) |
int | execRemoveDeviceProp (String idPlug, String prop, RestCallback cb) |
int | execRemoveDeviceProp (String prop, RestCallback cb) |
int | execGetDeviceLocation (RestCallback cb) |
int | execGetDeviceLocation (String idPlug, RestCallback cb) |
int | execSetDeviceLocation (Number lon, Number lat, Number alt, Number accuracy, Object time, RestCallback cb) |
int | execSetDeviceLocation (String idPlug, Number lon, Number lat, Number alt, Number accuracy, Object time, RestCallback cb) |
int | execSetDeviceLocation (String idPlug, String location, RestCallback cb) |
int | execSetDeviceLocation (String location, RestCallback cb) |
int | execRemoveDeviceLocation (RestCallback cb) |
int | execRemoveDeviceLocation (String idPlug, RestCallback cb) |
int | execGetChannels (String channelMask, String params, RestCallback cb) |
int | execGetChannels (String channelMask, RestCallback cb) |
int | execGetChannels (String channelMask, Object at, String of, int offset, int limit, RestCallback cb) |
int | execGetChannels (String channelMask, Object at, String of, RestCallback cb) |
int | execGetChannels (String channelMask, Object before, Object after, String of, int offset, int limit, RestCallback cb) |
int | execGetChannels (String channelMask, Object before, Object after, String of, RestCallback cb) |
int | execRetrieveData (String channelMask, RestCallback cb) |
int | execRetrieveData (String channelMask, String params, RestCallback cb) |
int | execRetrieveData (String channelMask, Object at, String of, int offset, int limit, RestCallback cb) |
int | execRetrieveData (String channelMask, Object before, Object after, String of, int offset, int limit, RestCallback cb) |
int | execPublishData (String channelName, String body, RestCallback cb) |
int | execPublishData (String channelName, Object data, Object at, String of, Object ttlOrExpire, RestCallback cb) |
int | execPublishData (String channelName, Object data, Object at, Object ttlOrExpire, RestCallback cb) |
int | execPublishData (String channelName, String id, Object data, Object at, String of, Object ttlOrExpire, RestCallback cb) |
int | execPublishData (String channelName, String id, Object data, Object at, Object ttlOrExpire, RestCallback cb) |
int | execPublishData (String channelName, Object data, Object at, String of, RestCallback cb) |
int | execPublishData (String channelName, Object data, Object at, RestCallback cb) |
int | execRemoveData (String channelMask, String body, RestCallback cb) |
int | execRemoveData (String channelMask, Object at, String of, RestCallback cb) |
int | execRemoveData (String channelMask, Object before, Object after, String of, RestCallback cb) |
int | execRemoveData (String[] ids, RestCallback cb) |
int | execRemoveData (String id, RestCallback cb) |
Public Member Functions inherited from RestBaseManager | |
Opts | getOpts () |
String | getAuthId () |
boolean | isEmpty () |
RestJob | getJobOf (int id) |
Response | sync (int id, long timeout) |
Response | sync (int id) |
boolean | cancel (int id) |
boolean | cancel (Request request) |
boolean | waitFor (int id, long timeout) |
boolean | waitFor (int id) |
boolean | waitForIdle (long timeout) |
boolean | waitForIdle () |
boolean | waitForStop (long timeout) |
boolean | waitForStop () |
Public Member Functions inherited from MultiListener | |
MultiListener () | |
boolean | hasListener (Listener l) |
Listener | getListener (int location) |
void | addListener (Listener l) |
boolean | removeListener (Listener l) |
Listener | removeListener (int location) |
void | clearListeners () |
Listener | getListener () |
final void | setListener (Listener l) |
void | onStart () |
void | onStop () |
void | onPause () |
void | onResume () |
void | onReady () |
void | onIdle () |
void | onEvt (Object evt, Object value) |
void | onErr (Throwable t) |
Public Member Functions inherited from MetaListener | |
MetaListener () | |
MetaListener (Listener l) | |
Listener | getListener () |
void | setListener (Listener l) |
void | onStart () |
void | onStop () |
void | onPause () |
void | onResume () |
void | onReady () |
void | onIdle () |
void | onEvt (Object evt, Object value) |
void | onErr (Throwable t) |
Static Public Attributes | |
static final String | EVT_ENROLL = "enroll" |
static final String | K_MODEL = "model" |
static final String | K_HWID = "hwid" |
static final String | K_PASS = "pass" |
static final String | K_CTRL = "ctrl" |
static final String | K_NAME = "name" |
static final String | K_PROPS = "props" |
static final String | K_DATA = "data" |
static final String | K_OF = "of" |
static final String | K_AT = "at" |
static final String | K_BEFORE = "before" |
static final String | K_AFTER = "after" |
static final String | K_OFFSET = "offset" |
static final String | K_LIMIT = "limit" |
static final String | K_TTL = "ttl" |
static final String | K_EXPIRE = "expire_at" |
static final String | K_ID = "id" |
static final String | K_AUTH = "auth" |
static final String | K_STATUS = "status" |
static final String | K_PERM = "perm" |
static final String | K_LOCATION = "location" |
static final String | LOCATION_LONGITUDE = "x" |
static final String | LOCATION_LATITUDE = "y" |
static final String | LOCATION_ALTITUDE = "z" |
static final String | LOCATION_ACCURACY = "r" |
static final String | LOCATION_TIME = "t" |
static final String | STATUS_OK = "ok" |
static final String | STATUS_DISABLED = "disabled" |
static final String | STATUS_REACTIVATE = "reactivate" |
Static Public Attributes inherited from RestBaseManager | |
static final int | ID_NULL = RestSpooler.ID_NULL |
Protected Member Functions | |
RestManager (RestSpooler spooler, Opts opts) | |
RestCallback | makeEnrollCb (final RestCallback cb) |
Protected Member Functions inherited from RestBaseManager | |
RestBaseManager (RestSpooler spooler, Opts opts) | |
RestSpooler | getSpooler () |
int | execRequest (Request request, RestCallback cb) |
int | execGet (String action, String path, RestCallback cb) |
int | execPut (String action, String path, String body, RestCallback cb) |
int | execPost (String action, String path, String body, RestCallback cb) |
int | execPatch (String action, String path, String body, RestCallback cb) |
int | execDelete (String action, String path, String body, RestCallback cb) |
int | execRequest (String method, String action, String path, String body, RestCallback cb) |
int | execRequest (String method, String action, String path, RestCallback cb, Object... body) |
void | finalize () throws Throwable |
void | wantAuth () |
void | wantBasicAuth () |
void | wantEmailAuth () |
void | wantMasterAuth () |
void | wantDeviceAuth () |
void | wantNoEmailAuth () |
void | wantNoAuth () |
void | wantNoDeviceAuth () |
Static Protected Member Functions | |
static Object [] | toExpireKV (Object val) |
Static Protected Member Functions inherited from RestBaseManager | |
static String | bodyGen (Object... args) |
static String | queryGen (Object... args) |
static String | pathQuery (String path, String query) |
static String | esc (Object s) throws UnsupportedEncodingException |
static Object | queryCast (Object o) throws UnsupportedEncodingException |
static Object | ts (Object val, String err) |
static Object | tso (Object val, String err) |
static Object | tsp (Object val, String err) |
static void | runOnCb (RestCallback cb, Runnable runnable) |
Static Protected Attributes | |
static final String | ACTION_DEVICE = "device" |
static final String | ACTION_DATA = "data" |
static final String | ACTION_CHANNEL = "channel" |
Additional Inherited Members | |
Protected Attributes inherited from RestBaseManager | |
final Opts | opts |
final RestSpooler | spooler |
Protected Attributes inherited from MetaListener | |
Listener | listener |
Class for handling remote requests with CloudPlugs server.
An instance of this class can be obtained by calling RestClient#getManager(Opts). Most methods of this class send requests to the server and are named using the prefix exec
. Such methods are executed in an asynchronous way, that implies the invokation will return as soon as possible, usually before sending the request over the network.
All the requests will be serially enqueued and sent (following the order of method calls) in a separated thread spooler, transparent to the developer. The last argument of each request method is an instance of the interface RestCallback, its method RestCallback#on will receive the results of the asynchronous execution: the produced Request and its Response. The method RestCallback#on will be called by the underlying spooler and it will be executed in the thread of the underlying spooler, keep it in mind because any invokation requires main thread execution (for example GUI update) will fail if directly called from a RestCallback#on implementation.
The return value of all exec
prefixed methods is an integer identifier for controlling the request execution flow. For instance, you can call RestBaseManager#cancel(int) to cancel an enqueued request or you can call RestBaseManager#waitFor(int) to wait for the completition of an enqueued request.
See RestBaseManager for additional details.
|
protected |
int execControlDevice | ( | String | body, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for asking grants to control another device. This is the a low level method you can directly set the body of the HTTP request. See execControlDevice(String, String, String, RestCallback) for a more convenient way to enroll a controller. Device authentication credentials must be set before invoking this method.
body | the JSON body of the HTTP request to send |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execControlDevice | ( | String | model, |
String | ctrl, | ||
String | pass, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for asking grants to control another device. Device authentication credentials must be set before invoking this method.
model | the model identifier of the device to control |
ctrl | the serial number of the device to control |
pass | the secret password for controlling the device |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execEnrollController | ( | String | body, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for enrolling a controller. This is the a low level method you can directly set the body of the HTTP request. See execEnrollController(String, String, String, String, String, JSONObject, RestCallback) for a more convenient way to enroll a controller. Device authentication credentials cannot be set before invoking this method.
body | the JSON body of the HTTP request to send |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execEnrollController | ( | String | model, |
String | ctrl, | ||
String | pass, | ||
String | hwid, | ||
String | name, | ||
JSONObject | props, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for enrolling a controller. Device authentication credentials cannot be set before invoking this method.
model | the model identifier of the device to control |
ctrl | the serial number of the device to control |
pass | the secret password for controlling the device |
hwid | if not null, a unique String to identify this controller (if null, it will be automatically computed by the server) |
name | if not null, the name of this controller |
props | if not null, the additional properties (key-value pairs) of this controller |
cb | if not null, the callback will receive the Request and its Response |
RestException | when having authentication credentials or IllegalArgumentException for argument validation error |
int execEnrollProduct | ( | String | body, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for enrolling a production thing. This is the a low level method you can directly set the body of the HTTP request. See execEnrollProduct(String, String, String, JSONObject, RestCallback) for a more convenient way to enroll a production thing. Device authentication credentials cannot be set before invoking this method.
body | the JSON body of the HTTP request to send |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execEnrollProduct | ( | String | model, |
String | hwid, | ||
String | pass, | ||
JSONObject | props, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for enrolling a production thing. Device authentication credentials cannot be set before invoking this method.
model | the model identifier of this device |
hwid | the serial number of this device |
pass | the secret password for enrolling this device |
props | if not null, the additional properties (key-value pairs) of this device as an instance of org.json.JSONObject |
cb | if not null, the callback will receive the Request and its Response |
RestException | when having authentication credentials or IllegalArgumentException for argument validation error |
int execEnrollPrototype | ( | String | body, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for enrolling a new prototype. This is the a low level method you can directly set the body of the HTTP request. See execEnrollPrototype(String, String, String, JSONObject, JSONObject, RestCallback) for a more convenient way to enroll a production thing. Email authentication credentials must be set before invoking this method.
body | the JSON body of the HTTP request to send |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execEnrollPrototype | ( | String | pass, |
String | name, | ||
String | hwid, | ||
JSONObject | perm, | ||
JSONObject | props, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for enrolling a new prototype. Email authentication credentials must be set before invoking this method.
pass | for setting the authentication password of the new prototype |
name | a unique String name for this prototype |
hwid | if not null, a unique String to identify this device (if null, it will be automatically computed by the server) |
props | if not null, the additional properties (key-value pairs) of this device as an instance of org.json.JSONObject |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetChannels | ( | String | channelMask, |
String | params, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for getting all existing channel names match with the given mask and such that all conditions in the query parameters are satisfied. See execGetChannels(String, Object, String, int, int, RestCallback) and execGetChannels(String, Object, Object, String, int, int, RestCallback) for more convenient ways to get the channel names. Authentication credentials must be set before invoking this method.
channelMask | the channel mask used to filter the results |
params | the query parameters with the conditions or null if no condition should be applied |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetChannels | ( | String | channelMask, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for getting all existing channel names match with the given mask. Authentication credentials must be set before invoking this method.
channelMask | the channel mask used to filter the results |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetChannels | ( | String | channelMask, |
Object | at, | ||
String | of, | ||
int | offset, | ||
int | limit, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for getting all existing channel names match with the given mask and such that all specified conditions in the other arguments are satified. Authentication credentials must be set before invoking this method.
channelMask | the channel mask used to filter the results |
at | if not null, timestamp: the channels must contain data published on specified timestamp (Number, String or java.util.Date) |
of | if not null, PlugIDs CSV: the channels must contain data published by one of the specified PlugIDs |
offset | how many result channels to skip in the response, 0 to avoid skipping |
limit | maximum number of channels to include in the response, 0 to get as many as possible |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetChannels | ( | String | channelMask, |
Object | at, | ||
String | of, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for getting all existing channel names match with the given mask and such that all specified conditions in the other arguments are satified. Authentication credentials must be set before invoking this method.
channelMask | the channel mask used to filter the results |
at | if not null, timestamp: the channels must contain data published on specified timestamp (Number, String or java.util.Date) |
of | if not null, PlugIDs CSV: the channels must contain data published by one of the specified PlugIDs |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetChannels | ( | String | channelMask, |
Object | before, | ||
Object | after, | ||
String | of, | ||
int | offset, | ||
int | limit, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for getting all existing channel names match with the given mask and such that all specified conditions in the other arguments are satified. Authentication credentials must be set before invoking this method.
channelMask | the channel mask used to filter the results |
before | if not null, timestamp or data ID: the channels must contain data published before the timestamp (Number, String or java.util.Date) or before the data ID |
after | if not null, timestamp or data ID: the channels must contain data published after the timestamp (Number, String or java.util.Date) or after the data ID |
of | if not null, PlugIDs CSV: the channels must contain data published by one of the specified PlugIDs |
offset | how many result channels to skip in the response, 0 to avoid skipping |
limit | maximum number of channels to include in the response, 0 to get as many as possible |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetChannels | ( | String | channelMask, |
Object | before, | ||
Object | after, | ||
String | of, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for getting all existing channel names match with the given mask and such that all specified conditions in the other arguments are satified. Authentication credentials must be set before invoking this method.
channelMask | the channel mask used to filter the results |
before | if not null, timestamp or data ID: the channels must contain data published before the timestamp (Number, String or java.util.Date) or before the data ID |
after | if not null, timestamp or data ID: the channels must contain data published after the timestamp (Number, String or java.util.Date) or after the data ID |
of | if not null, PlugIDs CSV: the channels must contain data published by one of the specified PlugIDs |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetDevice | ( | String | idPlug, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for getting all the information about a specific device. The response could fail if the authentication credentials don't have enough grants to read such information. Authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to read |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetDevice | ( | RestCallback | cb | ) |
Enqueue an asynchronous request for getting all the information about this device. Device authentication credentials must be set before invoking this method.
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetDeviceLocation | ( | RestCallback | cb | ) |
Enqueue an asynchronous request for getting the value of the location additional property of this device. Device authentication credentials must be set before invoking this method.
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetDeviceLocation | ( | String | idPlug, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for getting the value of the location additional property of the given device. The response could fail if the authentication credentials don't have enough grants to read the location. Authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to read |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetDeviceProp | ( | String | prop, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for getting the value of a specific additional property of this device. Device authentication credentials must be set before invoking this method.
prop | the name of the additional property to get, if null the entire additional properties JSON object will be got |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execGetDeviceProp | ( | String | idPlug, |
String | prop, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for getting the value of a specific additional property of the given device. The response could fail if the authentication credentials don't have enough grants to read such property. Authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to read |
prop | the name of the additional property to get, if null the entire additional properties JSON object will be got |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execPublishData | ( | String | channelName, |
String | body, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for publishing data. This is the a low level method you can specify directly the body of the request. See execPublishData(String, Object, Object, String, Object, RestCallback), execPublishData(String, Object, Object, String, RestCallback), execPublishData(String, Object, Object, Object, RestCallback) and execPublishData(String, Object, Object, RestCallback) for more convenient ways to publish data. Authentication credentials must be set before invoking this method.
channelName | the channel name to publish data to |
body | the JSON body of the HTTP request to send |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execPublishData | ( | String | channelName, |
Object | data, | ||
Object | at, | ||
String | of, | ||
Object | ttlOrExpire, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for publishing data. Authentication credentials must be set before invoking this method.
channelName | the channel name to publish data to |
data | the JSON data to publish |
at | the timestamp (Number, String or java.util.Date) of the data, if null the server will automatically set this value as the current date |
of | the Plug-ID string of the publisher of the data; null means this device |
ttlOrExpire | if not null, an expire timestamp (Number, String or java.util.Date) to set when this data will be automatically removed or a time-to-live of the data in seconds |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execPublishData | ( | String | channelName, |
Object | data, | ||
Object | at, | ||
Object | ttlOrExpire, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for publishing data. Authentication credentials must be set before invoking this method.
channelName | the channel name to publish data to |
data | the JSON data to publish |
at | the timestamp (Number, String or java.util.Date) of the data, if null the server will automatically set this value as the current date |
ttlOrExpire | if not null, an expire timestamp (Number, String or java.util.Date) to set when this data will be automatically removed or a time-to-live of the data in seconds |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execPublishData | ( | String | channelName, |
String | id, | ||
Object | data, | ||
Object | at, | ||
String | of, | ||
Object | ttlOrExpire, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for publishing new data or changing an already published data. The response could fail if the authentication credentials don't have enough grants to complete the publication. Authentication credentials must be set before invoking this method.
channelName | the channel name to publish data to |
id | null for publishing new data, otherwise the id of a previously published data to modify |
data | the JSON data to publish |
at | the timestamp (Number, String or java.util.Date) of the data, if null the server will automatically set this value as the current date |
of | the Plug-ID string of the publisher of the data; null means this device |
ttlOrExpire | if not null, an expire timestamp (Number, String or java.util.Date) to set when this data will be automatically removed or a time-to-live of the data in seconds |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execPublishData | ( | String | channelName, |
String | id, | ||
Object | data, | ||
Object | at, | ||
Object | ttlOrExpire, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for publishing new data or changing an already published data. The response could fail if the authentication credentials don't have enough grants to complete the publication. Authentication credentials must be set before invoking this method.
channelName | the channel name to publish data to |
id | null for publishing new data, otherwise the id of a previously published data to modify |
data | the JSON data to publish |
at | the timestamp (Number, String or java.util.Date) of the data, if null the server will automatically set this value as the current date |
ttlOrExpire | if not null, an expire timestamp (Number, String or java.util.Date) to set when this data will be automatically removed or a time-to-live of the data in seconds |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execPublishData | ( | String | channelName, |
Object | data, | ||
Object | at, | ||
String | of, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for publishing data. Authentication credentials must be set before invoking this method.
channelName | the channel name to publish data to |
data | the JSON data to publish |
at | the timestamp (Number, String or java.util.Date) of the data, if null the server will automatically set this value as the current date |
of | the Plug-ID string of the publisher of the data; null means this device |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execPublishData | ( | String | channelName, |
Object | data, | ||
Object | at, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for publishing data. Authentication credentials must be set before invoking this method.
channelName | the channel name to publish data to |
data | the JSON data to publish |
at | the timestamp (Number, String or java.util.Date) of the data, if null the server will automatically set this value as the current date |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRemoveData | ( | String | channelMask, |
String | body, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for removing already published data. This is the a low level method you can specify directly the body of the request. See execRemoveData(String[], RestCallback), execRemoveData(String, Object, Object, String, RestCallback) and execRemoveData(String, Object, String, RestCallback) for more convenient ways to remove data. The response could fail if the authentication credentials don't have enough grants to complete the operation. Authentication credentials must be set before invoking this method.
channelMask | the channel mask such that all data contained in it will be removed |
body | the JSON body of the HTTP request |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRemoveData | ( | String | channelMask, |
Object | at, | ||
String | of, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for removing already published data. The response could fail if the authentication credentials don't have enough grants to complete the operation. Authentication credentials must be set before invoking this method.
channelMask | the channel mask such that all data contained in it will be removed |
at | if not null, remove only data published at this timestamp (Number, String or java.util.Date) |
of | if not null, remove only data published by this PlugID or CSV of Plug-IDs |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRemoveData | ( | String | channelMask, |
Object | before, | ||
Object | after, | ||
String | of, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for removing already published data. The response could fail if the authentication credentials don't have enough grants to complete the operation. Authentication credentials must be set before invoking this method.
channelMask | the channel mask such that all data contained in it will be removed |
before | if not null, remove only data published before this timestamp (Number, String or java.util.Date) |
after | if not null, remove only data published after this timestamp (Number, String or java.util.Date) |
of | if not null, remove only data published by this PlugID or CSV of Plug-IDs |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRemoveData | ( | String [] | ids, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for removing already published data. The response could fail if the authentication credentials don't have enough grants to complete the operation. Authentication credentials must be set before invoking this method.
ids | array of all data ID to remove |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRemoveData | ( | String | id, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for removing already published data. The response could fail if the authentication credentials don't have enough grants to complete the operation. Authentication credentials must be set before invoking this method.
id | the data ID to remove |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRemoveDeviceLocation | ( | RestCallback | cb | ) |
Enqueue an asynchronous request for removing the location
additional property of this device. Device authentication credentials must be set before invoking this method.
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRemoveDeviceLocation | ( | String | idPlug, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for removing the location
additional property of the given device. The response could fail if the authentication credentials don't have enough grants to remove the property. Authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to modify |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRemoveDeviceProp | ( | String | idPlug, |
String | prop, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for removing a specific additional property of the given device. The response could fail if the authentication credentials don't have enough grants to remove the property. Authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to modify |
prop | the name of the additional property to remove |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRemoveDeviceProp | ( | String | prop, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for removing a specific additional property of this device. Device authentication credentials must be set before invoking this method.
prop | the name of the additional property to remove |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRetrieveData | ( | String | channelMask, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for retrieving already published data. Authentication credentials must be set before invoking this method.
channelMask | the channel mask used to filter which data should be retrieved |
cb | if not null, the callback will receive the Request and its Response |
IllegalArgumentException | if an argument is not valid. |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRetrieveData | ( | String | channelMask, |
String | params, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for retrieving already published data. This is the a low level method you can specify directly the URL query of the request. See execRetrieveData(String, RestCallback), execRetrieveData(String, Object, String, int, int, RestCallback) and execRetrieveData(String, Object, Object, String, int, int, RestCallback) for more convenient ways to retrieve published data. Authentication credentials must be set before invoking this method.
channelMask | the channel mask used to filter which data should be retrieved |
params | if not null the parameters string of the query url |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRetrieveData | ( | String | channelMask, |
Object | at, | ||
String | of, | ||
int | offset, | ||
int | limit, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for retrieving already published data. Optionally filter the data by Plug-IDs of data publishers and/or by the timestamp at
at when data has been published. Authentication credentials must be set before invoking this method.
channelMask | the channel mask used to filter which data should be retrieved |
at | if not null, the timestamp (Number, String or java.util.Date) the data has been published |
of | if not null, the CSV string of Plug-IDs published the data to retrieve |
offset | if greater than zero, the resulting response will contain values after the offset-th one |
limit | if greater than zero, the resulting response will contain at most |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execRetrieveData | ( | String | channelMask, |
Object | before, | ||
Object | after, | ||
String | of, | ||
int | offset, | ||
int | limit, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for retrieving already published data. Optionally filter the data to retrieve by Plug-IDs of data publishers and/or by choosing specific intervals with before
after
after. Authentication credentials must be set before invoking this method.
channelMask | the channel mask used to filter which data should be retrieved |
before | if not null, the most recent timestamp (Number, String or java.util.Date) of the data to retrieve or a String contains the published data ID before which retrieve the data |
after | if not null, the minimum timestamp (Number, String or java.util.Date) of the data to retrieve or a String contains the published data ID after which retrieve the data |
of | if not null, the CSV string of Plug-IDs published the data to retrieve |
offset | if greater than zero, the resulting response will contain values after the offset-th one |
limit | if greater than zero, the resulting response will contain at most |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execSetDevice | ( | String | body, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for setting information about this device. This is the a low level method you can directly set the body of the HTTP request. See execSetDevice(String, JSONObject, RestCallback) for a more convenient way to set the information of this device. Device authentication credentials must be set before invoking this method.
body | the JSON body of the HTTP request to send |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execSetDevice | ( | String | idPlug, |
String | body, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for setting information about a specific device. This is the a low level method you can directly set the body of the HTTP request. See execSetDevice(String, String, JSONObject, String, JSONObject, RestCallback) for a more convenient way to set the information of this device. The response could fail if the authentication credentials don't have enough grants to write such information. Authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to modify |
body | the JSON body of the HTTP request to send |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execSetDevice | ( | String | name, |
JSONObject | props, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for setting information of this device. Device authentication credentials must be set before invoking this method.
name | if not null, the new name of this device |
props | if not null, the additional properties (key-value pairs) to set for this device |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execSetDevice | ( | String | idPlug, |
String | name, | ||
JSONObject | props, | ||
String | status, | ||
JSONObject | perm, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for setting information of a specific device. The response could fail if the authentication credentials don't have enough grants to write such information. Authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to modify |
name | if not null, the new name of this device |
props | if not null, the additional properties (key-value pairs) to set for this device |
status | if not null, the new status of the device, one of STATUS_OK, STATUS_DISABLED or STATUS_REACTIVATE (the last one won't work on prototypes and controllers, but only on production things) |
perm | if not null, a JSON of the new permission object to assign to the device |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execSetDeviceLocation | ( | Number | lon, |
Number | lat, | ||
Number | alt, | ||
Number | accuracy, | ||
Object | time, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for setting the value of the location additional property of this device. Device authentication credentials must be set before invoking this method.
lon | the longitude from -180 to 180, it cannot be null |
lat | the latitude from -90 to 90, it cannot be null |
alt | the altitude in meters over the sea or null if this location has no altitude |
accuracy | the location accuracy in meters or null if this location has no accuracy |
time | if not null, the timestamp (Number, String or java.util.Date) this location has been measured |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execSetDeviceLocation | ( | String | idPlug, |
Number | lon, | ||
Number | lat, | ||
Number | alt, | ||
Number | accuracy, | ||
Object | time, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for setting the value of the location
additional property of the given device. The response could fail if the authentication credentials don't have enough grants to write the location. Authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to modify |
lon | the longitude from -180 to 180, it cannot be null |
lat | the latitude from -90 to 90, it cannot be null |
alt | the altitude in meters over the sea or null if this location has no altitude |
accuracy | the location accuracy in meters or null if this location has no accuracy |
time | if not null, the timestamp (Number, String or java.util.Date) this location has been measured |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execSetDeviceLocation | ( | String | idPlug, |
String | location, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for setting the value of the location
additional property of the given device. See execSetDeviceLocation(String, Number, Number, Number, Number, Object, RestCallback) for a more convenient way to set the location. The response could fail if the authentication credentials don't have enough grants to write the location. Authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to modify |
location | the JSON object of the location to set |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execSetDeviceLocation | ( | String | location, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for setting the value of the location
additional property of this device. See execSetDeviceLocation(Number, Number, Number, Number, Object, RestCallback) for a more convenient way to set the location. Device authentication credentials must be set before invoking this method.
location | the JSON object of the location to set |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execSetDeviceProp | ( | String | prop, |
String | value, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for setting the value of one or more additional properties of this device. Device authentication credentials must be set before invoking this method.
prop | the name of the additional property to set, if null then value will contain a JSON object of all additional properties to set |
value | the JSON value to set for the property prop or if prop is null it contains the JSON object of all additional properties to set |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execSetDeviceProp | ( | String | idPlug, |
String | prop, | ||
String | value, | ||
RestCallback | cb | ||
) |
Enqueue an asynchronous request for setting the value of one or more additional properties of the given device. The response could fail if the authentication credentials don't have enough grants to write such properties. Authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to modify |
prop | the name of the additional property to set, if null then value will contain a JSON object of all additional properties to set |
value | the JSON value to set for the property prop or if prop is null it contains the JSON object of all additional properties to set |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execUncontrolDevice | ( | String | idPlug, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for releasing the control of a device. Successful responses require the control of the device was already been grant. Device authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to release control; you can pass a CSV of PlugIDs to release the control of more devices at the same time |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execUncontrolDevice | ( | String [] | idPlugs, |
RestCallback | cb | ||
) |
Enqueue an asynchronous request for releasing the control of one or more devices. Successful responses require the control of the devices was already been grant. Device authentication credentials must be set before invoking this method.
idPlugs | one or more PlugIDs identify the devices to release control |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execUnenroll | ( | RestCallback | cb | ) |
Unenroll this device and remove all data stored in the cloud and related to this device. Device authentication credentials must be set before invoking this method.
RestException | for invalid authentication credentials |
int execUnenroll | ( | String | idPlug, |
RestCallback | cb | ||
) |
Unenroll the specified device and remove all data stored in the cloud and related to that device. Email authentication credentials must be set before invoking this method.
idPlug | the PlugID identifies the device to unenroll |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
int execUnenroll | ( | String [] | idPlugs, |
RestCallback | cb | ||
) |
Unenroll the specified devices and remove all data stored in the cloud and related to those devices. Email authentication credentials must be set before invoking this method.
idPlugs | the PlugIDs identify the devices to unenroll |
cb | if not null, the callback will receive the Request and its Response |
RestException | for invalid authentication credentials or IllegalArgumentException for argument validation error |
|
protected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
static |
Event String used to notify any registered com.cloudplugs.util.Listener about a successful enroll.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |