diff --git a/lib/cloudapi2.js b/lib/cloudapi2.js index cb9139d..f62ddc1 100644 --- a/lib/cloudapi2.js +++ b/lib/cloudapi2.js @@ -298,19 +298,9 @@ CloudAPI.prototype.listKeys = function listKeys(opts, cb) { * XXX document this, see the api doc above :) * @param {Function} callback of the form `function (err, images, res)` */ -CloudAPI.prototype.listImages = function listImages(options, callback) { - var self = this; - if (callback === undefined) { - callback = options; - options = {}; - } - assert.object(options, 'options'); - assert.func(callback, 'callback'); - - var endpoint = self._path(format('/%s/images', self.user), options); - self._request(endpoint, function (err, req, res, body) { - callback(err, body, res); - }); +CloudAPI.prototype.listImages = function listImages(opts, cb) { + var endpoint = sprintf('/%s/images', this.user); + this._passThrough(endpoint, opts, cb); }; @@ -339,17 +329,9 @@ CloudAPI.prototype.getImage = function getImage(options, callback) { // ---- packages -CloudAPI.prototype.listPackages = function listPackages(options, callback) { - var self = this; - if (typeof (options) === 'function') { - callback = options; - options = {}; - } - - var endpoint = self._path(format('/%s/packages', self.user), options); - self._request(endpoint, function (err, req, res, body) { - callback(err, body, res); - }); +CloudAPI.prototype.listPackages = function listPackages(opts, cb) { + var endpoint = sprintf('/%s/packages', this.user); + this._passThrough(endpoint, opts, cb); }; CloudAPI.prototype.getPackage = function getPackage(options, callback) {