k2hr3-api 1.0.42 → 2.0.1

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 (149) hide show
  1. package/config/k2hr3-init.sh.templ +4 -4
  2. package/dist/.gitkeep +0 -0
  3. package/dist/src/app.js +262 -0
  4. package/{bin → dist/src/bin}/run.sh +1 -1
  5. package/dist/src/bin/watcher.js +113 -0
  6. package/dist/src/bin/www.js +217 -0
  7. package/dist/src/lib/basicipcheck.js +392 -0
  8. package/dist/src/lib/cacerts.js +106 -0
  9. package/dist/src/lib/dbglogging.js +190 -0
  10. package/dist/src/lib/dummyuserapi.js +719 -0
  11. package/dist/src/lib/ipwatch.js +354 -0
  12. package/dist/src/lib/k2hr3acrutil.js +532 -0
  13. package/dist/src/lib/k2hr3apiutil.js +1444 -0
  14. package/dist/src/lib/k2hr3cliutil.js +183 -0
  15. package/dist/src/lib/k2hr3config.js +832 -0
  16. package/dist/src/lib/k2hr3cryptutil.js +258 -0
  17. package/dist/src/lib/k2hr3dkc.js +12121 -0
  18. package/dist/src/lib/k2hr3extdata.js +198 -0
  19. package/dist/src/lib/k2hr3keys.js +207 -0
  20. package/dist/src/lib/k2hr3resutil.js +111 -0
  21. package/dist/src/lib/k2hr3template.js +6546 -0
  22. package/dist/src/lib/k2hr3tokens.js +2643 -0
  23. package/dist/src/lib/k2hr3userdata.js +296 -0
  24. package/dist/src/lib/k8soidc.js +1000 -0
  25. package/dist/src/lib/openstackapiv2.js +695 -0
  26. package/dist/src/lib/openstackapiv3.js +932 -0
  27. package/dist/src/lib/openstackep.js +667 -0
  28. package/{tests/auto_common.js → dist/src/lib/types.js} +4 -38
  29. package/dist/src/routes/acr.js +704 -0
  30. package/dist/src/routes/debugVerify.js +294 -0
  31. package/dist/src/routes/extdata.js +219 -0
  32. package/dist/src/routes/list.js +264 -0
  33. package/dist/src/routes/policy.js +840 -0
  34. package/dist/src/routes/resource.js +1489 -0
  35. package/dist/src/routes/role.js +2627 -0
  36. package/dist/src/routes/service.js +908 -0
  37. package/dist/src/routes/tenant.js +1141 -0
  38. package/dist/src/routes/userTokens.js +482 -0
  39. package/dist/src/routes/userdata.js +212 -0
  40. package/dist/src/routes/version.js +103 -0
  41. package/package.json +152 -121
  42. package/ChangeLog +0 -378
  43. package/app.js +0 -292
  44. package/bin/watcher +0 -122
  45. package/bin/www +0 -180
  46. package/eslint.config.mjs +0 -68
  47. package/lib/basicipcheck.js +0 -376
  48. package/lib/cacerts.js +0 -71
  49. package/lib/dbglogging.js +0 -151
  50. package/lib/dummyuserapi.js +0 -766
  51. package/lib/ipwatch.js +0 -379
  52. package/lib/k2hr3acrutil.js +0 -516
  53. package/lib/k2hr3apiutil.js +0 -1494
  54. package/lib/k2hr3cliutil.js +0 -191
  55. package/lib/k2hr3config.js +0 -826
  56. package/lib/k2hr3cryptutil.js +0 -254
  57. package/lib/k2hr3dkc.js +0 -12632
  58. package/lib/k2hr3extdata.js +0 -198
  59. package/lib/k2hr3keys.js +0 -234
  60. package/lib/k2hr3resutil.js +0 -100
  61. package/lib/k2hr3template.js +0 -6925
  62. package/lib/k2hr3tokens.js +0 -2799
  63. package/lib/k2hr3userdata.js +0 -312
  64. package/lib/k8soidc.js +0 -1012
  65. package/lib/openstackapiv2.js +0 -764
  66. package/lib/openstackapiv3.js +0 -1032
  67. package/lib/openstackep.js +0 -553
  68. package/routes/acr.js +0 -738
  69. package/routes/debugVerify.js +0 -263
  70. package/routes/extdata.js +0 -232
  71. package/routes/list.js +0 -270
  72. package/routes/policy.js +0 -869
  73. package/routes/resource.js +0 -1441
  74. package/routes/role.js +0 -2664
  75. package/routes/service.js +0 -894
  76. package/routes/tenant.js +0 -1095
  77. package/routes/userTokens.js +0 -511
  78. package/routes/userdata.js +0 -218
  79. package/routes/version.js +0 -108
  80. package/templ/Dockerfile.templ +0 -71
  81. package/tests/auto_acr.js +0 -1101
  82. package/tests/auto_acr_spec.js +0 -79
  83. package/tests/auto_all_spec.js +0 -142
  84. package/tests/auto_control_subprocess.sh +0 -243
  85. package/tests/auto_extdata.js +0 -220
  86. package/tests/auto_extdata_spec.js +0 -79
  87. package/tests/auto_init_config_json.sh +0 -275
  88. package/tests/auto_k2hdkc_server.ini +0 -109
  89. package/tests/auto_k2hdkc_slave.ini +0 -83
  90. package/tests/auto_list.js +0 -439
  91. package/tests/auto_list_spec.js +0 -79
  92. package/tests/auto_policy.js +0 -1579
  93. package/tests/auto_policy_spec.js +0 -79
  94. package/tests/auto_resource.js +0 -10956
  95. package/tests/auto_resource_spec.js +0 -79
  96. package/tests/auto_role.js +0 -6150
  97. package/tests/auto_role_spec.js +0 -79
  98. package/tests/auto_service.js +0 -770
  99. package/tests/auto_service_spec.js +0 -79
  100. package/tests/auto_subprocesses.js +0 -114
  101. package/tests/auto_template.sh +0 -126
  102. package/tests/auto_tenant.js +0 -1100
  103. package/tests/auto_tenant_spec.js +0 -79
  104. package/tests/auto_token_util.js +0 -219
  105. package/tests/auto_userdata.js +0 -292
  106. package/tests/auto_userdata_spec.js +0 -79
  107. package/tests/auto_usertokens.js +0 -565
  108. package/tests/auto_usertokens_spec.js +0 -79
  109. package/tests/auto_version.js +0 -127
  110. package/tests/auto_version_spec.js +0 -79
  111. package/tests/auto_watcher.js +0 -157
  112. package/tests/auto_watcher_spec.js +0 -79
  113. package/tests/k2hdkc_test.data +0 -986
  114. package/tests/k2hdkc_test_load.sh +0 -255
  115. package/tests/k2hr3template_test.js +0 -187
  116. package/tests/k2hr3template_test.sh +0 -339
  117. package/tests/k2hr3template_test_async.js +0 -216
  118. package/tests/k2hr3template_test_template.result +0 -7117
  119. package/tests/k2hr3template_test_template.txt +0 -3608
  120. package/tests/k2hr3template_test_vars.js +0 -194
  121. package/tests/manual_acr_delete.js +0 -143
  122. package/tests/manual_acr_get.js +0 -297
  123. package/tests/manual_acr_postput.js +0 -215
  124. package/tests/manual_allusertenant_get.js +0 -113
  125. package/tests/manual_extdata_get.js +0 -191
  126. package/tests/manual_k2hr3keys_get.js +0 -84
  127. package/tests/manual_list_gethead.js +0 -230
  128. package/tests/manual_policy_delete.js +0 -132
  129. package/tests/manual_policy_gethead.js +0 -275
  130. package/tests/manual_policy_postput.js +0 -297
  131. package/tests/manual_resource_delete.js +0 -433
  132. package/tests/manual_resource_gethead.js +0 -423
  133. package/tests/manual_resource_postput.js +0 -487
  134. package/tests/manual_role_delete.js +0 -404
  135. package/tests/manual_role_gethead.js +0 -547
  136. package/tests/manual_role_postput.js +0 -544
  137. package/tests/manual_service_delete.js +0 -153
  138. package/tests/manual_service_gethead.js +0 -178
  139. package/tests/manual_service_postput.js +0 -348
  140. package/tests/manual_tenant_delete.js +0 -186
  141. package/tests/manual_tenant_gethead.js +0 -268
  142. package/tests/manual_tenant_postput.js +0 -293
  143. package/tests/manual_test.sh +0 -352
  144. package/tests/manual_userdata_get.js +0 -173
  145. package/tests/manual_usertoken_gethead.js +0 -136
  146. package/tests/manual_usertoken_postput.js +0 -310
  147. package/tests/manual_version_get.js +0 -127
  148. package/tests/run_local_test_k2hdkc.sh +0 -174
  149. package/tests/test.sh +0 -333
