From 1f76feae4df5b03c44735da91b9f1a378d49709f Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Mon, 27 Oct 2014 23:59:34 -0700 Subject: [PATCH] [aliases] add updated aliases for 1.x --- scripts/generate/aliases.js | 9 +++++++++ scripts/generate/js_api.js | 11 +++++++++-- src/lib/apis/1_x.js | 30 ++++++++++-------------------- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/scripts/generate/aliases.js b/scripts/generate/aliases.js index 3c4170ac9..d05e2b62f 100644 --- a/scripts/generate/aliases.js +++ b/scripts/generate/aliases.js @@ -162,5 +162,14 @@ module.exports = [ '/_snapshot/{repository}/{snapshot}/_create' ] } + }, + { + version: '>1.4.0', + aliases: { + 'indices.putAlias': [ + // '/{index}/_alias/{name}', + '/{index}/_aliases/{name}' + ] + } } ]; \ No newline at end of file diff --git a/scripts/generate/js_api.js b/scripts/generate/js_api.js index 458678088..b334d79ad 100644 --- a/scripts/generate/js_api.js +++ b/scripts/generate/js_api.js @@ -19,14 +19,21 @@ module.exports = function (branch, done) { var docVars; // slightly modified clone of apiSpec for the docs var branchSuffix = utils.branchSuffix(branch); + var maxMinorVersion = (function () { + var branches = require(fromRoot('package.json')).config.supported_es_branches; + var top = branches.map(function (v) { return v + '.0'; }).sort(semver.compare).pop(); + return top.split('.')[1]; + }()); + var branchAsVersion = (function () { var m; + // master === the highest version number if (branch === 'master') return '999.999.999'; // n.m -> n.m.0 if (m = branch.match(/^\d+\.\d+$/)) return branch + '.0'; - // n.x -> n.0.0 - if (m = branch.match(/^(\d+)\.x$/i)) return m[1] + '.0.0'; + // n.x -> n.(maxVersion + 1).0 + if (m = branch.match(/^(\d+)\.x$/i)) return m[1] + '.' + (+maxMinorVersion + 1) + '.0'; throw new Error('unable to convert branch "' + branch + '" to semver'); }()); diff --git a/src/lib/apis/1_x.js b/src/lib/apis/1_x.js index e55949537..05e344f7a 100644 --- a/src/lib/apis/1_x.js +++ b/src/lib/apis/1_x.js @@ -3237,7 +3237,7 @@ api.indices.prototype.optimize = ca({ * @param {Object} params - An object with parameters used to carry out this action * @param {Date, Number} params.timeout - Explicit timestamp for the document * @param {Date, Number} params.masterTimeout - Specify timeout for connection to master - * @param {String, String[], Boolean} params.index - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` or omit to perform the operation on all indices. + * @param {String, String[], Boolean} params.index - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. * @param {String} params.name - The name of the alias to be created or updated */ api.indices.prototype.putAlias = ca({ @@ -3250,27 +3250,17 @@ api.indices.prototype.putAlias = ca({ name: 'master_timeout' } }, - urls: [ - { - fmt: '/<%=index%>/_alias/<%=name%>', - req: { - index: { - type: 'list' - }, - name: { - type: 'string' - } - } - }, - { - fmt: '/_alias/<%=name%>', - req: { - name: { - type: 'string' - } + url: { + fmt: '/<%=index%>/_alias/<%=name%>', + req: { + index: { + type: 'list' + }, + name: { + type: 'string' } } - ], + }, method: 'PUT' });