Skip to content

Commit

Permalink
Merge pull request #26 from nodejitsu/preacher
Browse files Browse the repository at this point in the history
Integrate Preacher-API
  • Loading branch information
julianduque committed Aug 16, 2013
2 parents 86108c0 + d6454aa commit 1060d5f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 91 deletions.
63 changes: 2 additions & 61 deletions node.js/lib/client/logs.js
Expand Up @@ -7,66 +7,7 @@
*
*/

var util = require('util'),
Client = require('./client').Client;

//
// ### function Logs (options)
// #### @options {Object} Options for this instance
// 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);

// Constructor function for the Logs resource with Nodejitsu's Logs API
//
// ### 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) {
var appName = this.defaultUser(appName),
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;
5 changes: 3 additions & 2 deletions node.js/package.json
@@ -1,6 +1,6 @@
{
"name": "nodejitsu-api",
"version": "0.4.7",
"version": "0.5.0",
"description": "nodejitsu API client wrapper",
"keywords": ["nodejitsu", "nodejitsu-api"],
"homepage": "http://github.com/nodejitsu/nodejitsu-api",
Expand All @@ -13,7 +13,8 @@
"test": "vows --spec ./test/commands/*-test.js"
},
"dependencies": {
"request": "2.16.2"
"request": "2.25.0",
"preacher-api": "0.1.2"
},
"devDependencies": {
"vows": "0.7.x",
Expand Down
28 changes: 0 additions & 28 deletions node.js/test/commands/logs-test.js

This file was deleted.

0 comments on commit 1060d5f

Please sign in to comment.