diff --git a/docs/api_methods_1_x.asciidoc b/docs/api_methods_1_x.asciidoc index 553097826..0ba6203f4 100644 --- a/docs/api_methods_1_x.asciidoc +++ b/docs/api_methods_1_x.asciidoc @@ -31,6 +31,9 @@ NOTE: At this time, you must opt into the 1.x API by setting the `apiVersion` co * <> * <> * <> +* <> +* <> +* <> * <> * <> * <> @@ -1537,7 +1540,7 @@ client.searchTemplate([params, [callback]]) // no description -The default method is `POST` and the usual <> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-search.html[the elasticsearch docs] for more about this method. +The default method is `POST` and the usual <> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for more about this method. // no examples @@ -1545,6 +1548,32 @@ The default method is `POST` and the usual <> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html[the elasticsearch docs] for more about this method. + +// no examples + + +==== Params + +[horizontal] +`name`:: +`String` -- A benchmark name + +link:#[back to top] + +[[api-benchmark-list-1-x]] +=== `benchmark.list` + +[source,js] +-------- +client.benchmark.list([params, [callback]]) +-------- + +// no description + +The default method is `GET` and the usual <> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html[the elasticsearch docs] for more about this method. + +// no examples + + +==== Params + +[horizontal] +`index`:: +`String, String[], Boolean` -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`type`:: +`String` -- The name of the document type + +link:#[back to top] + +[[api-benchmark-submit-1-x]] +=== `benchmark.submit` + +[source,js] +-------- +client.benchmark.submit([params, [callback]]) +-------- + +// no description + +The default method is `PUT` and the usual <> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html[the elasticsearch docs] for more about this method. + +// no examples + + +==== Params + +[horizontal] +`verbose`:: +`Boolean` -- Specify whether to return verbose statistics about each iteration (default: false) +`index`:: +`String, String[], Boolean` -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`type`:: +`String` -- The name of the document type + +link:#[back to top] + [[api-cat-aliases-1-x]] === `cat.aliases` diff --git a/docs/api_methods_master.asciidoc b/docs/api_methods_master.asciidoc index ffbb2ce52..915a49492 100644 --- a/docs/api_methods_master.asciidoc +++ b/docs/api_methods_master.asciidoc @@ -31,6 +31,9 @@ NOTE: At this time, you must opt into the master API by setting the `apiVersion` * <> * <> * <> +* <> +* <> +* <> * <> * <> * <> @@ -1537,7 +1540,7 @@ client.searchTemplate([params, [callback]]) // no description -The default method is `POST` and the usual <> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-search.html[the elasticsearch docs] for more about this method. +The default method is `POST` and the usual <> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html[the elasticsearch docs] for more about this method. // no examples @@ -1545,6 +1548,32 @@ The default method is `POST` and the usual <> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html[the elasticsearch docs] for more about this method. + +// no examples + + +==== Params + +[horizontal] +`name`:: +`String` -- A benchmark name + +link:#[back to top] + +[[api-benchmark-list-master]] +=== `benchmark.list` + +[source,js] +-------- +client.benchmark.list([params, [callback]]) +-------- + +// no description + +The default method is `GET` and the usual <> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html[the elasticsearch docs] for more about this method. + +// no examples + + +==== Params + +[horizontal] +`index`:: +`String, String[], Boolean` -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`type`:: +`String` -- The name of the document type + +link:#[back to top] + +[[api-benchmark-submit-master]] +=== `benchmark.submit` + +[source,js] +-------- +client.benchmark.submit([params, [callback]]) +-------- + +// no description + +The default method is `PUT` and the usual <> apply. See http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html[the elasticsearch docs] for more about this method. + +// no examples + + +==== Params + +[horizontal] +`verbose`:: +`Boolean` -- Specify whether to return verbose statistics about each iteration (default: false) +`index`:: +`String, String[], Boolean` -- A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +`type`:: +`String` -- The name of the document type + +link:#[back to top] + [[api-cat-aliases-master]] === `cat.aliases` diff --git a/package.json b/package.json index bde095877..777b69b6f 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "load-grunt-tasks": "~0.2.0", "load-grunt-config": "~0.7.0", "grunt-s3": "~0.2.0-alpha.3", - "grunt-run": "*", + "grunt-run": "^0.2.2", "grunt-contrib-compress": "~0.5.3", "grunt-contrib-copy": "~0.4.1", "grunt-prompt": "~0.1.2", diff --git a/src/lib/apis/1_x.js b/src/lib/apis/1_x.js index 982c1cc6c..b43469a8e 100644 --- a/src/lib/apis/1_x.js +++ b/src/lib/apis/1_x.js @@ -3,7 +3,104 @@ var ca = require('../client_action'); var api = module.exports = {}; -api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot']; +api._namespaces = ['benchmark', 'cat', 'cluster', 'indices', 'nodes', 'snapshot']; + +api.benchmark = function BenchmarkNS(transport) { + this.transport = transport; +}; + +/** + * Perform a [benchmark.abort](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {String} params.name - A benchmark name + */ +api.benchmark.prototype.abort = ca({ + url: { + fmt: '/_bench/abort/<%=name%>', + req: { + name: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [benchmark.list](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {String} params.type - The name of the document type + */ +api.benchmark.prototype.list = ca({ + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_bench', + req: { + index: { + type: 'list' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_bench', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_bench' + } + ] +}); + +/** + * Perform a [benchmark.submit](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {Boolean} params.verbose - Specify whether to return verbose statistics about each iteration (default: false) + * @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {String} params.type - The name of the document type + */ +api.benchmark.prototype.submit = ca({ + params: { + verbose: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_bench', + req: { + index: { + type: 'list' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_bench', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_bench' + } + ], + method: 'PUT' +}); /** * Perform a [bulk](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/docs-bulk.html) request @@ -4726,13 +4823,60 @@ api.search = ca({ }); /** - * Perform a [searchTemplate](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-search.html) request + * Perform a [searchTemplate](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html) request * * @param {Object} params - An object with parameters used to carry out this action + * @param {Boolean} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {Boolean} params.allowNoIndices - 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 {String} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {String, String[], Boolean} params.routing - A comma-separated list of specific routing values + * @param {Duration} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {String} params.searchType - Search operation type * @param {String, String[], Boolean} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices * @param {String, String[], Boolean} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types */ api.searchTemplate = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed' + ], + name: 'expand_wildcards' + }, + preference: { + type: 'string' + }, + routing: { + type: 'list' + }, + scroll: { + type: 'duration' + }, + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'query_and_fetch', + 'dfs_query_then_fetch', + 'dfs_query_and_fetch', + 'count', + 'scan' + ], + name: 'search_type' + } + }, urls: [ { fmt: '/<%=index%>/<%=type%>/_search/template', diff --git a/src/lib/apis/master.js b/src/lib/apis/master.js index 0d5b5ec0e..a4af5d581 100644 --- a/src/lib/apis/master.js +++ b/src/lib/apis/master.js @@ -3,7 +3,104 @@ var ca = require('../client_action'); var api = module.exports = {}; -api._namespaces = ['cat', 'cluster', 'indices', 'nodes', 'snapshot']; +api._namespaces = ['benchmark', 'cat', 'cluster', 'indices', 'nodes', 'snapshot']; + +api.benchmark = function BenchmarkNS(transport) { + this.transport = transport; +}; + +/** + * Perform a [benchmark.abort](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {String} params.name - A benchmark name + */ +api.benchmark.prototype.abort = ca({ + url: { + fmt: '/_bench/abort/<%=name%>', + req: { + name: { + type: 'string' + } + } + }, + method: 'POST' +}); + +/** + * Perform a [benchmark.list](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {String} params.type - The name of the document type + */ +api.benchmark.prototype.list = ca({ + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_bench', + req: { + index: { + type: 'list' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_bench', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_bench' + } + ] +}); + +/** + * Perform a [benchmark.submit](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-benchmark.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {Boolean} params.verbose - Specify whether to return verbose statistics about each iteration (default: false) + * @param {String, String[], Boolean} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {String} params.type - The name of the document type + */ +api.benchmark.prototype.submit = ca({ + params: { + verbose: { + type: 'boolean' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_bench', + req: { + index: { + type: 'list' + }, + type: { + type: 'string' + } + } + }, + { + fmt: '/<%=index%>/_bench', + req: { + index: { + type: 'list' + } + } + }, + { + fmt: '/_bench' + } + ], + method: 'PUT' +}); /** * Perform a [bulk](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/docs-bulk.html) request @@ -4726,13 +4823,60 @@ api.search = ca({ }); /** - * Perform a [searchTemplate](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-search.html) request + * Perform a [searchTemplate](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html) request * * @param {Object} params - An object with parameters used to carry out this action + * @param {Boolean} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {Boolean} params.allowNoIndices - 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 {String} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) + * @param {String, String[], Boolean} params.routing - A comma-separated list of specific routing values + * @param {Duration} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {String} params.searchType - Search operation type * @param {String, String[], Boolean} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices * @param {String, String[], Boolean} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types */ api.searchTemplate = ca({ + params: { + ignoreUnavailable: { + type: 'boolean', + name: 'ignore_unavailable' + }, + allowNoIndices: { + type: 'boolean', + name: 'allow_no_indices' + }, + expandWildcards: { + type: 'enum', + 'default': 'open', + options: [ + 'open', + 'closed' + ], + name: 'expand_wildcards' + }, + preference: { + type: 'string' + }, + routing: { + type: 'list' + }, + scroll: { + type: 'duration' + }, + searchType: { + type: 'enum', + options: [ + 'query_then_fetch', + 'query_and_fetch', + 'dfs_query_then_fetch', + 'dfs_query_and_fetch', + 'count', + 'scan' + ], + name: 'search_type' + } + }, urls: [ { fmt: '/<%=index%>/<%=type%>/_search/template', diff --git a/test/integration/yaml_suite/yaml_doc.js b/test/integration/yaml_suite/yaml_doc.js index 6cc5f66ba..ddaef2e4a 100644 --- a/test/integration/yaml_suite/yaml_doc.js +++ b/test/integration/yaml_suite/yaml_doc.js @@ -341,9 +341,19 @@ YamlDoc.prototype = { var clientAction = this.get(clientActionName, client); var params = _.transform(args[action], function (params, val, name) { var camelName = _.camelCase(name); - // undocumented params should be passed through as-is + + // search through the params and url peices to find this param name var paramName = name; - if (clientAction && clientAction.spec && clientAction.spec.params && clientAction.spec.params[camelName]) { + var spec = clientAction && clientAction.spec; + var knownParam = spec && spec.params && spec.params[camelName]; + var knownUrlParam = spec && !knownParam && !!_.find(spec.url ? [spec.url] : spec.urls, function (url) { + if ((url.opt && url.opt[camelName]) || (url.req && url.req[camelName])) { + return true; + } + }); + + // if we do know this param name, use the camelCase verison + if (knownParam || knownUrlParam) { paramName = camelName; } @@ -375,41 +385,36 @@ YamlDoc.prototype = { expect(clientAction || clientActionName).to.be.a('function'); - if (typeof clientAction === 'function') { - if (_.isNumeric(catcher)) { - params.ignore = _.union(params.ignore || [], [catcher]); - catcher = null; - } - - var cb = _.bind(function (error, body, status) { - this._last_requests_response = body; - - if (error) { - if (catcher) { - if (catcher instanceof RegExp) { - // error message should match the regexp - expect(error.message).to.match(catcher); - error = null; - } else if (typeof catcher === 'function') { - // error should be an instance of - expect(error).to.be.a(catcher); - error = null; - } else { - return done(new Error('Invalid catcher ' + catcher)); - } - } else { - return done(error); - } - } - - done(error); - }, this); - - clientAction.call(client, params, cb); - } else { - done(new Error('stepped in do_do, did not find a function')); + if (_.isNumeric(catcher)) { + params.ignore = _.union(params.ignore || [], [catcher]); + catcher = null; } + var cb = _.bind(function (error, body, status) { + this._last_requests_response = body; + + if (error) { + if (catcher) { + if (catcher instanceof RegExp) { + // error message should match the regexp + expect(error.message).to.match(catcher); + error = null; + } else if (typeof catcher === 'function') { + // error should be an instance of + expect(error).to.be.a(catcher); + error = null; + } else { + return done(new Error('Invalid catcher ' + catcher)); + } + } else { + return done(error); + } + } + + done(error); + }, this); + + clientAction.call(client, params, cb); }, /**