k2hr3-api 1.0.24 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/ChangeLog +12 -0
  2. package/app.js +63 -30
  3. package/bin/run.sh +14 -0
  4. package/config/default.json +3 -2
  5. package/lib/k2hr3config.js +12 -0
  6. package/lib/k2hr3dkc.js +903 -13
  7. package/lib/k2hr3keys.js +1 -0
  8. package/lib/k2hr3tokens.js +147 -60
  9. package/package.json +10 -5
  10. package/routes/tenant.js +1014 -0
  11. package/routes/userTokens.js +77 -126
  12. package/tests/auto_all_spec.js +4 -0
  13. package/tests/auto_tenant.js +989 -0
  14. package/tests/auto_tenant_spec.js +79 -0
  15. package/tests/auto_usertokens.js +6 -6
  16. package/tests/manual_acr_delete.js +1 -0
  17. package/tests/manual_acr_get.js +1 -0
  18. package/tests/manual_acr_postput.js +1 -0
  19. package/tests/manual_allusertenant_get.js +58 -3
  20. package/tests/manual_extdata_get.js +1 -0
  21. package/tests/manual_list_gethead.js +1 -0
  22. package/tests/manual_policy_delete.js +1 -0
  23. package/tests/manual_policy_gethead.js +3 -1
  24. package/tests/manual_policy_postput.js +1 -0
  25. package/tests/manual_resource_delete.js +1 -0
  26. package/tests/manual_resource_gethead.js +1 -0
  27. package/tests/manual_resource_postput.js +1 -0
  28. package/tests/manual_role_delete.js +2 -0
  29. package/tests/manual_role_gethead.js +4 -0
  30. package/tests/manual_role_postput.js +2 -0
  31. package/tests/manual_service_delete.js +1 -0
  32. package/tests/manual_service_gethead.js +1 -0
  33. package/tests/manual_service_postput.js +1 -0
  34. package/tests/manual_tenant_delete.js +152 -0
  35. package/tests/manual_tenant_gethead.js +268 -0
  36. package/tests/manual_tenant_postput.js +293 -0
  37. package/tests/manual_test.sh +21 -7
  38. package/tests/manual_userdata_get.js +1 -0
  39. package/tests/manual_usertoken_gethead.js +1 -0
  40. package/tests/manual_usertoken_postput.js +1 -0
  41. package/tests/manual_version_get.js +1 -0
  42. package/tests/test.sh +2 -0
