k2hr3-api 1.0.37 → 1.0.39
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.
- package/ChangeLog +12 -0
- package/README.md +31 -31
- package/app.js +6 -10
- package/bin/run.sh +21 -21
- package/bin/www +1 -1
- package/config/k2hr3-init.sh.templ +5 -5
- package/eslint.config.mjs +68 -0
- package/lib/cacerts.js +8 -7
- package/lib/dummyuserapi.js +1 -1
- package/lib/ipwatch.js +1 -1
- package/lib/k2hr3acrutil.js +12 -14
- package/lib/k2hr3apiutil.js +5 -5
- package/lib/k2hr3cryptutil.js +2 -0
- package/lib/k2hr3dkc.js +25 -28
- package/lib/k2hr3template.js +54 -52
- package/lib/k2hr3tokens.js +4 -4
- package/lib/k8soidc.js +3 -3
- package/lib/openstackapiv2.js +51 -52
- package/lib/openstackapiv3.js +86 -87
- package/lib/openstackep.js +46 -46
- package/package.json +8 -8
- package/routes/acr.js +66 -110
- package/routes/debugVerify.js +12 -14
- package/routes/extdata.js +24 -40
- package/routes/list.js +24 -36
- package/routes/policy.js +72 -120
- package/routes/resource.js +110 -165
- package/routes/role.js +177 -295
- package/routes/service.js +54 -90
- package/routes/userTokens.js +1 -1
- package/routes/userdata.js +12 -20
- package/routes/version.js +39 -23
- package/tests/auto_control_subprocess.sh +9 -9
- package/tests/auto_init_config_json.sh +3 -3
- package/tests/auto_resource.js +417 -478
- package/tests/auto_role.js +55 -71
- package/tests/auto_template.sh +4 -4
- package/tests/auto_version.js +39 -23
- package/tests/k2hdkc_test_load.sh +9 -9
- package/tests/k2hr3template_test.sh +12 -12
- package/tests/k2hr3template_test_vars.js +60 -62
- package/tests/manual_acr_delete.js +11 -12
- package/tests/manual_acr_get.js +9 -10
- package/tests/manual_acr_postput.js +12 -13
- package/tests/manual_extdata_get.js +5 -6
- package/tests/manual_list_gethead.js +12 -13
- package/tests/manual_policy_delete.js +12 -13
- package/tests/manual_policy_gethead.js +27 -27
- package/tests/manual_policy_postput.js +21 -23
- package/tests/manual_resource_delete.js +11 -15
- package/tests/manual_resource_gethead.js +11 -14
- package/tests/manual_resource_postput.js +18 -21
- package/tests/manual_role_delete.js +22 -28
- package/tests/manual_role_gethead.js +53 -53
- package/tests/manual_role_postput.js +28 -31
- package/tests/manual_service_delete.js +11 -13
- package/tests/manual_service_gethead.js +13 -15
- package/tests/manual_service_postput.js +10 -11
- package/tests/manual_test.sh +10 -10
- package/tests/manual_userdata_get.js +14 -15
- package/tests/manual_usertoken_gethead.js +12 -14
- package/tests/manual_usertoken_postput.js +23 -26
- package/tests/manual_version_get.js +12 -13
- package/tests/run_local_test_k2hdkc.sh +4 -4
- package/tests/test.sh +12 -12
|
@@ -27,32 +27,31 @@
|
|
|
27
27
|
// for testing. You can specify these files for k2hr3template_test.sh
|
|
28
28
|
//
|
|
29
29
|
|
|
30
|
-
/* eslint-disable indent */
|
|
31
30
|
module.exports = {
|
|
32
31
|
'statement_print_test_00': 'value_00',
|
|
33
32
|
'formula_variable_00': 'value_name_00',
|
|
34
|
-
'formula_variable_01':
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
'formula_variable_02':
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
'formula_variable_array_01':
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
'formula_variable_object_01':
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
33
|
+
'formula_variable_01': [
|
|
34
|
+
'value_01[0]'
|
|
35
|
+
],
|
|
36
|
+
'formula_variable_02': {
|
|
37
|
+
'value_name_00': 'value_02{value_name_00}'
|
|
38
|
+
},
|
|
39
|
+
'formula_variable_array_01': [
|
|
40
|
+
'array_value_00',
|
|
41
|
+
'array_value_01'
|
|
42
|
+
],
|
|
43
|
+
'formula_variable_object_01': {
|
|
44
|
+
'object_key_00': 'object_value_00',
|
|
45
|
+
'object_key_01': 'object_value_01',
|
|
46
|
+
'object_key_02': [
|
|
47
|
+
'object_value_02_01',
|
|
48
|
+
'object_value_02_02'
|
|
49
|
+
],
|
|
50
|
+
'object_key_03': {
|
|
51
|
+
'object_valkey_03_00': true,
|
|
52
|
+
'object_valkey_03_01': 'object_valval_03_01'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
56
55
|
'formula_calculate_not_00': true,
|
|
57
56
|
'formula_calculate_not_01': false,
|
|
58
57
|
'formula_calculate_inc_00': 0,
|
|
@@ -143,48 +142,47 @@ module.exports = {
|
|
|
143
142
|
'formula_syntax_for_03': 0,
|
|
144
143
|
'formula_syntax_for_04': 1,
|
|
145
144
|
'formula_syntax_for_05': 'string',
|
|
146
|
-
'formula_syntax_for_06':
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
'formula_syntax_for_07':
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
145
|
+
'formula_syntax_for_06': [
|
|
146
|
+
'string00',
|
|
147
|
+
'string01'
|
|
148
|
+
],
|
|
149
|
+
'formula_syntax_for_07': {
|
|
150
|
+
'key_1': true,
|
|
151
|
+
'key_2': false
|
|
152
|
+
},
|
|
154
153
|
'formula_syntax_foreach_00': [],
|
|
155
|
-
'formula_syntax_foreach_01':
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
'formula_syntax_foreach_02':
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
'formula_syntax_foreach_03':
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
'formula_syntax_foreach_04':
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
154
|
+
'formula_syntax_foreach_01': [
|
|
155
|
+
null
|
|
156
|
+
],
|
|
157
|
+
'formula_syntax_foreach_02': [
|
|
158
|
+
true,
|
|
159
|
+
false
|
|
160
|
+
],
|
|
161
|
+
'formula_syntax_foreach_03': [
|
|
162
|
+
0,
|
|
163
|
+
1
|
|
164
|
+
],
|
|
165
|
+
'formula_syntax_foreach_04': [
|
|
166
|
+
'string00',
|
|
167
|
+
'string01'
|
|
168
|
+
],
|
|
170
169
|
'formula_syntax_foreach_10': {},
|
|
171
|
-
'formula_syntax_foreach_11':
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
'formula_syntax_foreach_12':
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
'formula_syntax_foreach_13':
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
'formula_syntax_foreach_14':
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
170
|
+
'formula_syntax_foreach_11': {
|
|
171
|
+
'key': null
|
|
172
|
+
},
|
|
173
|
+
'formula_syntax_foreach_12': {
|
|
174
|
+
'key_1': true,
|
|
175
|
+
'key_2': false
|
|
176
|
+
},
|
|
177
|
+
'formula_syntax_foreach_13': {
|
|
178
|
+
'key_1': 0,
|
|
179
|
+
'key_2': 1
|
|
180
|
+
},
|
|
181
|
+
'formula_syntax_foreach_14': {
|
|
182
|
+
'key_1': 'string00',
|
|
183
|
+
'key_2': 'string01'
|
|
184
|
+
}
|
|
186
185
|
};
|
|
187
|
-
/* eslint-enable indent */
|
|
188
186
|
|
|
189
187
|
/*
|
|
190
188
|
* Local variables:
|
|
@@ -42,18 +42,17 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
42
42
|
//
|
|
43
43
|
function rawDeleteV1Acr(token, service)
|
|
44
44
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
45
|
+
var headers = {
|
|
46
|
+
'Content-Type': 'application/json',
|
|
47
|
+
'X-Auth-Token': token
|
|
48
|
+
};
|
|
49
|
+
var options = {
|
|
50
|
+
'host': hostname,
|
|
51
|
+
'port': hostport,
|
|
52
|
+
'path': '/v1/acr/' + service,
|
|
53
|
+
'method': 'DELETE',
|
|
54
|
+
'headers': headers
|
|
55
|
+
};
|
|
57
56
|
|
|
58
57
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
59
58
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
package/tests/manual_acr_get.js
CHANGED
|
@@ -62,16 +62,15 @@ function rawGetV1Acr(token, service, inputdata)
|
|
|
62
62
|
urlarg = encodeURI(urlarg);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
65
|
+
var headers = {
|
|
66
|
+
'Content-Type': 'application/json'
|
|
67
|
+
};
|
|
68
|
+
var options = {
|
|
69
|
+
'host': hostname,
|
|
70
|
+
'port': hostport,
|
|
71
|
+
'path': '/v1/acr/' + service + urlarg,
|
|
72
|
+
'method': 'GET'
|
|
73
|
+
};
|
|
75
74
|
|
|
76
75
|
if(apiutil.isSafeString(token)){
|
|
77
76
|
headers['X-Auth-Token'] = token;
|
|
@@ -55,19 +55,18 @@ function rawPutPostV1Acr(method, tenant, token, service)
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
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
|
+
};
|
|
71
70
|
|
|
72
71
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
73
72
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -43,7 +43,6 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
43
43
|
//
|
|
44
44
|
function getV1ExtData(uri, path, ua, is_gzip)
|
|
45
45
|
{
|
|
46
|
-
/* eslint-disable indent, no-mixed-spaces-and-tabs */
|
|
47
46
|
var headers = {};
|
|
48
47
|
var typehead = 'Content-Type';
|
|
49
48
|
var uahead = 'User-Agent';
|
|
@@ -56,11 +55,11 @@ function getV1ExtData(uri, path, ua, is_gzip)
|
|
|
56
55
|
if(is_gzip){
|
|
57
56
|
headers[gziphead] = 'gzip';
|
|
58
57
|
}
|
|
59
|
-
var options
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
var options = {
|
|
59
|
+
'host': hostname,
|
|
60
|
+
'port': hostport,
|
|
61
|
+
'method': 'GET'
|
|
62
|
+
};
|
|
64
63
|
|
|
65
64
|
options.headers = headers;
|
|
66
65
|
options.path = '/v1/extdata/' + uri + '/' + path;
|
|
@@ -60,19 +60,18 @@ function getV1ChildrenList(method, token, type, service, path, is_expand)
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
63
|
+
var headers = {
|
|
64
|
+
'Content-Type': 'application/json',
|
|
65
|
+
'Content-Length': 0,
|
|
66
|
+
'X-Auth-Token': token
|
|
67
|
+
};
|
|
68
|
+
var options = {
|
|
69
|
+
'host': hostname,
|
|
70
|
+
'port': hostport,
|
|
71
|
+
'path': entrypath,
|
|
72
|
+
'method': method,
|
|
73
|
+
'headers': headers
|
|
74
|
+
};
|
|
76
75
|
|
|
77
76
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
78
77
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -42,19 +42,18 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
42
42
|
//
|
|
43
43
|
function deleteV1Policy(token, name)
|
|
44
44
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
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/policy/' + name,
|
|
54
|
+
'method': 'DELETE',
|
|
55
|
+
'headers': headers
|
|
56
|
+
};
|
|
58
57
|
|
|
59
58
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
60
59
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -48,19 +48,18 @@ function getV1Policy(token, name, service)
|
|
|
48
48
|
urlarg = encodeURI('?service=' + service);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
51
|
+
var headers = {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
'Content-Length': 0,
|
|
54
|
+
'X-Auth-Token': token
|
|
55
|
+
};
|
|
56
|
+
var options = {
|
|
57
|
+
'host': hostname,
|
|
58
|
+
'port': hostport,
|
|
59
|
+
'path': '/v1/policy/' + name + urlarg,
|
|
60
|
+
'method': 'GET',
|
|
61
|
+
'headers': headers
|
|
62
|
+
};
|
|
64
63
|
|
|
65
64
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
66
65
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -109,22 +108,23 @@ function getV1Policy(token, name, service)
|
|
|
109
108
|
|
|
110
109
|
function headV1Policy(tenant, name, action, resource)
|
|
111
110
|
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var urlarg
|
|
111
|
+
var headers = {
|
|
112
|
+
'Content-Type': 'application/json',
|
|
113
|
+
'Content-Length': 0
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
var urlarg = '?resource=' + resource + '&action=' + action;
|
|
118
117
|
if(apiutil.isSafeString(tenant)){
|
|
119
|
-
urlarg
|
|
118
|
+
urlarg += '&tenant=' + tenant;
|
|
120
119
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
|
|
121
|
+
var options = {
|
|
122
|
+
'host': hostname,
|
|
123
|
+
'port': hostport,
|
|
124
|
+
'path': '/v1/policy/' + name + encodeURI(urlarg),
|
|
125
|
+
'method': 'HEAD',
|
|
126
|
+
'headers': headers
|
|
127
|
+
};
|
|
128
128
|
|
|
129
129
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
130
130
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -43,31 +43,29 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
43
43
|
//
|
|
44
44
|
function postV1Policy(method, token, name, effect, action, resource, alias)
|
|
45
45
|
{
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
46
|
+
var strbody = '';
|
|
47
|
+
var headers = {
|
|
48
|
+
'Content-Type': 'application/json',
|
|
49
|
+
'X-Auth-Token': token
|
|
50
|
+
};
|
|
51
|
+
var options = {
|
|
52
|
+
'host': hostname,
|
|
53
|
+
'port': hostport,
|
|
54
|
+
'path': '/v1/policy',
|
|
55
|
+
'method': method
|
|
56
|
+
};
|
|
58
57
|
|
|
59
58
|
if(apiutil.compareCaseString('post', method)){
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
59
|
+
var body = {
|
|
60
|
+
'policy': {
|
|
61
|
+
'name': name,
|
|
62
|
+
'effect': effect,
|
|
63
|
+
'action': action,
|
|
64
|
+
'resource': resource,
|
|
65
|
+
'condition': null,
|
|
66
|
+
'alias': alias
|
|
67
|
+
}
|
|
68
|
+
};
|
|
71
69
|
|
|
72
70
|
strbody = JSON.stringify(body);
|
|
73
71
|
headers['Content-Length'] = strbody.length;
|
|
@@ -43,12 +43,10 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
43
43
|
//
|
|
44
44
|
function deleteV1Resource(token_type, token, name, data_type, keynames, aliases, port, cuk, roleyrn)
|
|
45
45
|
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
46
|
+
var headers = {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
'Content-Length': 0,
|
|
49
|
+
};
|
|
52
50
|
|
|
53
51
|
if(apiutil.isSafeString(token)){
|
|
54
52
|
headers['X-Auth-Token'] = token;
|
|
@@ -121,15 +119,13 @@ function deleteV1Resource(token_type, token, name, data_type, keynames, aliases,
|
|
|
121
119
|
}
|
|
122
120
|
}
|
|
123
121
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
};
|
|
132
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
122
|
+
var options = {
|
|
123
|
+
'host': hostname,
|
|
124
|
+
'port': hostport,
|
|
125
|
+
'path': '/v1/resource/' + name + encodeURI(urlarg),
|
|
126
|
+
'method': 'DELETE',
|
|
127
|
+
'headers': headers
|
|
128
|
+
};
|
|
133
129
|
|
|
134
130
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
135
131
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -43,12 +43,10 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
43
43
|
//
|
|
44
44
|
function getV1Resource(is_get_req, token_type, token, name, service, is_expand, data_type, keyname, port, cuk, roleyrn)
|
|
45
45
|
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
46
|
+
var headers = {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
'Content-Length': 0,
|
|
49
|
+
};
|
|
52
50
|
|
|
53
51
|
if(apiutil.isSafeString(token)){
|
|
54
52
|
headers['X-Auth-Token'] = token;
|
|
@@ -112,14 +110,13 @@ function getV1Resource(is_get_req, token_type, token, name, service, is_expand,
|
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
113
|
+
var options = {
|
|
114
|
+
'host': hostname,
|
|
115
|
+
'port': hostport,
|
|
116
|
+
'path': '/v1/resource/' + name + encodeURI(urlarg),
|
|
117
|
+
'method': (is_get_req ? 'GET' : 'HEAD'),
|
|
118
|
+
'headers': headers
|
|
119
|
+
};
|
|
123
120
|
|
|
124
121
|
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
125
122
|
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
@@ -42,20 +42,19 @@ var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
|
42
42
|
//
|
|
43
43
|
function postV1Resource(method, token, querypath, name, datatype, data, reskeys, alias, port, cuk, roleyrn)
|
|
44
44
|
{
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
45
|
+
var strbody = '';
|
|
46
|
+
var headers = {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
};
|
|
50
49
|
if(apiutil.isSafeString(token)){
|
|
51
50
|
headers['X-Auth-Token'] = token;
|
|
52
51
|
}
|
|
53
|
-
var options
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
var options = {
|
|
53
|
+
'host': hostname,
|
|
54
|
+
'port': hostport,
|
|
55
|
+
'path': '/v1/resource' + apiutil.getSafeString(querypath),
|
|
56
|
+
'method': method
|
|
57
|
+
};
|
|
59
58
|
|
|
60
59
|
if(!apiutil.compareCaseString('string', datatype) && !apiutil.compareCaseString('object', datatype)){
|
|
61
60
|
datatype = 'string'; // default data type is string
|
|
@@ -68,15 +67,13 @@ function postV1Resource(method, token, querypath, name, datatype, data, reskeys,
|
|
|
68
67
|
data = apiutil.parseJSON(data);
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
};
|
|
79
|
-
/* eslint-enable indent, no-mixed-spaces-and-tabs */
|
|
70
|
+
var body = {
|
|
71
|
+
'resource': {
|
|
72
|
+
'type': datatype,
|
|
73
|
+
'data': data, // if datatype is string, this includes control codes
|
|
74
|
+
'keys': reskeys
|
|
75
|
+
}
|
|
76
|
+
};
|
|
80
77
|
|
|
81
78
|
if(apiutil.isSafeString(name)){
|
|
82
79
|
body.resource.name = name;
|
|
@@ -274,7 +271,7 @@ function rawGetInputKeys(str)
|
|
|
274
271
|
try{
|
|
275
272
|
// parse JSON
|
|
276
273
|
result = JSON.parse(str);
|
|
277
|
-
}catch(err){
|
|
274
|
+
}catch(err){ // eslint-disable-line no-unused-vars
|
|
278
275
|
// key=val,key=val...
|
|
279
276
|
result = {};
|
|
280
277
|
// parse ','
|