// Licensed to Elasticsearch B.V under one or more agreements. // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information 'use strict' /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ function buildIndicesGetAlias (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts /** * Perform a [indices.get_alias](https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-aliases.html) request * * @param {list} index - A comma-separated list of index names to filter aliases * @param {list} name - A comma-separated list of alias names to return * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ const acceptedQuerystring = [ 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'local', 'pretty', 'human', 'error_trace', 'source', 'filter_path' ] const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path' } return function indicesGetAlias (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options options = {} } if (typeof params === 'function' || params == null) { callback = params params = {} options = {} } // check required parameters if (params.body != null) { const err = new ConfigurationError('This API does not require a body') return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) return handleError(err, callback) } var warnings = [] var { method, body, index, name, ...querystring } = params querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) if (method == null) { method = 'GET' } var ignore = options.ignore if (typeof ignore === 'number') { options.ignore = [ignore] } var path = '' if ((index) != null && (name) != null) { path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) } else if ((name) != null) { path = '/' + '_alias' + '/' + encodeURIComponent(name) } else if ((index) != null) { path = '/' + encodeURIComponent(index) + '/' + '_alias' } else { path = '/' + '_alias' } // build request object const request = { method, path, body: null, querystring } options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) } } module.exports = buildIndicesGetAlias