diff --git a/src/key/gen.js b/src/key/gen.js index 1523adc334..38612d9afe 100644 --- a/src/key/gen.js +++ b/src/key/gen.js @@ -2,16 +2,24 @@ const promisify = require('promisify-es6') +const transform = function (res, callback) { + callback(null, { + id: res.Id, + name: res.Name + }) +} + module.exports = (send) => { return promisify((args, opts, callback) => { if (typeof (opts) === 'function') { callback = opts opts = {} } - send({ + + send.andTransform({ path: 'key/gen', args: args, qs: opts - }, callback) + }, transform, callback) }) } diff --git a/src/key/import.js b/src/key/import.js index aec92081aa..9cea80e276 100644 --- a/src/key/import.js +++ b/src/key/import.js @@ -2,15 +2,22 @@ const promisify = require('promisify-es6') +const transform = function (res, callback) { + callback(null, { + id: res.Id, + name: res.Name + }) +} + module.exports = (send) => { return promisify((name, pem, password, callback) => { - send({ + send.andTransform({ path: 'key/import', args: name, qs: { pem: pem, password: password } - }, callback) + }, transform, callback) }) } diff --git a/src/key/list.js b/src/key/list.js index 7b58c2a6d4..bcd9bc8e2d 100644 --- a/src/key/list.js +++ b/src/key/list.js @@ -2,15 +2,25 @@ const promisify = require('promisify-es6') +const transform = function (res, callback) { + callback(null, res.Keys.map(key => { + return { + id: key.Id, + name: key.Name + } + })) +} + module.exports = (send) => { return promisify((opts, callback) => { if (typeof (opts) === 'function') { callback = opts opts = {} } - send({ + + send.andTransform({ path: 'key/list', qs: opts - }, callback) + }, transform, callback) }) } diff --git a/src/key/rename.js b/src/key/rename.js index 9fa9dda7e8..68b45f010b 100644 --- a/src/key/rename.js +++ b/src/key/rename.js @@ -2,11 +2,20 @@ const promisify = require('promisify-es6') +const transform = function (res, callback) { + callback(null, { + id: res.Id, + was: res.Was, + now: res.Now, + overwrite: res.Overwrite + }) +} + module.exports = (send) => { return promisify((oldName, newName, callback) => { - send({ + send.andTransform({ path: 'key/rename', args: [oldName, newName] - }, callback) + }, transform, callback) }) } diff --git a/src/key/rm.js b/src/key/rm.js index 7388dff61b..7e4e98500b 100644 --- a/src/key/rm.js +++ b/src/key/rm.js @@ -2,11 +2,18 @@ const promisify = require('promisify-es6') +const transform = function (res, callback) { + callback(null, { + id: res.Keys[0].Id, + name: res.Keys[0].Name + }) +} + module.exports = (send) => { return promisify((args, callback) => { - send({ + send.andTransform({ path: 'key/rm', args: args - }, callback) + }, transform, callback) }) }