Files
elasticsearch-js/src/api/indices/get_settings.js
2013-10-03 10:05:58 -07:00

65 lines
1.5 KiB
JavaScript

var _ = require('../../lib/toolbelt')
, paramHelper = require('../../lib/param_helper');
/**
* 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, callback) {
params = params || {};
var request = {
ignore: params.ignore
}
, url = {}
, query = {}
, responseOpts = {};
request.method = 'get';
// find the url's params
if (typeof params.index !== 'undefined') {
switch (typeof params.index) {
case 'string':
url.index = params.index;
break;
case 'object':
if (_.isArray(params.index)) {
url.index = params.index.join(',');
} else {
throw new TypeError('Invalid index: ' + params.index + ' should be a comma seperated list, array, or boolean.');
}
break;
default:
url.index = !!params.index;
}
}
// build the url
if (url.hasOwnProperty('index')) {
request.url = '/' + encodeURIComponent(url.index) + '/_settings';
}
else {
request.url = '/_settings';
}
// build the query string
request.url = request.url + _.makeQueryString(query);
var reqPromise = this.client.request(request);
if (callback) {
reqPromise.then(_.bind(callback, null, null), callback);
}
return reqPromise;
}
module.exports = doIndicesGetSettings;