Permalink
Browse files

[minor] Remove lib/jitsu/clients/* since they have been moved to lib/…

…jitsu/api/*
  • Loading branch information...
1 parent 2229733 commit a1833382f270d9321e806e69cfbcce14070ad60c @indexzero indexzero committed Mar 6, 2011
Showing with 0 additions and 146 deletions.
  1. +0 −72 lib/jitsu/clients/apps.js
  2. +0 −74 lib/jitsu/clients/client.js
View
@@ -1,72 +0,0 @@
-/*
- * app.js: Client for the Nodejitsu apps API.
- *
- * (C) 2010, Nodejitsu Inc.
- *
- */
-
-var util = require('util'),
- winston = require('winston'),
- jitsu = require('jitsu');
-
-//
-// ### function Apps (options)
-// #### @options {Object} Options for this instance
-// Constructor function for the Apps resource responsible
-// with Nodejitsu's Apps API
-//
-var Apps = exports.Apps = function (options) {
- jitsu.Client.call(this, options);
-};
-
-// Inherit from Client base object
-util.inherits(Apps, jitsu.Client);
-
-//
-// ### function list (callback)
-// #### @callback {function} Continuation to pass control to when complete
-// Lists all applications for the authenticated user
-//
-Apps.prototype.list = function (callback) {
- winston.info('Listing apps');
- this._request('GET', ['apps'], callback, function (res, result) {
- callback(null, result.apps);
- });
-};
-
-//
-// ### function create (app, callback)
-// #### @app {Object} Package.json manifest for the application.
-// #### @callback {function} Continuation to pass control to when complete
-// Creates an application with the specified package.json manifest in `app`.
-//
-Apps.prototype.create = function (app, callback) {
- this._request('POST', ['apps', app.name], app, callback, function (err, res, body) {
-
- });
-};
-
-//
-// ### function update (name, attrs, callback)
-// #### @name {string} Name of the application to update
-// #### @attrs {Object} Attributes to update for this application.
-// #### @callback {function} Continuation to pass control to when complete
-// Updates the application with `name` with the specified attributes in `attrs`
-//
-Apps.prototype.update = function (name, attrs, callback) {
- this._request('PUT', ['apps', name], attrs, callback, function (err, res, body) {
-
- });
-};
-
-//
-// ### function destroy (name, callback)
-// #### @name {string} Name of the application to destroy
-// #### @callback {function} Continuation to pass control to when complete
-// Destroys the application with `name` for the authenticated user.
-//
-Apps.prototype.destory = function (name, callback) {
- this._request('DELETE', ['apps', name], callback, function (err, res, body) {
-
- });
-};
@@ -1,74 +0,0 @@
-/*
- * client.js: Client base for the Nodejitsu API clients.
- *
- * (C) 2010, Nodejitsu Inc.
- *
- */
-
-var eyes = require('eyes'),
- request = require('request'),
- jitsu = require('jitsu');
-
-//
-// ### function Client (options)
-// #### @options {Object} Options for this instance
-// Constructor function for the Client base responsible
-// for communicating with Nodejitsu's API
-//
-var Client = exports.Client = function (options) {
- this.options = options;
-};
-
-//
-// ### @private function _request (method, uri, [body], success, callback)
-// #### @method {string} HTTP method to use
-// #### @uri {Array} Locator for the Remote Resource
-// #### @body {Object} **optional** JSON Request Body
-// #### @success {function} Continuation to call upon successful transactions
-// #### @callback {function} Continuation to call if errors occur.
-// Makes a request to `this.remoteUri + uri` using `method` and any
-// `body` (JSON-only) if supplied. Short circuits to `callback` if the response
-// code from Nodejitsu matches `jitsu.failCodes`.
-//
-Client.prototype._request = function (method, uri /* variable arguments */) {
- var options, args = Array.prototype.slice.call(arguments),
- success = args.pop(),
- callback = args.pop(),
- body = typeof args[args.length - 1] === 'object' && args.pop(),
- encoded = jitsu.utils.base64.encode(this.options.auth);
-
- options = {
- method: method || 'GET',
- uri: this.options.remoteUri + '/' + uri.join('/'),
- headers: {
- 'Authorization': 'Basic ' + encoded,
- 'Content-Type': 'application/json'
- }
- };
-
- if (body) {
- options.body = JSON.stringify(body);
- }
-
- request(options, function (err, response, body) {
- if (err) {
- return callback(err);
- }
-
- try {
- var statusCode = response.statusCode.toString(),
- result = JSON.parse(body);
- }
- catch (ex) {
- // Ignore Errors
- }
-
- if (Object.keys(jitsu.failCodes).indexOf(statusCode) !== -1) {
- var error = new Error('Nodejitsu Error (' + statusCode + '): ' + jitsu.failCodes[statusCode]);
- error.result = result;
- return callback(error);
- }
-
- success(response, result);
- });
-};

0 comments on commit a183338

Please sign in to comment.