@@ -0,0 +1,79 @@
1
+ /*
2
+ * K2HR3 REST API
3
+ *
4
+ * Copyright 2023 Yahoo Japan Corporation.
5
+ *
6
+ * K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
7
+ * common management information for the cloud.
8
+ * K2HR3 can dynamically manage information as "who", "what", "operate".
9
+ * These are stored as roles, resources, policies in K2hdkc, and the
10
+ * client system can dynamically read and modify these information.
11
+ *
12
+ * For the full copyright and license information, please view
13
+ * the license file that was distributed with this source code.
14
+ *
15
+ * AUTHOR: Takeshi Nakatani
16
+ * CREATE: Thu Jul 6 2023
17
+ * REVISION:
18
+ *
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ var common = require('./auto_common'); // Common objects for Chai
24
+ var chai = common.chai; // eslint-disable-line no-unused-vars
25
+ var chaiHttp = common.chaiHttp; // eslint-disable-line no-unused-vars
26
+ var app = common.app; // eslint-disable-line no-unused-vars
27
+ var assert = common.assert; // eslint-disable-line no-unused-vars
28
+ var expect = common.expect; // eslint-disable-line no-unused-vars
29
+ var subproc = require('./auto_subprocesses');
30
+
31
+ //--------------------------------------------------------------
32
+ // Before in global section
33
+ //--------------------------------------------------------------
34
+ before(function(){ // eslint-disable-line no-undef
35
+ //
36
+ // Start all sub processes
37
+ //
38
+ subproc.start(this);
39
+ });
40
+
41
+ //--------------------------------------------------------------
42
+ // After in global section
43
+ //--------------------------------------------------------------
44
+ after(function(){ // eslint-disable-line no-undef
45
+ //
46
+ // Stop all sub processes
47
+ //
48
+ subproc.stop(this);
49
+ });
50
+
51
+ //--------------------------------------------------------------
52
+ // BeforeEach in global section
53
+ //--------------------------------------------------------------
54
+ beforeEach(function(){ // eslint-disable-line no-undef
55
+ // Nothing to do
56
+ });
57
+
58
+ //--------------------------------------------------------------
59
+ // AfterEach in global section
60
+ //--------------------------------------------------------------
61
+ afterEach(function(){ // eslint-disable-line no-undef
62
+ // Nothing to do
63
+ });
64
+
65
+ //--------------------------------------------------------------
66
+ // Sub describe section
67
+ //--------------------------------------------------------------
68
+ describe('SUB API TEST: TENANT', function(){ // eslint-disable-line no-undef
69
+ require('./auto_tenant');
70
+ });
71
+
72
+ /*
73
+ * Local variables:
74
+ * tab-width: 4
75
+ * c-basic-offset: 4
76
+ * End:
77
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
78
+ * vim<600: noexpandtab sw=4 ts=4
79
+ */
@@ -431,11 +431,11 @@ describe('API : USER TOKEN', function(){ // eslint-disable-line no-undef
431
431
  expect(res.body.scoped).to.be.a('boolean').to.be.false;
432
432
  expect(res.body.user).to.be.a('string').to.equal('dummyuser');
433
433
  expect(res.body.tenants).to.be.an.instanceof(Array).to.have.lengthOf(5);
434
- expect(res.body.tenants[0]).to.deep.equal({name: 'tenant0', display: 'dummy_tenant_0'});
435
- expect(res.body.tenants[1]).to.deep.equal({name: 'tenant1', display: 'dummy_tenant_1'});
436
- expect(res.body.tenants[2]).to.deep.equal({name: 'tenant2', display: 'dummy_tenant_2'});
437
- expect(res.body.tenants[3]).to.deep.equal({name: 'tenant3', display: 'dummy_tenant_3'});
438
- expect(res.body.tenants[4]).to.deep.equal({name: 'tenant4', display: 'dummy_tenant_4'});
434
+ expect(res.body.tenants[0]).to.deep.equal({name: 'tenant0', id: '1000', description: 'dummy tenant no.0', display: 'dummy_tenant_0'});
435
+ expect(res.body.tenants[1]).to.deep.equal({name: 'tenant1', id: '1001', description: 'dummy tenant no.1', display: 'dummy_tenant_1'});
436
+ expect(res.body.tenants[2]).to.deep.equal({name: 'tenant2', id: '1002', description: 'dummy tenant no.2', display: 'dummy_tenant_2'});
437
+ expect(res.body.tenants[3]).to.deep.equal({name: 'tenant3', id: '1003', description: 'dummy tenant no.3', display: 'dummy_tenant_3'});
438
+ expect(res.body.tenants[4]).to.deep.equal({name: 'tenant4', id: '1004', description: 'dummy tenant no.4', display: 'dummy_tenant_4'});
439
439
 
440
440
  done();
441
441
  });
@@ -455,7 +455,7 @@ describe('API : USER TOKEN', function(){ // eslint-disable-line no-undef
455
455
  expect(res.body.scoped).to.be.a('boolean').to.be.true;
456
456
  expect(res.body.user).to.be.a('string').to.equal('dummyuser');
457
457
  expect(res.body.tenants).to.be.an.instanceof(Array).to.have.lengthOf(1);
458
- expect(res.body.tenants[0]).to.deep.equal({name: 'tenant0', display: 'tenant0'});
458
+ expect(res.body.tenants[0]).to.deep.equal({name: 'tenant0', id: '1000', description: 'dummy tenant no.0', display: 'dummy_tenant_0'});
459
459
 
460
460
  done();
461
461
  });
@@ -63,6 +63,7 @@ function rawDeleteV1Acr(token, service)
63
63
  if(null !== cacerts.ca){
64
64
  options.ca = cacerts.ca;
65
65
  }
66
+ options.rejectUnauthorized = false; // always insecure for this manual test
66
67
  options.agent = new https.Agent(options);
67
68
  httpobj = https;
