Comparing version 0.4.3 to 0.4.4
@@ -46,10 +46,12 @@ #!/usr/bin/env node | ||
// Write the different values into AT&T M2X | ||
var at = new Date().toISOString(); | ||
var values = { | ||
load_1m: [ { value: load_1m } ], | ||
load_5m: [ { value: load_5m } ], | ||
load_15m: [ { value: load_15m } ] | ||
load_1m: [ { value: load_1m, at: at } ], | ||
load_5m: [ { value: load_5m, at: at } ], | ||
load_15m: [ { value: load_15m, at: at } ] | ||
}; | ||
this.m2xClient.feeds.postMultiple(FEED, values, function(data, error, res) { | ||
if (error || res.statusCode !== 204) { | ||
if (error || res.statusCode !== 202) { | ||
// abort if something went wrong | ||
@@ -56,0 +58,0 @@ clearInterval(this.updateInterval); |
@@ -8,3 +8,3 @@ 'use strict'; | ||
var API_BASE = "http://api-m2x.att.com/v1"; | ||
var USER_AGENT = "M2X/0.4.3 (node.js)"; | ||
var USER_AGENT = "M2X/0.4.4 (node.js)"; | ||
@@ -38,3 +38,3 @@ var Client = function(apiKey, apiBase) { | ||
headers = helpers.extend(this.defaultHeaders, options.headers || {}); | ||
headers = helpers.extend(options.headers || {}, this.defaultHeaders); | ||
@@ -41,0 +41,0 @@ if (! headers["Content-Type"]) { |
@@ -109,2 +109,8 @@ 'use strict'; | ||
// Update stream value | ||
Feeds.prototype.updateStreamValue = function(id, name, params, cb) { | ||
return this.client. | ||
put(helpers.url("/feeds/%s/streams/%s/value", id, name), { params: params }, cb); | ||
}; | ||
// Delete the stream (and all its values) from the feed | ||
@@ -143,3 +149,3 @@ Feeds.prototype.deleteStream = function(id, name, cb) { | ||
// { "at": <Time in ISO8601>, "value": x }, | ||
// { "value": y } | ||
// { "at": <Time in ISO8601>, "value": y } | ||
// ], | ||
@@ -149,4 +155,2 @@ // "stream-name-2": [ ... ] | ||
// | ||
// If the `at` attribute is missing the the current time of the | ||
// server, in UTC, will be used. | ||
Feeds.prototype.postMultiple = function(id, values, cb) { | ||
@@ -153,0 +157,0 @@ return this.client.post(helpers.url("/feeds/%s", id), { params: { values: values } }, cb); |
{ | ||
"name": "m2x", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "AT&T M2X API client for node.js", | ||
@@ -5,0 +5,0 @@ "main": "./lib/m2x", |
# Node.js M2X API Client # | ||
The AT&T M2X API provides all the needed operations to connect your device to AT&T's [M2X](http://m2x.att.com) service. | ||
The AT&T M2X API provides all the needed operations to connect your device to AT&T's [M2X](http://m2x.att.com) service. | ||
This client provides an easy to use interface for [node.js](http://nodejs.org/). | ||
@@ -62,6 +62,6 @@ | ||
associated with the M2X API key supplied when initializing M2X | ||
The list of data source batches can be filtered by using one or | ||
more of the following optional parameters: | ||
* `q` text to search, matching the name and description. | ||
@@ -82,5 +82,5 @@ * `tags` a comma separated list of tags. | ||
Create a new data source batch | ||
Accepts the following parameters as members of a hash: | ||
* `name` the name of the new data source. | ||
@@ -94,5 +94,5 @@ * `visibility` either "public" or "private". | ||
Update an existing data source batch details | ||
Accepts the following parameters as members of a hash: | ||
* `name` the name of the new data source. | ||
@@ -106,3 +106,3 @@ * `visibility` either "public" or "private". | ||
List/search all data sources in the batch | ||
See Datasources#search for search parameters description. | ||
@@ -113,3 +113,3 @@ | ||
Add a new data source to an existing batch | ||
Accepts a `serial` parameter, that must be a unique identifier | ||
@@ -136,6 +136,6 @@ within this batch. | ||
with the M2X API key supplied when initializing M2X | ||
The list of blueprints can be filtered by using one or more of the | ||
following optional parameters: | ||
* `q` text to search, matching the name and description. | ||
@@ -156,5 +156,5 @@ * `tags` a comma separated list of tags. | ||
Create a new data source blueprint | ||
Accepts the following parameters as members of a hash: | ||
* `name` the name of the new data source blueprint. | ||
@@ -168,5 +168,5 @@ * `visibility` either "public" or "private". | ||
Update an existing data source blueprint's information | ||
Accepts the following parameters as members of a hash: | ||
* `name` the name of the new data source blueprint. | ||
@@ -195,6 +195,6 @@ * `visibility` either "public" or "private". | ||
with the M2X API key supplied when initializing M2X | ||
The list of data sources can be filtered by using one or more of the | ||
following optional parameters: | ||
* `q` text to search, matching the name and description. | ||
@@ -215,5 +215,5 @@ * `tags` a comma separated list of tags. | ||
Create a new data source | ||
Accepts the following parameters as members of a hash: | ||
* `name` the name of the new data source. | ||
@@ -227,5 +227,5 @@ * `visibility` either "public" or "private". | ||
Update an existing data source details | ||
Accepts the following parameters as members of a hash: | ||
* `name` the name of the new data source. | ||
@@ -298,6 +298,6 @@ * `visibility` either "public" or "private". | ||
recent values first). | ||
The values can be filtered by using one or more of the following | ||
optional parameters: | ||
* `start` An ISO 8601 timestamp specifying the start of the date range to be considered. | ||
@@ -344,3 +344,3 @@ * `end` An ISO 8601 timestamp specifying the end of the date range to be considered. | ||
{ "at": <Time in ISO8601>, "value": x }, | ||
{ "value": y } | ||
{ "at": <Time in ISO8601>, "value": y } | ||
], | ||
@@ -351,4 +351,2 @@ "stream-name-2": [ ... ] | ||
If the `at` attribute is missing then the current time of the server, in UTC, will be used. | ||
* m2x.feeds.triggers(id, callback) | ||
@@ -401,3 +399,3 @@ | ||
Create a new API Key. | ||
Note that, according to the parameters sent, you can create a Master API Key or a Feed/Stream API Key. See https://m2x.att.com/developer/documentation/keys#Create-Key for details on the parameters accepted by this method. | ||
@@ -408,3 +406,3 @@ | ||
Update API Key properties. | ||
This method accepts the same parameters as create API Key and has the same validations. Note that the Key token cannot be updated through this method. | ||
@@ -415,3 +413,3 @@ | ||
Regenerate an API Key token. | ||
Note that if you regenerate the key that you're using for authentication then you would need to change your scripts to start using the new key token for all subsequent requests. | ||
@@ -470,10 +468,12 @@ | ||
// Write the different values into AT&T M2X | ||
var at = new Date().toISOString(); | ||
var values = { | ||
load_1m: [ { value: load_1m } ], | ||
load_5m: [ { value: load_5m } ], | ||
load_15m: [ { value: load_15m } ] | ||
load_1m: [ { value: load_1m, at: at } ], | ||
load_5m: [ { value: load_5m, at: at } ], | ||
load_15m: [ { value: load_15m, at: at } ] | ||
}; | ||
this.m2xClient.feeds.postMultiple(FEED, values, function(data, error, res) { | ||
if (res.statusCode !== 204) { | ||
if (res.statusCode !== 202) { | ||
// abort if something went wrong | ||
@@ -480,0 +480,0 @@ clearInterval(this.updateInterval); |
40754
15
599