Device¶
In order to modify, add, delete or do anything else with the data inside buckets, it is necessary to use the device function.
To setup an device object, you need a token (that you need to get in our website). Be sure to use tokens with the correct write/read previlegies for the current function that you want to use. For example, a token with only read previlegies can’t create, modify or delete anything from a device.
.info¶
Get all information from the device
Result(){
public Boolean status;
public String message;
public Object result;
}
Device device = new Device("7c16da11-2101-4ea3-9568-7249115d73f3");
Result res = device.info("58d5318eabd6a6000e542b95");
.insert¶
Insert a new data into a bucket. You can get more information about what information can be passed with insert in our api documentation
Result(){
public Boolean status;
public String message;
public Object result;
}
Device device = new Device("8aa46f99-3156-4ebd-a275-fdb75c4dccbf");
final Object loc = new Object() {
public Double lat = 42.2974279;
public Double lng = -85.628292;
};
Object data = new Object() {
public String variable = "temperature";
public String unit = "F";
public String value = "55";
public String time = "2015-11-03 13:44:33";
public Object location = loc;
};
Result res = device.insert(data);
.find¶
Get a list of data from bucket respecting the query options passed. You can get more information about what information can be passed with .find in our get documentation
Result(){
public Boolean status;
public String message;
public Object result;
}
Device device = new Device("8aa46f99-3156-4ebd-a275-fdb75c4dccbf");
Object filter = new Object(){
public String variable = "myvar";
public String query = "last_value";
public String end_date = "2014-12-25 23:33:22";
public String start_date = "2014-12-20 23:33:22";
};
Result res = device.find(filter);
.remove¶
Remove a data from the bucket. It’s possible to remove in three ways: * The last data inserted by the device * The last data inserted by device into a variable * A specific data by it ID
Result(){
public Boolean status;
public String message;
public Object result;
}
Device device = new Device("8aa46f99-3156-4ebd-a275-fdb75c4dccbf");
Object filter = new Object(){
public String variable = "myvar";
public String query = "last_value";
public String end_date = "2014-12-25 23:33:22";
public String start_date = "2014-12-20 23:33:22";
};
Result res = device.remove(null, null);
or
Device device = new Device("8aa46f99-3156-4ebd-a275-fdb75c4dccbf");
Object filter = new Object(){
public String variable = "myvar";
public String query = "last_value";
public String end_date = "2014-12-25 23:33:22";
public String start_date = "2014-12-20 23:33:22";
};
Result res = device.remove("myvar", null);
or
Device device = new Device("8aa46f99-3156-4ebd-a275-fdb75c4dccbf");
Object filter = new Object(){
public String variable = "myvar";
public String query = "last_value";
public String end_date = "2014-12-25 23:33:22";
public String start_date = "2014-12-20 23:33:22";
};
Result res = device.remove("577d81ac7ee399ef1a6e98da", 1);