diff options
Diffstat (limited to 'js/zt1-api-client')
-rw-r--r-- | js/zt1-api-client/index.js | 22 | ||||
-rw-r--r-- | js/zt1-api-client/package.json | 6 | ||||
-rw-r--r-- | js/zt1-api-client/test.js | 12 |
3 files changed, 20 insertions, 20 deletions
diff --git a/js/zt1-api-client/index.js b/js/zt1-api-client/index.js index 55f7fb24..4e3598b5 100644 --- a/js/zt1-api-client/index.js +++ b/js/zt1-api-client/index.js @@ -2,14 +2,14 @@ var request = require('request'); -function ZT1Client(url,authToken) +function ZT1ApiClient(url,authToken) { this.url = url; this.authToken = authToken; } // Generate new ZeroTier identity -- mostly for testing -ZT1Client.prototype.newIdentity = function(callback) +ZT1ApiClient.prototype.newIdentity = function(callback) { request({ url: this.url + 'newIdentity', @@ -27,7 +27,7 @@ ZT1Client.prototype.newIdentity = function(callback) }); } -ZT1Client.prototype._jsonGet = function(getPath,callback) +ZT1ApiClient.prototype._jsonGet = function(getPath,callback) { request({ url: this.url + getPath, @@ -44,7 +44,7 @@ ZT1Client.prototype._jsonGet = function(getPath,callback) }); }; -ZT1Client.prototype.status = function(callback) +ZT1ApiClient.prototype.status = function(callback) { request({ url: this.url + 'controller', @@ -77,27 +77,27 @@ ZT1Client.prototype.status = function(callback) }.bind(this)); }; -ZT1Client.prototype.getNetworks = function(callback) +ZT1ApiClient.prototype.getNetworks = function(callback) { this._jsonGet('network',callback); }; -ZT1Client.prototype.getPeers = function(callback) +ZT1ApiClient.prototype.getPeers = function(callback) { this._jsonGet('peer',callback); }; -ZT1Client.prototype.listControllerNetworks = function(callback) +ZT1ApiClient.prototype.listControllerNetworks = function(callback) { this._jsonGet('controller/network',callback); }; -ZT1Client.prototype.getControllerNetwork = function(nwid,callback) +ZT1ApiClient.prototype.getControllerNetwork = function(nwid,callback) { this._jsonGet('controller/network/' + nwid,callback); }; -ZT1Client.prototype.saveControllerNetwork = function(network,callback) +ZT1ApiClient.prototype.saveControllerNetwork = function(network,callback) { if ((typeof network.nwid !== 'string')||(network.nwid.length !== 16)) return callback(new Error('Missing required field: nwid'),null); @@ -153,8 +153,8 @@ ZT1Client.prototype.saveControllerNetwork = function(network,callback) }); }; -ZT1Client.prototype.getControllerNetworkMember = function(nwid,address,callback) { +ZT1ApiClient.prototype.getControllerNetworkMember = function(nwid,address,callback) { this._jsonGet('controller/network/' + nwid + '/member/' + address,callback); }; -exports.ZT1Client = ZT1Client; +exports.ZT1ApiClient = ZT1ApiClient; diff --git a/js/zt1-api-client/package.json b/js/zt1-api-client/package.json index 953f6d37..bb818710 100644 --- a/js/zt1-api-client/package.json +++ b/js/zt1-api-client/package.json @@ -1,7 +1,7 @@ { - "name": "nodejs-zt1-client", - "version": "1.0.0", - "description": "ZeroTier One Network Virtualization Service JSON API Client", + "name": "zt1-api-client", + "version": "0.0.1", + "description": "ZeroTier One JSON API Client", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/js/zt1-api-client/test.js b/js/zt1-api-client/test.js index 347ca1a1..bfe9b112 100644 --- a/js/zt1-api-client/test.js +++ b/js/zt1-api-client/test.js @@ -1,24 +1,24 @@ -var ZT1Client = require('./index.js').ZT1Client; +var ZT1ApiClient = require('./index.js').ZT1ApiClient; -var zt1c = new ZT1Client('http://127.0.0.1:9993/','5d6181b71fae2684f9cc64ed'); +var zt1 = new ZT1ApiClient('http://127.0.0.1:9993/','5d6181b71fae2684f9cc64ed'); -zt1c.status(function(err,status) { +zt1.status(function(err,status) { if (err) console.log(err); else console.log(status); - zt1c.getNetworks(function(err,networks) { + zt1.getNetworks(function(err,networks) { if (err) console.log(err); else console.log(networks); - zt1c.getPeers(function(err,peers) { + zt1.getPeers(function(err,peers) { if (err) console.log(err); else console.log(peers); if (status.controller) { - zt1c.saveControllerNetwork({ + zt1.saveControllerNetwork({ nwid: status.address + 'dead01', name: 'test network', private: true |