@@ -1,215 +0,0 @@
1
- /*
2
- * K2HR3 REST API
3
- *
4
- * Copyright 2017 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 Nor 6 2017
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 rawPutPostV1Acr(method, tenant, token, service)
44
- {
45
- var strbody = '';
46
- var urlarg = '';
47
- if(apiutil.isSafeString(tenant)){
48
- if(apiutil.compareCaseString('POST', method)){
49
- strbody = {
50
- tenant: tenant
51
- };
52
- strbody = JSON.stringify(strbody);
53
- }else{
54
- urlarg = encodeURI('?tenant=' + tenant);
55
- }
56
- }
57
-
58
- var headers = {
59
- 'Content-Type': 'application/json',
60
- 'Content-Length': strbody.length,
61
- 'X-Auth-Token': 'U=' + token
62
- };
63
- var options = {
64
- 'host': hostname,
65
- 'port': hostport,
66
- 'path': '/v1/acr/' + service + urlarg,
67
- 'method': method,
68
- 'headers': headers
69
- };
70
-
71
- r3logger.dlog('request options = ' + JSON.stringify(options));
72
- r3logger.dlog('request headers = ' + JSON.stringify(headers));
73
- r3logger.dlog('request body = ' + apiutil.getSafeString(strbody));
74
-
75
- var httpobj;
76
- if(is_https){
77
- if(null !== cacerts.ca){
78
- options.ca = cacerts.ca;
79
- }
80
- options.rejectUnauthorized = false; // always insecure for this manual test
81
- options.agent = new https.Agent(options);
82
- httpobj = https;
83
- }else{
84
- options.agent = new http.Agent(options);
85
- httpobj = http;
86
- }
87
-
88
- var req = httpobj.request(options, function(res)
89
- {
90
- var response = '';
91
- console.log('RESPONSE CODE = ' + res.statusCode);
92
- r3logger.dlog('response status = ' + res.statusCode);
93
- r3logger.dlog('response header = ' + JSON.stringify(res.headers));
94
- res.setEncoding('utf8');
95
-
96
- res.on('data', function (chunk)
97
- {
98
- r3logger.dlog('response chunk = ' + chunk);
99
- response += chunk;
100
- });
101
-
102
- res.on('end', function(result) // eslint-disable-line no-unused-vars
103
- {
104
- r3logger.mlog(r3logger.dump(response)); // response is object(or not)
105
- console.log('RESPONSE BODY = ' + JSON.stringify(response));
106
- process.exit(0);
107
- });
108
- });
109
-
110
- req.on('error', function(e)
111
- {
112
- r3logger.elog('problem with request: ' + e.message);
113
- });
114
-
115
- // write data to request body
116
- if(apiutil.compareCaseString('POST', method)){
117
- req.write(strbody);
118
- }
119
- req.end();
120
- }
121
-
122
- //
123
- // Utility for inputting token for two pattern
124
- //
125
- // callback(error, tenant name(allow null), token string)
126
- //
127
- function rawInputToken(callback)
128
- {
129
- var _callback = callback;
130
-
131
- cliutil.getConsoleInput('Tenant name(allow empty) : ', true, false, function(isbreak, tenant)
132
- {
133
- if(isbreak){
134
- _callback('break for inputting tenant name');
135
- return;
136
- }
137
- var _tenant = apiutil.isSafeString(tenant) ? tenant.toLowerCase() : null;
138
- var _message;
139
- if(null === _tenant){
140
- _message = 'SCOPED user token : ';
141
- }else{
142
- _message = 'UNSCOPED user token : ';
143
- }
144
-
145
- cliutil.getConsoleInput(_message, true, false, function(isbreak, token)
146
- {
147
- if(isbreak){
148
- _callback('break for inputting token');
149
- return;
150
- }
151
- if(!apiutil.isSafeString(token)){
152
- _callback('token must be string');
153
- return;
154
- }
155
- var _token = token;
156
- _callback(null, _tenant, _token);
157
- });
158
- });
159
- }
160
-
161
- //
162
- // run
163
- //
164
- cliutil.getConsoleInput('Method(POST/PUT) : ', true, false, function(isbreak, method)
165
- {
166
- if(isbreak){
167
- process.exit(0);
168
- }
169
-
170
- var _method;
171
- if(apiutil.compareCaseString('post', method)){
172
- _method = 'POST';
173
- }else if(apiutil.compareCaseString('put', method)){
174
- _method = 'PUT';
175
- }else{
176
- console.log('method must be POST or PUT : ' + method);
177
- process.exit(0);
178
- }
179
-
180
- cliutil.getConsoleInput('Create base service name : ', true, false, function(isbreak, service)
181
- {
182
- if(isbreak){
183
- process.exit(0);
184
- }
185
- if(!apiutil.isSafeString(service)){
186
- console.log('service must be service name.');
187
- process.exit(0);
188
- }
189
- var _service = service;
190
-
191
- rawInputToken(function(error, tenant, token)
192
- {
193
- if(null !== error){
194
- console.log(error);
195
- process.exit(0);
196
- }
197
- var _tenant = tenant;
198
- var _token = token;
199
-
200
- //
201
- // run
202
- //
203
- rawPutPostV1Acr(_method, _tenant, _token, _service);
204
- });
205
- });
206
- });
207
-
208
- /*
209
- * Local variables:
210
- * tab-width: 4
211
- * c-basic-offset: 4
212
- * End:
213
- * vim600: noexpandtab sw=4 ts=4 fdm=marker
214
- * vim<600: noexpandtab sw=4 ts=4
215
- */
@@ -1,113 +0,0 @@
1
- /*
2
- * K2HR3 REST API
3
- *
4
- * Copyright 2017 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: Wed Jun 8 2017
17
- * REVISION:
18
- *
19
- */
20
-
21
- 'use strict';
22
-
23
- var k2hr3 = require('../lib/k2hr3dkc');
24
-
25
- var apiutil = require('../lib/k2hr3apiutil');
26
- var r3Conf = require('../lib/k2hr3config').r3ApiConfig;
27
- var apiConf = new r3Conf();
28
-
29
- // Debug logging objects
30
- var r3logger = require('../lib/dbglogging');
31
-
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
- //---------------------------------------------------------
82
- // call library function directly
83
- //---------------------------------------------------------
84
- function printAllUserTenantService()
85
- {
86
- console.log('\n[NOTE] You need to run this as root user for attaching CHMPX memory.\n');
87
-
88
- //
89
- // This is not API, so access to k2hdkc directly.
90
- //
91
- var allservices = k2hr3.getAllServices();
92
- console.log('all service list : ' + JSON.stringify(allservices));
93
-
94
- var alltenants = k2hr3.getAllTenants();
95
- console.log('all tenant list : ' + JSON.stringify(alltenants));
96
-
97
- var allusers = k2hr3.getAllUsers();
98
- console.log('all user list : ' + JSON.stringify(allusers));
99
- }
100
-
101
- //
102
- // run
103
- //
104
- printAllUserTenantService();
105
-
106
- /*
107
- * Local variables:
108
- * tab-width: 4
109
- * c-basic-offset: 4
110
- * End:
111
- * vim600: noexpandtab sw=4 ts=4 fdm=marker
112
- * vim<600: noexpandtab sw=4 ts=4
113
- */
@@ -1,191 +0,0 @@
1
- /*
2
- * K2HR3 REST API
3
- *
4
- * Copyright 2017 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 May 18 2020
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
- var cryptutil = require('../lib/k2hr3cryptutil');
30
-
31
- // Debug logging objects
32
- var r3logger = require('../lib/dbglogging');
33
-
34
- //
35
- // Hostname and port from env
36
- //
37
- var hostname = apiutil.getSafeString(process.env.APIHOST);
38
- var hostport = apiutil.getSafeString(process.env.APIPORT);
39
- var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
40
-
41
- //
42
- // Request API for test
43
- //
44
- function getV1ExtData(uri, path, ua, is_gzip)
45
- {
46
- var headers = {};
47
- var typehead = 'Content-Type';
48
- var uahead = 'User-Agent';
49
- var gziphead = 'Accept-Encoding';
50
-
51
- headers[typehead] = 'application/octet-stream';
52
- if(apiutil.isSafeString(ua)){
53
- headers[uahead] = ua;
54
- }
55
- if(is_gzip){
56
- headers[gziphead] = 'gzip';
57
- }
58
- var options = {
59
- 'host': hostname,
60
- 'port': hostport,
61
- 'method': 'GET'
62
- };
63
-
64
- options.headers = headers;
65
- options.path = '/v1/extdata/' + uri + '/' + path;
66
-
67
- r3logger.dlog('request options = ' + JSON.stringify(options));
68
- r3logger.dlog('request headers = ' + JSON.stringify(headers));
69
-
70
- var _is_gzip = is_gzip;
71
- var httpobj;
72
- if(is_https){
73
- if(null !== cacerts.ca){
74
- options.ca = cacerts.ca;
75
- }
76
- options.rejectUnauthorized = false; // always insecure for this manual test
77
- options.agent = new https.Agent(options);
78
- httpobj = https;
79
- }else{
80
- options.agent = new http.Agent(options);
81
- httpobj = http;
82
- }
83
-
84
- var req = httpobj.request(options, function(res)
85
- {
86
- var response;
87
-
88
- console.log('RESPONSE CODE = ' + res.statusCode);
89
- r3logger.dlog('response status = ' + res.statusCode);
90
- r3logger.dlog('response header = ' + JSON.stringify(res.headers));
91
-
92
- if(_is_gzip){
93
- response = [];
94
- }else{
95
- res.setEncoding('utf8');
96
- response = '';
97
- }
98
-
99
- res.on('data', function(chunk)
100
- {
101
- if(_is_gzip){
102
- response.push(chunk);
103
- }else{
104
- r3logger.dlog('response chunk = ' + chunk);
105
- response += chunk;
106
- }
107
- });
108
-
109
- res.on('end', function(result) // eslint-disable-line no-unused-vars
110
- {
111
- if(_is_gzip){
112
- // Buffer
113
- var buffer = Buffer.concat(response);
114
- r3logger.mlog(r3logger.dump(buffer)); // response is object(or not)
115
-
116
- var gunzipString= cryptutil.r3Gunzip(buffer);
117
- console.log('RESPONSE BODY(GUNZIP) = <<<\n' + gunzipString + '\n<<<');
118
- }else{
119
- // Text
120
- r3logger.mlog(r3logger.dump(response)); // response is object(or not)
121
- console.log('RESPONSE BODY = ' + response);
122
- }
123
- process.exit(0);
124
- });
125
- });
126
- req.on('error', function(e) {
127
- r3logger.elog('problem with request: ' + e.message);
128
- });
129
- req.end();
130
- }
131
-
132
- cliutil.getConsoleInput('extdata uri (/v1/extdata/<uri>/<path>) : ', true, false, function(isbreak, uri)
133
- {
134
- if(isbreak){
135
- process.exit(0);
136
- }
137
- var _uri = uri;
138
-
139
- if(!apiutil.isSafeString(_uri)){
140
- process.exit(0);
141
- }
142
-
143
- cliutil.getConsoleInput('extdata path (/v1/extdata/<uri>/<path>) : ', true, false, function(isbreak, path)
144
- {
145
- if(isbreak){
146
- process.exit(0);
147
- }
148
- var _path = path;
149
-
150
- if(!apiutil.isSafeString(_path)){
151
- process.exit(0);
152
- }
153
-
154
- cliutil.getConsoleInput('User-Agent (allowed empty) : ', true, false, function(isbreak, ua)
155
- {
156
- if(isbreak){
157
- process.exit(0);
158
- }
159
- var _ua = apiutil.getSafeString(ua);
160
-
161
- cliutil.getConsoleInput('Response Type (gzip or text(default)) : ', true, false, function(isbreak, type)
162
- {
163
- if(isbreak){
164
- process.exit(0);
165
- }
166
- var _type = type;
167
- var _is_gzip= false;
168
-
169
- if('' === apiutil.getSafeString(_type) || apiutil.compareCaseString('text', apiutil.getSafeString(_type))){
170
- _is_gzip = false;
171
- }else if(apiutil.compareCaseString('gzip', apiutil.getSafeString(_type))){
172
- _is_gzip = true;
173
- }else{
174
- process.exit(0);
175
- }
176
-
177
- // run
178
- getV1ExtData(_uri, _path, _ua, _is_gzip);
179
- });
180
- });
181
- });
182
- });
183
-
184
- /*
185
- * Local variables:
186
- * tab-width: 4
187
- * c-basic-offset: 4
188
- * End:
189
- * vim600: noexpandtab sw=4 ts=4 fdm=marker
190
- * vim<600: noexpandtab sw=4 ts=4
191
- */
@@ -1,84 +0,0 @@
1
- /*
2
- * K2HR3 REST API
3
- *
4
- * Copyright 2017 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: Wed Jun 8 2017
17
- * REVISION:
18
- *
19
- */
20
-
21
- 'use strict';
22
-
23
- var util = require('util');
24
-
25
- var apiutil = require('../lib/k2hr3apiutil');
26
- var cliutil = require('../lib/k2hr3cliutil');
27
- var r3keys = require('../lib/k2hr3keys').getK2hr3Keys;
28
-
29
- // Debug logging objects
30
- //var r3logger = require('../lib/dbglogging');
31
-
32
- //
33
- // run
34
- //
35
- cliutil.getConsoleInput('user(allow null) : ', true, false, function(isbreak, user)
36
- {
37
- if(isbreak){
38
- process.exit(0);
39
- }
40
- var _user = null;
41
- if('' !== apiutil.getSafeString(user) && !apiutil.compareCaseString('null', apiutil.getSafeString(user))){
42
- _user = user;
43
- }
44
-
45
- cliutil.getConsoleInput('tenant(allow null) : ', true, false, function(isbreak, tenant)
46
- {
47
- if(isbreak){
48
- process.exit(0);
49
- }
50
- var _tenant = null;
51
- if('' !== apiutil.getSafeString(tenant) && !apiutil.compareCaseString('null', apiutil.getSafeString(tenant))){
52
- _tenant = tenant;
53
- }
54
-
55
- cliutil.getConsoleInput('service(allow null) : ', true, false, function(isbreak, service)
56
- {
57
- if(isbreak){
58
- process.exit(0);
59
- }
60
- var _service = null;
61
-
62
- if('' !== apiutil.getSafeString(service) && !apiutil.compareCaseString('null', apiutil.getSafeString(service))){
63
- _service = service;
64
- }
65
-
66
- var keys = r3keys(_user, _tenant, _service);
67
- var dumpdata = util.inspect(keys, {showHidden: true, depth: null, maxArrayLength: 1000});
68
-
69
- console.log('user = ' + apiutil.getSafeString(user));
70
- console.log('tenant = ' + apiutil.getSafeString(tenant));
71
- console.log('service = ' + apiutil.getSafeString(service));
72
- console.log('keys = \n' + dumpdata);
73
- });
74
- });
75
- });
76
-
77
- /*
78
- * Local variables:
79
- * tab-width: 4
80
- * c-basic-offset: 4
81
- * End:
82
- * vim600: noexpandtab sw=4 ts=4 fdm=marker
83
- * vim<600: noexpandtab sw=4 ts=4
84
- */