Skip to content

Commit f91cdde

Browse files
authored
feat(getSettings): allow advanced=1 (#650)
Fixes #637 This is an undocumented parameter, which has enterprise usage, which is why I didn't add it to the docblock. cc @seafoox
1 parent 8cb52db commit f91cdde

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
lines changed

src/Index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,20 @@ Index.prototype.clearIndex = function(callback) {
608608
* error: null or Error('message')
609609
* content: the settings object or the error message if a failure occured
610610
*/
611-
Index.prototype.getSettings = function(callback) {
612-
var indexObj = this;
611+
Index.prototype.getSettings = function(opts, callback) {
612+
if (arguments.length === 1 || typeof opts === 'function') {
613+
callback = opts;
614+
opts = {};
615+
}
616+
617+
var indexName = encodeURIComponent(this.indexName);
613618
return this.as._jsonRequest({
614619
method: 'GET',
615-
url: '/1/indexes/' + encodeURIComponent(indexObj.indexName) + '/settings?getVersion=2',
620+
url:
621+
'/1/indexes/' +
622+
indexName +
623+
'/settings?getVersion=2' +
624+
(opts.advanced ? '&advanced=' + opts.advanced : ''),
616625
hostType: 'read',
617626
callback: callback
618627
});
Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
11
'use strict';
22

3-
module.exports = {
4-
object: 'index',
5-
methodName: 'getSettings',
6-
testName: 'index.getSettings(cb)',
7-
action: 'read',
8-
expectedRequest: {
9-
method: 'GET',
10-
URL: {
11-
pathname: '/1/indexes/%s/settings',
12-
query: {
13-
getVersion: '2'
3+
module.exports = [
4+
{
5+
object: 'index',
6+
methodName: 'getSettings',
7+
testName: 'index.getSettings(cb)',
8+
action: 'read',
9+
expectedRequest: {
10+
method: 'GET',
11+
URL: {
12+
pathname: '/1/indexes/%s/settings',
13+
query: {
14+
getVersion: '2'
15+
}
16+
}
17+
}
18+
},
19+
{
20+
object: 'index',
21+
methodName: 'getSettings',
22+
testName: 'index.getSettings({ advanced: 1 }, cb)',
23+
callArguments: [{advanced: 1}],
24+
action: 'read',
25+
expectedRequest: {
26+
method: 'GET',
27+
URL: {
28+
pathname: '/1/indexes/%s/settings',
29+
query: {
30+
getVersion: '2',
31+
advanced: '1'
32+
}
1433
}
1534
}
1635
}
17-
};
36+
];

0 commit comments

Comments
 (0)