68
69
  }else{
@@ -86,6 +86,7 @@ function rawGetV1Acr(token, service, inputdata)
86
86
  if(null !== cacerts.ca){
87
87
  options.ca = cacerts.ca;
88
88
  }
89
+ options.rejectUnauthorized = false; // always insecure for this manual test
89
90
  options.agent = new https.Agent(options);
90
91
  httpobj = https;
91
92
  }else{
@@ -78,6 +78,7 @@ function rawPutPostV1Acr(method, tenant, token, service)
78
78
  if(null !== cacerts.ca){
79
79
  options.ca = cacerts.ca;
80
80
  }
81
+ options.rejectUnauthorized = false; // always insecure for this manual test
81
82
  options.agent = new https.Agent(options);
82
83
  httpobj = https;
83
84
  }else{
@@ -22,14 +22,69 @@
22
22
 
23
23
  var k2hr3 = require('../lib/k2hr3dkc');
24
24
 
25
+ var apiutil = require('../lib/k2hr3apiutil');
26
+ var r3Conf = require('../lib/k2hr3config').r3ApiConfig;
27
+ var apiConf = new r3Conf();
28
+
25
29
  // Debug logging objects
26
- //var r3logger = require('../lib/dbglogging');
30
+ var r3logger = require('../lib/dbglogging');
27
31
 
28
- //
32
+ //---------------------------------------------------------
33
+ // Configuration and port number from Environment
34
+ //---------------------------------------------------------
35
+ var dkcconf = null;
36
+ var dkcport = null;
37
+ var dkccuk = null;
38
+ (function()
39
+ {
40
+ if(!apiutil.isSafeEntity(dkcconf)){
41
+ var tmpdkcconf = apiConf.getK2hdkcConfig();
42
+ if(!apiutil.checkFileExist(tmpdkcconf)){
43
+ r3logger.elog('k2hdkc slave configuration file(' + tmpdkcconf + ') specified in config json does not exist, then try to check K2HDKC_SLAVE_CONF environemnt.');
44
+
45
+ tmpdkcconf = apiutil.getSafeString(process.env.K2HDKC_SLAVE_CONF);
46
+ if(!apiutil.checkFileExist(tmpdkcconf)){
47
+ r3logger.elog('k2hdkc slave configuration file(' + tmpdkcconf + ') specified by K2HDKC_SLAVE_CONF environemnt does not exist, then use default path(/etc/k2hdkc/slave.ini).');
48
+ tmpdkcconf = '/etc/k2hdkc/slave.ini';
49
+ }
50
+ }
51
+ dkcconf = tmpdkcconf;
52
+ }
53
+ if(!apiutil.isSafeEntity(dkcport)){
54
+ var tmpdkcport = apiConf.getK2hdkcPort();
55
+ if(isNaN(tmpdkcport) || null === tmpdkcport){
56
+ r3logger.elog('k2hdkc slave port number(' + JSON.stringify(tmpdkcport) + ') specified in config json is something wrong, then try to check K2HDKC_SLAVE_PORT environemnt.');
57
+
58
+ tmpdkcport = apiutil.getSafeString(process.env.K2HDKC_SLAVE_PORT);
59
+ if(!apiutil.isSafeString(tmpdkcport) || isNaN(tmpdkcport)){
60
+ r3logger.elog('k2hdkc slave port number(' + JSON.stringify(tmpdkcport) + ') specified by K2HDKC_SLAVE_PORT environment is something wrong, then use default port number(8031).');
61
+ tmpdkcport = 8031;
62
+ }
63
+ }
64
+ dkcport = parseInt(tmpdkcport);
65
+ }
66
+ if(!apiutil.isSafeEntity(dkccuk)){
67
+ var tmpdkccuk = apiConf.getK2hdkcCuk();
68
+ if(null === tmpdkccuk){
69
+ r3logger.mlog('k2hdkc slave cuk is not specified. then try to check K2HDKC_SLAVE_CUK environemnt.');
70
+
71
+ tmpdkccuk = apiutil.getSafeString(process.env.K2HDKC_SLAVE_CUK);
72
+ if(!apiutil.isSafeString(tmpdkccuk)){
73
+ r3logger.mlog('k2hdkc slave cuk is not specified by K2HDKC_SLAVE_CUK environment is something wrong, then not use cuk(null).');
74
+ tmpdkccuk = null;
75
+ }
76
+ }
77
+ dkccuk = tmpdkccuk;
78
+ }
79
+ }());
80
+
81
+ //---------------------------------------------------------
29
82
  // call library function directly
30
- //
83
+ //---------------------------------------------------------
31
84
  function printAllUserTenantService()
32
85
  {
86
+ console.log('\n[NOTE] You need to run this as root user for attaching CHMPX memory.\n');
87
+
33
88
  //
34
89
  // This is not API, so access to k2hdkc directly.
35
90
  //
@@ -74,6 +74,7 @@ function getV1ExtData(uri, path, ua, is_gzip)
74
74
  if(null !== cacerts.ca){
75
75
  options.ca = cacerts.ca;
76
76
  }
77
+ options.rejectUnauthorized = false; // always insecure for this manual test
77
78
  options.agent = new https.Agent(options);
78
79
  httpobj = https;
79
80
  }else{
@@ -82,6 +82,7 @@ function getV1ChildrenList(method, token, type, service, path, is_expand)
82
82
  if(null !== cacerts.ca){
83
83
  options.ca = cacerts.ca;
84
84
  }
85
+ options.rejectUnauthorized = false; // always insecure for this manual test
85
86
  options.agent = new https.Agent(options);
86
87
  httpobj = https;
87
88
  }else{
@@ -64,6 +64,7 @@ function deleteV1Policy(token, name)
64
64
  if(null !== cacerts.ca){
65
65
  options.ca = cacerts.ca;
66
66
  }
67
+ options.rejectUnauthorized = false; // always insecure for this manual test
67
68
  options.agent = new https.Agent(options);
68
69
  httpobj = https;
69
70
  }else{
@@ -70,6 +70,7 @@ function getV1Policy(token, name, service)
70
70
  if(null !== cacerts.ca){
71
71
  options.ca = cacerts.ca;
72
72
  }
73
+ options.rejectUnauthorized = false; // always insecure for this manual test
73
74
  options.agent = new https.Agent(options);
74
75
  httpobj = https;
75
76
  }else{
@@ -133,6 +134,7 @@ function headV1Policy(tenant, name, action, resource)
133
134
  if(null !== cacerts.ca){
134
135
  options.ca = cacerts.ca;
135
136
  }
137
+ options.rejectUnauthorized = false; // always insecure for this manual test
136
138
  options.agent = new https.Agent(options);
137
139
  httpobj = https;
138
140
  }else{
@@ -208,7 +210,7 @@ cliutil.getConsoleInput('Method(GET/HEAD) : ', true, false, function
208
210
  });
209
211
  });
