From 2a2e4b9bee4a0cb03b617bb5fade07dcba5a8d78 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Tue, 12 Nov 2013 10:06:56 -0700 Subject: [PATCH 1/2] moved the API info from README.md into api.md, and added a check for methods that have no params. [ci skip] --- README.md | 22 +-- docs/api.md | 147 ++++++++++-------- scripts/generate/js_api/index.js | 14 +- .../generate/js_api/templates/api_docs.tmpl | 29 +++- scripts/generate/yaml_tests/index.js | 14 +- 5 files changed, 123 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index ed6b4e791..be6a96ff6 100644 --- a/README.md +++ b/README.md @@ -190,27 +190,7 @@ This function will receive a list of nodes received during a sniff. The list of To maintain consistency across all the low-level clients ([PHP](https://github.com/elasticsearch/elasticsearch-php), [Python](https://github.com/elasticsearch/elasticsearch-ph), [Ruby](https://github.com/elasticsearch/elasticsearch-ruby), [Perl](https://github.com/elasticsearch/elasticsearch-perl)) all API methods accept an object with parameters and a callback. If you don't pass the callback, the functions will return a promise. -### Generic Params - -Several parameters work on all API methods, and control the way that those requests are carried out: - -### ignore -Type: `Number` or `Number[]` - -Default: `null` - -Don't treat these HTTP status codes as "errors". Example use cases could be `ignore: 404` or `ignore: [404]` - -### timeout -Type: `Number` - -Default: `client.config.timeout` - -The number of milliseconds this request has to complete. It defaults to the timeout specified at the client level, which defaults to 10 seconds. - -### Methods - -All the methods can be seen [here](docs/api.md), or take a look at [api.js](src/lib/api.js). +For full details on the API, check out [api.md](docs/api.md). ### Examples diff --git a/docs/api.md b/docs/api.md index dae6e5ff1..9e717ace2 100644 --- a/docs/api.md +++ b/docs/api.md @@ -2,70 +2,82 @@ ## Table Of Contents + - [Generic Params](#generic-params) + - [Methods](#methods) + - [bulk](#bulk) + - [clearScroll](#clearscroll) + - [cluster.getSettings](#clustergetsettings) + - [cluster.health](#clusterhealth) + - [cluster.nodeHotThreads](#clusternodehotthreads) + - [cluster.nodeInfo](#clusternodeinfo) + - [cluster.nodeShutdown](#clusternodeshutdown) + - [cluster.nodeStats](#clusternodestats) + - [cluster.putSettings](#clusterputsettings) + - [cluster.reroute](#clusterreroute) + - [cluster.state](#clusterstate) + - [count](#count) + - [create](#create) + - [delete](#delete) + - [deleteByQuery](#deletebyquery) + - [exists](#exists) + - [explain](#explain) + - [get](#get) + - [getSource](#getsource) + - [index](#index) + - [indices.analyze](#indicesanalyze) + - [indices.clearCache](#indicesclearcache) + - [indices.close](#indicesclose) + - [indices.create](#indicescreate) + - [indices.delete](#indicesdelete) + - [indices.deleteAlias](#indicesdeletealias) + - [indices.deleteMapping](#indicesdeletemapping) + - [indices.deleteTemplate](#indicesdeletetemplate) + - [indices.deleteWarmer](#indicesdeletewarmer) + - [indices.exists](#indicesexists) + - [indices.existsAlias](#indicesexistsalias) + - [indices.existsType](#indicesexiststype) + - [indices.flush](#indicesflush) + - [indices.getAlias](#indicesgetalias) + - [indices.getAliases](#indicesgetaliases) + - [indices.getFieldMapping](#indicesgetfieldmapping) + - [indices.getMapping](#indicesgetmapping) + - [indices.getSettings](#indicesgetsettings) + - [indices.getTemplate](#indicesgettemplate) + - [indices.getWarmer](#indicesgetwarmer) + - [indices.open](#indicesopen) + - [indices.optimize](#indicesoptimize) + - [indices.putAlias](#indicesputalias) + - [indices.putMapping](#indicesputmapping) + - [indices.putSettings](#indicesputsettings) + - [indices.putTemplate](#indicesputtemplate) + - [indices.putWarmer](#indicesputwarmer) + - [indices.refresh](#indicesrefresh) + - [indices.segments](#indicessegments) + - [indices.snapshotIndex](#indicessnapshotindex) + - [indices.stats](#indicesstats) + - [indices.status](#indicesstatus) + - [indices.updateAliases](#indicesupdatealiases) + - [indices.validateQuery](#indicesvalidatequery) + - [info](#info) + - [mget](#mget) + - [mlt](#mlt) + - [msearch](#msearch) + - [percolate](#percolate) + - [scroll](#scroll) + - [search](#search) + - [suggest](#suggest) + - [update](#update) - - [bulk](#bulk) - - [clearScroll](#clearscroll) - - [cluster.getSettings](#clustergetsettings) - - [cluster.health](#clusterhealth) - - [cluster.nodeHotThreads](#clusternodehotthreads) - - [cluster.nodeInfo](#clusternodeinfo) - - [cluster.nodeShutdown](#clusternodeshutdown) - - [cluster.nodeStats](#clusternodestats) - - [cluster.putSettings](#clusterputsettings) - - [cluster.reroute](#clusterreroute) - - [cluster.state](#clusterstate) - - [count](#count) - - [create](#create) - - [delete](#delete) - - [deleteByQuery](#deletebyquery) - - [exists](#exists) - - [explain](#explain) - - [get](#get) - - [getSource](#getsource) - - [index](#index) - - [indices.analyze](#indicesanalyze) - - [indices.clearCache](#indicesclearcache) - - [indices.close](#indicesclose) - - [indices.create](#indicescreate) - - [indices.delete](#indicesdelete) - - [indices.deleteAlias](#indicesdeletealias) - - [indices.deleteMapping](#indicesdeletemapping) - - [indices.deleteTemplate](#indicesdeletetemplate) - - [indices.deleteWarmer](#indicesdeletewarmer) - - [indices.exists](#indicesexists) - - [indices.existsAlias](#indicesexistsalias) - - [indices.existsType](#indicesexiststype) - - [indices.flush](#indicesflush) - - [indices.getAlias](#indicesgetalias) - - [indices.getAliases](#indicesgetaliases) - - [indices.getFieldMapping](#indicesgetfieldmapping) - - [indices.getMapping](#indicesgetmapping) - - [indices.getSettings](#indicesgetsettings) - - [indices.getTemplate](#indicesgettemplate) - - [indices.getWarmer](#indicesgetwarmer) - - [indices.open](#indicesopen) - - [indices.optimize](#indicesoptimize) - - [indices.putAlias](#indicesputalias) - - [indices.putMapping](#indicesputmapping) - - [indices.putSettings](#indicesputsettings) - - [indices.putTemplate](#indicesputtemplate) - - [indices.putWarmer](#indicesputwarmer) - - [indices.refresh](#indicesrefresh) - - [indices.segments](#indicessegments) - - [indices.snapshotIndex](#indicessnapshotindex) - - [indices.stats](#indicesstats) - - [indices.status](#indicesstatus) - - [indices.updateAliases](#indicesupdatealiases) - - [indices.validateQuery](#indicesvalidatequery) - - [info](#info) - - [mget](#mget) - - [mlt](#mlt) - - [msearch](#msearch) - - [percolate](#percolate) - - [scroll](#scroll) - - [search](#search) - - [suggest](#suggest) - - [update](#update) +## Generic Params + +Several parameters can be passed to any API method, and will control the way that those requests are carried out. These parameters are not listed in each method's param list. + +| Name | Type | Description | +| ---- | ---- | ----------- | +| `[timeout=10000]` | Number | The number of milliseconds this request has to complete. It defaults to the timeout specified at the client level, which defaults to 10 seconds. | +| `ignore` | Number or Number[] | Don't treat these HTTP status codes as "errors". Example use cases could be `ignore: 404` or `ignore: [404]` | + +## Methods ### bulk() @@ -93,8 +105,7 @@ http://www.elasticsearch.org/guide/reference/api/search/scroll/ http://elasticsearch.org/guide/reference/api/admin-cluster-update-settings/ -| Name | Type | Description | -| ---- | ---- | ----------- | +-- none -- ### cluster.health() @@ -186,8 +197,7 @@ http://elasticsearch.org/guide/reference/api/admin-cluster-nodes-stats/ http://elasticsearch.org/guide/reference/api/admin-cluster-update-settings/ -| Name | Type | Description | -| ---- | ---- | ----------- | +-- none -- ### cluster.reroute() @@ -817,8 +827,7 @@ http://www.elasticsearch.org/guide/reference/api/validate/ http://elasticsearch.org/guide/ -| Name | Type | Description | -| ---- | ---- | ----------- | +-- none -- ### mget() diff --git a/scripts/generate/js_api/index.js b/scripts/generate/js_api/index.js index d842e98f2..c33f4ddda 100644 --- a/scripts/generate/js_api/index.js +++ b/scripts/generate/js_api/index.js @@ -34,11 +34,15 @@ function download() { }); } -try { - var stat = fs.statSync(outputPath); - if (!stat.isFile() || stat.ctime < Date.now() - 86400000) { +if (process.env.FORCE_GEN) { + download(); +} else { + try { + var stat = fs.statSync(outputPath); + if (!stat.isFile() || stat.ctime < Date.now() - 86400000) { + download(); + } + } catch (e) { download(); } -} catch (e) { - download(); } diff --git a/scripts/generate/js_api/templates/api_docs.tmpl b/scripts/generate/js_api/templates/api_docs.tmpl index baef4a6ad..023687ff2 100644 --- a/scripts/generate/js_api/templates/api_docs.tmpl +++ b/scripts/generate/js_api/templates/api_docs.tmpl @@ -2,7 +2,8 @@ ## Table Of Contents -<% + - [Generic Params](#generic-params) + - [Methods](#methods)<% function esc(str) { return str.replace(/\|/g, '|'); @@ -19,15 +20,30 @@ paramType = function (type) { }; _.each(actions, function (action) {%> - - [<%= action.name %>](#<%= action.name.toLowerCase().replace(/[^\w]/g, '') %>)<% + - [<%= action.name %>](#<%= action.name.toLowerCase().replace(/[^\w ]/g, '').replace(/ /g, '-') %>)<% }) +%> + +## Generic Params + +Several parameters can be passed to any API method, and will control the way that those requests are carried out. These parameters are not listed in each method's param list. + +| Name | Type | Description | +| ---- | ---- | ----------- | +| `[timeout=10000]` | Number | The number of milliseconds this request has to complete. It defaults to the timeout specified at the client level, which defaults to 10 seconds. | +| `ignore` | Number or Number[] | Don't treat these HTTP status codes as "errors". Example use cases could be `ignore: 404` or `ignore: [404]` | + +## Methods<% + _.each(actions, function (action) { %> ### <%= action.name %>() -<%= action.docUrl %> +<%= action.docUrl %><% + +if (_.size(action.allParams)) { %> | Name | Type | Description | | ---- | ---- | ----------- | @@ -36,4 +52,11 @@ _.each(actions, function (action) { %>|`<%= paramWithDefault(paramName, param.default) %>` | <%= paramType(param.type) %> | <%= esc(param.description || '') %>| <% }) +} else {%> + +-- none -- +<% + +} + }); %> diff --git a/scripts/generate/yaml_tests/index.js b/scripts/generate/yaml_tests/index.js index ae04db0d3..ad33ac29c 100644 --- a/scripts/generate/yaml_tests/index.js +++ b/scripts/generate/yaml_tests/index.js @@ -30,11 +30,15 @@ function download() { }); } -try { - var stat = fs.statSync(testFile); - if (!stat.isFile() || stat.ctime < Date.now() - 86400000) { +if (process.env.FORCE_GEN) { + download(); +} else { + try { + var stat = fs.statSync(testFile); + if (!stat.isFile() || stat.ctime < Date.now() - 86400000) { + download(); + } + } catch (e) { download(); } -} catch (e) { - download(); } From 58494af3d1b4a0500c405f95e9a310ddd183c4bd Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Tue, 12 Nov 2013 16:31:36 -0700 Subject: [PATCH 2/2] added simpler specification of the host and port for the browser tests --- Gruntfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 21b0f2006..984ee5275 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -234,8 +234,8 @@ module.exports = function (grunt) { * This is run in the default and browser_tests:{{browser}} tests. */ grunt.registerMultiTask('open_browser_tests', function () { - var host = process.env.ES_HOST || 'localhost'; - var port = process.env.ES_PORT || 9200; + var host = grunt.option('host') || 'localhost'; + var port = grunt.option('port') || 9200; var taskData = this.data; grunt.task.requires([