nodejitsu-api
Advanced tools
Comparing version 0.4.7 to 0.5.0
@@ -11,4 +11,3 @@ 'use strict'; | ||
var util = require('util'), | ||
Client = require('./client').Client, | ||
defaultUser = require('./helpers').defaultUser; | ||
Client = require('./client').Client; | ||
@@ -66,3 +65,3 @@ // | ||
Apps.prototype.create = function (app, callback) { | ||
var appName = defaultUser.call(this, app.name); | ||
var appName = this.defaultUser(app.name); | ||
@@ -79,4 +78,4 @@ this.request({ method: 'POST', uri: ['apps', appName], body: app }, callback); | ||
Apps.prototype.view = function (appName, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')), | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')), | ||
self = this; | ||
@@ -107,4 +106,4 @@ | ||
Apps.prototype.update = function (appName, attrs, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')); | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')); | ||
@@ -121,4 +120,4 @@ this.request({ method: 'PUT', uri: argv, body: attrs }, callback); | ||
Apps.prototype.destroy = function (appName, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')); | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')); | ||
@@ -141,4 +140,4 @@ this.request({ method: 'DELETE', uri: argv, appName: appName }, callback); | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')).concat('start'); | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')).concat('start'); | ||
@@ -161,4 +160,4 @@ if (cloud) { | ||
Apps.prototype.restart = function (appName, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')).concat('restart'); | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')).concat('restart'); | ||
@@ -175,4 +174,4 @@ this.cloud({ method: 'POST', uri: argv, appName: appName }, this.request, callback); | ||
Apps.prototype.stop = function (appName, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')).concat('stop'); | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')).concat('stop'); | ||
@@ -190,3 +189,3 @@ this.cloud({ method: 'POST', uri: argv, appName: appName }, this.request, callback); | ||
Apps.prototype.available = function (app, callback) { | ||
var appName = defaultUser.call(this, app.name), | ||
var appName = this.defaultUser(app.name), | ||
argv = ['apps'].concat(appName.split('/')).concat('available'); | ||
@@ -205,4 +204,4 @@ | ||
Apps.prototype.setDrones = function (appName, drones, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')).concat('cloud'), | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')).concat('cloud'), | ||
cloud = [{ drones: drones }]; | ||
@@ -221,4 +220,4 @@ | ||
Apps.prototype.datacenter = function (appName, cloud, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')).concat('cloud'), | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')).concat('cloud'), | ||
self = this; | ||
@@ -225,0 +224,0 @@ |
@@ -38,2 +38,18 @@ 'use strict'; | ||
// | ||
// ### function defaultUser (appName) | ||
// #### @data {String} App name, user/app, or user/database. | ||
// | ||
// A helper to prepend a default username. | ||
// needs 'this' to be able to options.get('username'). | ||
// | ||
Client.prototype.defaultUser = function (data) { | ||
if (!~data.indexOf('/')) { | ||
data = this.options.get('username') + '/' + data; | ||
} | ||
return data; | ||
}; | ||
// | ||
// ### function endpoints(callback) | ||
@@ -40,0 +56,0 @@ // #### @callback {function} Continuation to respond to when complete. |
@@ -11,3 +11,2 @@ 'use strict'; | ||
var util = require('util'), | ||
defaultUser = require('./helpers').defaultUser, | ||
Client = require('./client').Client; | ||
@@ -36,4 +35,4 @@ | ||
Databases.prototype.create = function (databaseType, databaseName, callback) { | ||
databaseName = defaultUser.call(this, databaseName); | ||
var argv = [ 'databases' ].concat(databaseName.split('/')); | ||
var databaseName = this.defaultUser(databaseName), | ||
argv = [ 'databases' ].concat(databaseName.split('/')); | ||
@@ -54,4 +53,4 @@ this.request({ method: 'POST', uri: argv, body: { type: databaseType }}, function (err, result, res) { | ||
Databases.prototype.get = function (databaseName, callback) { | ||
databaseName = defaultUser.call(this, databaseName); | ||
var argv = [ 'databases' ].concat(databaseName.split('/')); | ||
var databaseName = this.defaultUser(databaseName), | ||
argv = [ 'databases' ].concat(databaseName.split('/')); | ||
@@ -91,6 +90,6 @@ this.request({ uri: argv }, function (err, result) { | ||
Databases.prototype.destroy = function (databaseName, callback) { | ||
databaseName = defaultUser.call(this, databaseName); | ||
var argv = [ 'databases' ].concat(databaseName.split('/')); | ||
var databaseName = this.defaultUser(databaseName), | ||
argv = [ 'databases' ].concat(databaseName.split('/')); | ||
this.request({ method: 'DELETE', uri: argv }, callback); | ||
}; |
'use strict'; | ||
// | ||
// ### function defaultUser (appName) | ||
// #### @data {String} App name, user/app, or user/database. | ||
// | ||
// A helper to prepend a default username. | ||
// needs 'this' to be able to options.get('username'). | ||
// | ||
exports.defaultUser = function (data) { | ||
if (!~data.indexOf('/')) { | ||
data = this.options.get('username') + '/' + data; | ||
} | ||
return data; | ||
}; | ||
// | ||
// Async flow control helper function, to clean up some messy code. | ||
@@ -20,0 +5,0 @@ // |
@@ -11,4 +11,3 @@ 'use strict'; | ||
var util = require('util'), | ||
Client = require('./client').Client, | ||
defaultUser = require('./helpers').defaultUser; | ||
Client = require('./client').Client; | ||
@@ -15,0 +14,0 @@ // |
@@ -10,65 +10,5 @@ 'use strict'; | ||
var util = require('util'), | ||
Client = require('./client').Client, | ||
defaultUser = require('./helpers').defaultUser; | ||
// | ||
// ### function Logs (options) | ||
// #### @options {Object} Options for this instance | ||
// Constructor function for the Logs resource | ||
// with Nodejitsu's Logs API | ||
// Constructor function for the Logs resource with Nodejitsu's Logs API | ||
// | ||
var Logs = exports.Logs = function (options) { | ||
Client.call(this, options); | ||
}; | ||
// Inherit from Client base object | ||
util.inherits(Logs, Client); | ||
// | ||
// ### function byApp (appName, amount, callback) | ||
// #### @appName {string} Name of the application to retrieve | ||
// #### @amount {number} the number of lines to retrieve | ||
// #### @callback {function} Continuation to pass control to when complete. | ||
// It retrieves the specified amount of logs for the application | ||
// | ||
Logs.prototype.byApp = function (appName, amount, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['logs'].concat(appName.split('/')), | ||
options = { | ||
from: 'NOW-1DAY', | ||
until: 'NOW', | ||
rows: amount | ||
}; | ||
this.request({ method: 'POST', uri: argv, body: options }, callback); | ||
}; | ||
// | ||
// ### function byUser (amount, callback) | ||
// #### @username {string} Name of user whose logs we wish to retrieve | ||
// #### @amount {number} the number of lines to retrieve | ||
// #### @callback {function} Continuation to pass control to when complete. | ||
// It retrieves the specified amount of logs for all the applications for the user | ||
// | ||
Logs.prototype.byUser = function (username, amount, callback) { | ||
var options; | ||
if (arguments.length === 2) { | ||
callback = amount; | ||
amount = username; | ||
username = this.options.get('username'); | ||
} | ||
if (typeof username === undefined || username === null) { | ||
username = this.options.get('username'); | ||
} | ||
options = { | ||
from: 'NOW-1DAY', | ||
until: 'NOW', | ||
rows: amount | ||
}; | ||
this.request({method: 'POST', uri: ['logs', username], body: options }, callback); | ||
}; | ||
exports.Logs = require('preacher-api').Logs; |
@@ -11,4 +11,3 @@ 'use strict'; | ||
var util = require('util'), | ||
Client = require('./client').Client, | ||
defaultUser = require('./helpers').defaultUser; | ||
Client = require('./client').Client; | ||
@@ -35,4 +34,4 @@ // | ||
Snapshots.prototype.list = function (appName, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')).concat('snapshots'); | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')).concat('snapshots'); | ||
@@ -56,4 +55,4 @@ this.request({ uri: argv }, function (err, result) { | ||
Snapshots.prototype.create = function (appName, snapshotName, filename, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')).concat(['snapshots', snapshotName]); | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')).concat(['snapshots', snapshotName]); | ||
@@ -72,4 +71,4 @@ return this.upload({ uri: argv, file: filename }, callback); | ||
Snapshots.prototype.fetch = function (appName, snapshotName, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')).concat(['snapshots', snapshotName + '.tgz']); | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')).concat(['snapshots', snapshotName + '.tgz']); | ||
@@ -89,4 +88,4 @@ callback = callback || function () {}; | ||
Snapshots.prototype.destroy = function (appName, snapshotName, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')).concat(['snapshots', snapshotName]); | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')).concat(['snapshots', snapshotName]); | ||
@@ -105,6 +104,6 @@ this.request({ method: 'DELETE', uri: argv }, callback); | ||
Snapshots.prototype.activate = function (appName, snapshotName, callback) { | ||
appName = defaultUser.call(this, appName); | ||
var argv = ['apps'].concat(appName.split('/')).concat(['snapshots', snapshotName, 'activate']); | ||
var appName = this.defaultUser(appName), | ||
argv = ['apps'].concat(appName.split('/')).concat(['snapshots', snapshotName, 'activate']); | ||
this.request({ method: 'POST', uri: argv }, callback); | ||
}; |
@@ -11,4 +11,3 @@ 'use strict'; | ||
var util = require('util'), | ||
Client = require('./client').Client, | ||
defaultUser = require('./helpers').defaultUser; | ||
Client = require('./client').Client; | ||
@@ -15,0 +14,0 @@ // |
@@ -11,4 +11,3 @@ 'use strict'; | ||
var util = require('util'), | ||
Client = require('./client').Client, | ||
defaultUser = require('./helpers').defaultUser; | ||
Client = require('./client').Client; | ||
@@ -15,0 +14,0 @@ // |
{ | ||
"name": "nodejitsu-api", | ||
"version": "0.4.7", | ||
"version": "0.5.0", | ||
"description": "nodejitsu API client wrapper", | ||
@@ -16,3 +16,4 @@ "keywords": ["nodejitsu", "nodejitsu-api"], | ||
"dependencies": { | ||
"request": "2.16.2" | ||
"request": "2.25.0", | ||
"preacher-api": "0.1.3" | ||
}, | ||
@@ -19,0 +20,0 @@ "devDependencies": { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
67507
2
35
1520
+ Addedpreacher-api@0.1.3
+ Addedasn1@0.1.11(transitive)
+ Addedassert-plus@0.1.5(transitive)
+ Addedasync@0.9.2(transitive)
+ Addedaws-sign@0.3.0(transitive)
+ Addedboom@0.4.2(transitive)
+ Addedcookie-jar@0.3.0(transitive)
+ Addedcryptiles@0.2.2(transitive)
+ Addedctype@0.5.3(transitive)
+ Addedextendable@0.0.6(transitive)
+ Addedforever-agent@0.5.2(transitive)
+ Addedform-data@0.1.4(transitive)
+ Addedhawk@1.0.0(transitive)
+ Addedhoek@0.9.1(transitive)
+ Addedhttp-signature@0.10.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedload@0.1.4(transitive)
+ Addedoauth-sign@0.3.0(transitive)
+ Addedpreacher-api@0.1.3(transitive)
+ Addedprimus@1.1.4(transitive)
+ Addedqs@0.6.6(transitive)
+ Addedrequest@2.25.0(transitive)
+ Addedsntp@0.2.4(transitive)
+ Addedtunnel-agent@0.3.0(transitive)
- Removedasync@0.2.10(transitive)
- Removedaws-sign@0.2.1(transitive)
- Removedboom@0.3.8(transitive)
- Removedcookie-jar@0.2.0(transitive)
- Removedcryptiles@0.1.3(transitive)
- Removedforever-agent@0.2.0(transitive)
- Removedform-data@0.0.10(transitive)
- Removedhawk@0.10.2(transitive)
- Removedhoek@0.7.6(transitive)
- Removedjson-stringify-safe@3.0.0(transitive)
- Removedoauth-sign@0.2.0(transitive)
- Removedqs@0.5.6(transitive)
- Removedrequest@2.16.2(transitive)
- Removedsntp@0.1.4(transitive)
- Removedtunnel-agent@0.2.0(transitive)
Updatedrequest@2.25.0