210
212
 
211
- }else if(!apiutil.compareCaseString('head', _method)){
213
+ }else if(apiutil.compareCaseString('head', _method)){
212
214
  cliutil.getConsoleInput('Tenant name(allow null) : ', true, false, function(isbreak, tenant)
213
215
  {
214
216
  if(isbreak){
@@ -126,6 +126,7 @@ function postV1Policy(method, token, name, effect, action, resource, alias)
126
126
  if(null !== cacerts.ca){
127
127
  options.ca = cacerts.ca;
128
128
  }
129
+ options.rejectUnauthorized = false; // always insecure for this manual test
129
130
  options.agent = new https.Agent(options);
130
131
  httpobj = https;
131
132
  }else{
@@ -139,6 +139,7 @@ function deleteV1Resource(token_type, token, name, data_type, keynames, aliases,
139
139
  if(null !== cacerts.ca){
140
140
  options.ca = cacerts.ca;
141
141
  }
142
+ options.rejectUnauthorized = false; // always insecure for this manual test
142
143
  options.agent = new https.Agent(options);
143
144
  httpobj = https;
144
145
  }else{
@@ -129,6 +129,7 @@ function getV1Resource(is_get_req, token_type, token, name, service, is_expand,
129
129
  if(null !== cacerts.ca){
130
130
  options.ca = cacerts.ca;
131
131
  }
132
+ options.rejectUnauthorized = false; // always insecure for this manual test
132
133
  options.agent = new https.Agent(options);
133
134
  httpobj = https;
134
135
  }else{
@@ -165,6 +165,7 @@ function postV1Resource(method, token, querypath, name, datatype, data, reskeys,
165
165
  if(null !== cacerts.ca){
166
166
  options.ca = cacerts.ca;
167
167
  }
168
+ options.rejectUnauthorized = false; // always insecure for this manual test
168
169
  options.agent = new https.Agent(options);
169
170
  httpobj = https;
170
171
  }else{
@@ -86,6 +86,7 @@ function deleteV1Role(token, name, target_host, port, cuk)
86
86
  if(null !== cacerts.ca){
87
87
  options.ca = cacerts.ca;
88
88
  }
89
+ options.rejectUnauthorized = false; // always insecure for this manual test
89
90
  options.agent = new https.Agent(options);
90
91
  httpobj = https;
91
92
  }else{
@@ -173,6 +174,7 @@ function deleteV1_IPByCuk(addrs, port, cuk)
173
174
  if(null !== cacerts.ca){
174
175
  options.ca = cacerts.ca;
175
176
  }
177
+ options.rejectUnauthorized = false; // always insecure for this manual test
176
178
  options.agent = new https.Agent(options);
177
179
  httpobj = https;
178
180
  }else{
@@ -64,6 +64,7 @@ function getV1Role(token, name, is_expand)
64
64
  if(null !== cacerts.ca){
65
65
  options.ca = cacerts.ca;
66
66
  }
67
+ options.rejectUnauthorized = false; // always insecure for this manual test
67
68
  options.agent = new https.Agent(options);
68
69
  httpobj = https;
69
70
  }else{
@@ -130,6 +131,7 @@ function getV1RoleToken(token, name, expire)
130
131
  if(null !== cacerts.ca){
131
132
  options.ca = cacerts.ca;
132
133
  }
134
+ options.rejectUnauthorized = false; // always insecure for this manual test
133
135
  options.agent = new https.Agent(options);
134
136
  httpobj = https;
135
137
  }else{
@@ -191,6 +193,7 @@ function getV1RoleTokenList(token, name, expand)
191
193
  if(null !== cacerts.ca){
192
194
  options.ca = cacerts.ca;
193
195
  }
196
+ options.rejectUnauthorized = false; // always insecure for this manual test
194
197
  options.agent = new https.Agent(options);
195
198
  httpobj = https;
196
199
  }else{
@@ -264,6 +267,7 @@ function headV1Role(token, roleyrn, port, cuk)
264
267
  if(null !== cacerts.ca){
265
268
  options.ca = cacerts.ca;
266
269
  }
270
+ options.rejectUnauthorized = false; // always insecure for this manual test
267
271
  options.agent = new https.Agent(options);
268
272
  httpobj = https;
269
273
  }else{
@@ -107,6 +107,7 @@ function postV1Role(method, token, name, policies, alias)
107
107
  if(null !== cacerts.ca){
108
108
  options.ca = cacerts.ca;
109
109
  }
110
+ options.rejectUnauthorized = false; // always insecure for this manual test
110
111
  options.agent = new https.Agent(options);
111
112
  httpobj = https;
112
113
  }else{
@@ -244,6 +245,7 @@ function postV1RoleHost(method, is_user_token, token, name, target_host, port, c
244
245
  if(null !== cacerts.ca){
245
246
  options.ca = cacerts.ca;
246
247
  }
248
+ options.rejectUnauthorized = false; // always insecure for this manual test
247
249
  options.agent = new https.Agent(options);
248
250
  httpobj = https;
249
251
  }else{
@@ -69,6 +69,7 @@ function rawDeleteV1Service(token, service, tenant)
69
69
  if(null !== cacerts.ca){
70
70
  options.ca = cacerts.ca;
71
71
  }
72
+ options.rejectUnauthorized = false; // always insecure for this manual test
72
73
  options.agent = new https.Agent(options);
73
74
  httpobj = https;
74
75
  }else{
@@ -69,6 +69,7 @@ function rawGetHeadV1Service(method, token, service, tenant)
69
69
  if(null !== cacerts.ca){
70
70
  options.ca = cacerts.ca;
71
71
  }
72
+ options.rejectUnauthorized = false; // always insecure for this manual test
72
73
  options.agent = new https.Agent(options);
73
74
  httpobj = https;
74
75
  }else{
@@ -142,6 +142,7 @@ function rawPutPostV1Service(method, token, service, is_create, verify, is_verif
142
142
  if(null !== cacerts.ca){
143
143
  options.ca = cacerts.ca;
144
144
  }
145
+ options.rejectUnauthorized = false; // always insecure for this manual test
145
146
  options.agent = new https.Agent(options);
146
147
  httpobj = https;
147
148
  }else{
@@ -0,0 +1,152 @@
1
+ /*
2
+ * K2HR3 REST API
3
+ *
4
+ * Copyright 2023 Yahoo Japan Corporation.
5
+ *
6
+ * K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
7
+ * common management information for the cloud.
8
+ * K2HR3 can dynamically manage information as "who", "what", "operate".
9
+ * These are stored as roles, resources, policies in K2hdkc, and the
10
+ * client system can dynamically read and modify these information.
11
+ *
12
+ * For the full copyright and license information, please view
13
+ * the license file that was distributed with this source code.
14
+ *
15
+ * AUTHOR: Takeshi Nakatani
16
+ * CREATE: Mon Jun 3 2023
17
+ * REVISION:
18
+ *
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ var http = require('http');
24
+ var https = require('https');
25
+
26
+ var cacerts = require('../lib/cacerts');
27
+ var apiutil = require('../lib/k2hr3apiutil');
28
+ var cliutil = require('../lib/k2hr3cliutil');
29
+
30
+ // Debug logging objects
31
+ var r3logger = require('../lib/dbglogging');
32
+
33
+ //
34
+ // Hostname and port from env
35
+ //
36
+ var hostname = apiutil.getSafeString(process.env.APIHOST);
37
+ var hostport = apiutil.getSafeString(process.env.APIPORT);
38
+ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
39
+
40
+ //
41
+ // Request API for test
42
+ //
43
+ function deleteV1Tenant(token, name, id)
44
+ {
45
+ var headers = {
46
+ 'Content-Type': 'application/json',
47
+ 'Content-Length': 0,
48
+ 'X-Auth-Token': token
49
+ };
50
+ var options = {
51
+ 'host': hostname,
52
+ 'port': hostport,
53
+ 'path': '/v1/tenant/' + name + encodeURI('?id=' + id),
54
+ 'method': 'DELETE',
55
+ 'headers': headers
56
+ };
57
+
58
+ r3logger.dlog('request options = ' + JSON.stringify(options));
59
+ r3logger.dlog('request headers = ' + JSON.stringify(headers));
60
+
61
+ var httpobj;
62
+ if(is_https){
63
+ if(null !== cacerts.ca){
64
+ options.ca = cacerts.ca;
65
+ }
66
+ options.rejectUnauthorized = false; // always insecure for this manual test
67
+ options.agent = new https.Agent(options);
68
+ httpobj = https;
69
+ }else{
70
+ options.agent = new http.Agent(options);
71
+ httpobj = http;
72
+ }
73
+
74
+ var req = httpobj.request(options, function(res)
75
+ {
76
+ var response = '';
77
+ console.log('RESPONSE CODE = ' + res.statusCode);
78
+ r3logger.dlog('response status = ' + res.statusCode);
79
+ r3logger.dlog('response header = ' + JSON.stringify(res.headers));
80
+ res.setEncoding('utf8');
81
+
82
+ res.on('data', function (chunk)
83
+ {
84
+ r3logger.dlog('response chunk = ' + chunk);
85
+ response += chunk;
86
+ });
87
+
88
+ res.on('end', function(result) // eslint-disable-line no-unused-vars
89
+ {
90
+ r3logger.mlog(r3logger.dump(response)); // response is object(or not)
91
+ console.log('RESPONSE BODY = ' + JSON.stringify(response));
92
+ process.exit(0);
93
+ });
94
+ });
95
+
96
+ req.on('error', function(e)
97
+ {
98
+ r3logger.elog('problem with request: ' + e.message);
99
+ });
100
+ req.end();
101
+ }
102
+
103
+ //
104
+ // run
105
+ //
106
+ cliutil.getConsoleInput('Unscoped(or Scoped) user token : ', true, false, function(isbreak, token)
107
+ {
108
+ if(isbreak){
109
+ process.exit(0);
110
+ }
111
+ var _token = token;
112
+
113
+ cliutil.getConsoleInput('Tenant name : ', true, false, function(isbreak, tenant)
114
+ {
115
+ if(isbreak){
116
+ process.exit(0);
117
+ }
118
+
119
+ if(!apiutil.isSafeString(tenant)){
120
+ console.log('method DELETE must specify tenant name');
121
+ process.exit(0);
122
+ }
123
+ var _tenant = apiutil.getSafeString(tenant);
124
+
125
+ cliutil.getConsoleInput('Tenant id : ', true, false, function(isbreak, id)
126
+ {
127
+ if(isbreak){
128
+ process.exit(0);
129
+ }
130
+
131
+ if(!apiutil.isSafeString(id)){
132
+ console.log('method DELETE must specify tenant id');
133
+ process.exit(0);
134
+ }
135
+ var _id = apiutil.getSafeString(id);
136
+
137
+ //
138
+ // Run
139
+ //
140
+ deleteV1Tenant(_token, _tenant, _id);
141
+ });
142
+ });
143
+ });
144
+
145
+ /*
146
+ * Local variables:
147
+ * tab-width: 4
148
+ * c-basic-offset: 4
149
+ * End:
150
+ * vim600: noexpandtab sw=4 ts=4 fdm=marker
151
+ * vim<600: noexpandtab sw=4 ts=4
152
+ */