66 lines
1.5 KiB
JavaScript
66 lines
1.5 KiB
JavaScript
var _ = require('../../lib/utils'),
|
|
errors = require('../../lib/errors'),
|
|
q = require('q');
|
|
|
|
/**
|
|
* Perform an elasticsearch [indices.get_settings](http://www.elasticsearch.org/guide/reference/api/admin-indices-get-settings/) request
|
|
*
|
|
* @for Client
|
|
* @method indices.get_settings
|
|
* @param {Object} params - An object with parameters used to carry out this action
|
|
*/
|
|
function doIndicesGetSettings(params, cb) {
|
|
if (typeof params === 'function') {
|
|
cb = params;
|
|
params = {};
|
|
} else {
|
|
params = params || {};
|
|
cb = typeof cb === 'function' ? cb : _.noop;
|
|
}
|
|
|
|
var request = {
|
|
ignore: params.ignore,
|
|
method: 'GET'
|
|
},
|
|
parts = {},
|
|
query = {},
|
|
responseOpts = {};
|
|
|
|
|
|
// find the paths's params
|
|
if (typeof params.index !== 'undefined') {
|
|
switch (typeof params.index) {
|
|
case 'string':
|
|
parts.index = params.index;
|
|
break;
|
|
case 'object':
|
|
if (_.isArray(params.index)) {
|
|
parts.index = params.index.join(',');
|
|
} else {
|
|
throw new TypeError('Invalid index: ' + params.index + ' should be a comma seperated list, array, or boolean.');
|
|
}
|
|
break;
|
|
default:
|
|
parts.index = !!params.index;
|
|
}
|
|
}
|
|
|
|
|
|
// build the path
|
|
if (parts.hasOwnProperty('index')) {
|
|
request.path = '/' + encodeURIComponent(parts.index) + '/_settings';
|
|
}
|
|
else {
|
|
request.path = '/_settings';
|
|
}
|
|
|
|
|
|
// build the query string
|
|
|
|
request.path = request.path + _.makeQueryString(query);
|
|
|
|
this.client.request(request, cb);
|
|
}
|
|
|
|
module.exports = doIndicesGetSettings;
|