From a0e7a97729b10203e62763b0d3fe9eddd8df0419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 6 Jul 2017 14:13:21 +0300 Subject: [PATCH] MXS-1300: Add create/destroy/list commands for users Users can now be listed, created and destroyed via MaxCtrl. --- client/maxctrl/lib/create.js | 14 ++++++++++++++ client/maxctrl/lib/destroy.js | 3 +++ client/maxctrl/lib/list.js | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/client/maxctrl/lib/create.js b/client/maxctrl/lib/create.js index b13747774..aa7162f97 100644 --- a/client/maxctrl/lib/create.js +++ b/client/maxctrl/lib/create.js @@ -159,6 +159,20 @@ exports.builder = function(yargs) { doRequest('services/' + argv.service + '/listeners', null, {method: 'POST', body: listener}) }) + .command('user ', 'Create a new network user', {}, function(argv) { + + var user = { + 'data': { + 'id': argv.name, + 'type': 'inet', + 'attributes': { + 'password': argv.password + } + } + } + + doRequest('users/inet', null, {method: 'POST', body: user}) + }) .usage('Usage: create ') .help() diff --git a/client/maxctrl/lib/destroy.js b/client/maxctrl/lib/destroy.js index cc2dfb923..94c91549d 100644 --- a/client/maxctrl/lib/destroy.js +++ b/client/maxctrl/lib/destroy.js @@ -26,6 +26,9 @@ exports.builder = function(yargs) { .command('listener ', 'Destroy an unused listener', {}, function(argv) { doRequest('services/' + argv.service + '/listeners/' + argv.name, null, {method: 'DELETE'}) }) + .command('user ', 'Remove a network user', {}, function(argv) { + doRequest('users/inet/' + argv.name, null, {method: 'DELETE'}) + }) .usage('Usage: destroy ') .help() .command('*', 'the default command', {}, () => { diff --git a/client/maxctrl/lib/list.js b/client/maxctrl/lib/list.js index fb1583de8..b18fb3ce8 100644 --- a/client/maxctrl/lib/list.js +++ b/client/maxctrl/lib/list.js @@ -65,6 +65,11 @@ exports.builder = function(yargs) { {'Version': 'attributes.version'} ]) }) + .command('users', 'List created network users', {}, function() { + getCollection('users/inet',[ + {'Name':'id'} + ]) + }) .usage('Usage: list ') .help() .command('*', 'the default command', {}, () => {